@@ -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 )
@@ -868,10 +874,64 @@ ble_ll_cs_hci_remove_config(const uint8_t *cmdbuf, uint8_t cmdlen)
868
874
return BLE_ERR_SUCCESS ;
869
875
}
870
876
877
+ static int
878
+ ble_ll_cs_proc_set_chan_class (const uint8_t * channel_classification )
879
+ {
880
+ uint8_t i , j , next_id , byte ;
881
+
882
+ /* TODO:
883
+ * 1. The interval between two successive commands sent shall be at least 1 second.
884
+ * Otherwise, the Controller shall return the error code Command Disallowed (0x0C).
885
+ *
886
+ * 2. Combine the Host chan_class with local chan_class capabilities?
887
+ */
888
+
889
+ if (channel_classification [0 ] & 0b00000011 ||
890
+ channel_classification [2 ] & 0b10000000 ||
891
+ channel_classification [3 ] & 0b00000011 ||
892
+ channel_classification [9 ] & 0b11100000 ) {
893
+ /* Channels 0, 1, 23, 24, 25, 77, 78, and the bit 79 (non-channel)
894
+ * are RFU. At least 15 channels shall be enabled.
895
+ */
896
+ return -1 ;
897
+ }
898
+
899
+ for (i = 0 , j = 0 ; i < ARRAY_SIZE (g_ble_ll_cs_chan_class ); ++ i ) {
900
+ byte = channel_classification [i ];
901
+ next_id = i * 8 ;
902
+
903
+ while (byte ) {
904
+ if (byte & 1 ) {
905
+ g_ble_ll_cs_chan_indices [j ++ ] = next_id ;
906
+ }
907
+ ++ next_id ;
908
+ byte >>= 1 ;
909
+ }
910
+ }
911
+
912
+ g_ble_ll_cs_chan_count = j ;
913
+ if (g_ble_ll_cs_chan_count < 15 ) {
914
+ return -1 ;
915
+ }
916
+
917
+ memcpy (g_ble_ll_cs_chan_class , channel_classification ,
918
+ sizeof (g_ble_ll_cs_chan_class ));
919
+
920
+ return 0 ;
921
+ }
922
+
871
923
int
872
924
ble_ll_cs_hci_set_chan_class (const uint8_t * cmdbuf , uint8_t cmdlen )
873
925
{
874
- return BLE_ERR_UNSUPPORTED ;
926
+ int rc ;
927
+ const struct ble_hci_le_cs_set_chan_class_cp * cmd = (const void * )cmdbuf ;
928
+
929
+ rc = ble_ll_cs_proc_set_chan_class (cmd -> channel_classification );
930
+ if (rc ) {
931
+ return BLE_ERR_INV_HCI_CMD_PARMS ;
932
+ }
933
+
934
+ return BLE_ERR_SUCCESS ;
875
935
}
876
936
877
937
int
@@ -928,6 +988,8 @@ ble_ll_cs_init(void)
928
988
cap -> t_fcs_capability = 0x0100 ;
929
989
cap -> t_pm_capability = 0x0004 ;
930
990
cap -> tx_snr_capablity = 0x00 ;
991
+
992
+ ble_ll_cs_proc_set_chan_class (default_channel_classification );
931
993
}
932
994
933
995
void
0 commit comments