@@ -69,6 +69,12 @@ static const uint8_t t_ip1[] = {10, 20, 30, 40, 50, 60, 80, 145};
69
69
static const uint8_t t_ip2 [] = {10 , 20 , 30 , 40 , 50 , 60 , 80 , 145 };
70
70
static const uint8_t t_fcs [] = {15 , 20 , 30 , 40 , 50 , 60 , 80 , 100 , 120 , 150 };
71
71
static const uint8_t t_pm [] = {10 , 20 , 40 };
72
+ static const uint8_t default_channel_classification [10 ] = {
73
+ 0xFC , 0xFF , 0x7F , 0xFC , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0x1F
74
+ };
75
+ static uint8_t g_ble_ll_cs_chan_class [10 ];
76
+ static uint8_t g_ble_ll_cs_chan_count = 0 ;
77
+ static uint8_t g_ble_ll_cs_chan_indices [72 ];
72
78
73
79
void ble_ll_ctrl_rej_ext_ind_make (uint8_t rej_opcode , uint8_t err , uint8_t * ctrdata );
74
80
@@ -1120,10 +1126,64 @@ ble_ll_cs_hci_remove_config(const uint8_t *cmdbuf, uint8_t cmdlen)
1120
1126
return BLE_ERR_SUCCESS ;
1121
1127
}
1122
1128
1129
+ static int
1130
+ ble_ll_cs_proc_set_chan_class (const uint8_t * channel_classification )
1131
+ {
1132
+ uint8_t i , j , next_id , byte ;
1133
+
1134
+ /* TODO:
1135
+ * 1. The interval between two successive commands sent shall be at least 1 second.
1136
+ * Otherwise, the Controller shall return the error code Command Disallowed (0x0C).
1137
+ *
1138
+ * 2. Combine the Host chan_class with local chan_class capabilities?
1139
+ */
1140
+
1141
+ if (channel_classification [0 ] & 0b00000011 ||
1142
+ channel_classification [2 ] & 0b10000000 ||
1143
+ channel_classification [3 ] & 0b00000011 ||
1144
+ channel_classification [9 ] & 0b11100000 ) {
1145
+ /* Channels 0, 1, 23, 24, 25, 77, 78, and the bit 79 (non-channel)
1146
+ * are RFU. At least 15 channels shall be enabled.
1147
+ */
1148
+ return -1 ;
1149
+ }
1150
+
1151
+ for (i = 0 , j = 0 ; i < ARRAY_SIZE (g_ble_ll_cs_chan_class ); ++ i ) {
1152
+ byte = channel_classification [i ];
1153
+ next_id = i * 8 ;
1154
+
1155
+ while (byte ) {
1156
+ if (byte & 1 ) {
1157
+ g_ble_ll_cs_chan_indices [j ++ ] = next_id ;
1158
+ }
1159
+ ++ next_id ;
1160
+ byte >>= 1 ;
1161
+ }
1162
+ }
1163
+
1164
+ g_ble_ll_cs_chan_count = j ;
1165
+ if (g_ble_ll_cs_chan_count < 15 ) {
1166
+ return -1 ;
1167
+ }
1168
+
1169
+ memcpy (g_ble_ll_cs_chan_class , channel_classification ,
1170
+ sizeof (g_ble_ll_cs_chan_class ));
1171
+
1172
+ return 0 ;
1173
+ }
1174
+
1123
1175
int
1124
1176
ble_ll_cs_hci_set_chan_class (const uint8_t * cmdbuf , uint8_t cmdlen )
1125
1177
{
1126
- return BLE_ERR_UNSUPPORTED ;
1178
+ int rc ;
1179
+ const struct ble_hci_le_cs_set_chan_class_cp * cmd = (const void * )cmdbuf ;
1180
+
1181
+ rc = ble_ll_cs_proc_set_chan_class (cmd -> channel_classification );
1182
+ if (rc ) {
1183
+ return BLE_ERR_INV_HCI_CMD_PARMS ;
1184
+ }
1185
+
1186
+ return BLE_ERR_SUCCESS ;
1127
1187
}
1128
1188
1129
1189
int
@@ -1180,6 +1240,8 @@ ble_ll_cs_init(void)
1180
1240
cap -> t_fcs_capability = 1 << T_FCS_CAP_ID_150US ;
1181
1241
cap -> t_pm_capability = 1 << T_PM_CAP_ID_40US ;
1182
1242
cap -> tx_snr_capablity = 0x00 ;
1243
+
1244
+ ble_ll_cs_proc_set_chan_class (default_channel_classification );
1183
1245
}
1184
1246
1185
1247
void
0 commit comments