@@ -35,6 +35,12 @@ static const uint8_t t_ip1[] = {10, 20, 30, 40, 50, 60, 80, 145};
35
35
static const uint8_t t_ip2 [] = {10 , 20 , 30 , 40 , 50 , 60 , 80 , 145 };
36
36
static const uint8_t t_fcs [] = {15 , 20 , 30 , 40 , 50 , 60 , 80 , 100 , 120 , 150 };
37
37
static const uint8_t t_pm [] = {10 , 20 , 40 };
38
+ static const uint8_t default_channel_classification [10 ] = {
39
+ 0xFC , 0xFF , 0x7F , 0xFC , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0x1F
40
+ };
41
+ static uint8_t g_ble_ll_cs_chan_class [10 ];
42
+ static uint8_t g_ble_ll_cs_chan_count = 0 ;
43
+ static uint8_t g_ble_ll_cs_chan_indices [72 ];
38
44
39
45
int
40
46
ble_ll_cs_hci_rd_loc_supp_cap (uint8_t * rspbuf , uint8_t * rsplen )
@@ -858,10 +864,64 @@ ble_ll_cs_hci_remove_config(const uint8_t *cmdbuf, uint8_t cmdlen)
858
864
return BLE_ERR_SUCCESS ;
859
865
}
860
866
867
+ static int
868
+ ble_ll_cs_proc_set_chan_class (const uint8_t * channel_classification )
869
+ {
870
+ uint8_t i , j , next_id , byte ;
871
+
872
+ /* TODO:
873
+ * 1. The interval between two successive commands sent shall be at least 1 second.
874
+ * Otherwise, the Controller shall return the error code Command Disallowed (0x0C).
875
+ *
876
+ * 2. Combine the Host chan_class with local chan_class capabilities?
877
+ */
878
+
879
+ if (channel_classification [0 ] & 0b00000011 ||
880
+ channel_classification [2 ] & 0b10000000 ||
881
+ channel_classification [3 ] & 0b00000011 ||
882
+ channel_classification [9 ] & 0b11100000 ) {
883
+ /* Channels 0, 1, 23, 24, 25, 77, 78, and the bit 79 (non-channel)
884
+ * are RFU. At least 15 channels shall be enabled.
885
+ */
886
+ return -1 ;
887
+ }
888
+
889
+ for (i = 0 , j = 0 ; i < ARRAY_SIZE (g_ble_ll_cs_chan_class ); ++ i ) {
890
+ byte = channel_classification [i ];
891
+ next_id = i * 8 ;
892
+
893
+ while (byte ) {
894
+ if (byte & 1 ) {
895
+ g_ble_ll_cs_chan_indices [j ++ ] = next_id ;
896
+ }
897
+ ++ next_id ;
898
+ byte >>= 1 ;
899
+ }
900
+ }
901
+
902
+ g_ble_ll_cs_chan_count = j ;
903
+ if (g_ble_ll_cs_chan_count < 15 ) {
904
+ return -1 ;
905
+ }
906
+
907
+ memcpy (g_ble_ll_cs_chan_class , channel_classification ,
908
+ sizeof (g_ble_ll_cs_chan_class ));
909
+
910
+ return 0 ;
911
+ }
912
+
861
913
int
862
914
ble_ll_cs_hci_set_chan_class (const uint8_t * cmdbuf , uint8_t cmdlen )
863
915
{
864
- return BLE_ERR_UNSUPPORTED ;
916
+ int rc ;
917
+ const struct ble_hci_le_cs_set_chan_class_cp * cmd = (const void * )cmdbuf ;
918
+
919
+ rc = ble_ll_cs_proc_set_chan_class (cmd -> channel_classification );
920
+ if (rc ) {
921
+ return BLE_ERR_INV_HCI_CMD_PARMS ;
922
+ }
923
+
924
+ return BLE_ERR_SUCCESS ;
865
925
}
866
926
867
927
int
@@ -918,6 +978,8 @@ ble_ll_cs_init(void)
918
978
cap -> t_fcs_capability = 0x0100 ;
919
979
cap -> t_pm_capability = 0x0004 ;
920
980
cap -> tx_snr_capablity = 0x00 ;
981
+
982
+ ble_ll_cs_proc_set_chan_class (default_channel_classification );
921
983
}
922
984
923
985
void
0 commit comments