Skip to content

Commit ea15570

Browse files
committed
Bluetooth: Controller: Ifdef out HCI cmds unused by Zephyr host
Several HCI commands are not used by Zephyr host. Removing them saves NVM. Leave the commands supported when the host is unknown. Reasons for removing: - le_read_filter_accept_list_size: Available via kconfig - le_read_number_of_supported_adv_sets: Available via kconfig - le_read_periodic_adv_list_size: Available via kconfig - le_read_suggested_default_data_length: Available via kconfig - le_read_channel_map: Written by host/app - le_read_adv_physical_channel_tx_power: Written by host/app - le_set_host_feature_v2: No host feature bit >255 - le_clear_adv_sets: Use by application would break host state Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
1 parent 271acea commit ea15570

1 file changed

Lines changed: 34 additions & 2 deletions

File tree

subsys/bluetooth/controller/hci_internal.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,15 +298,15 @@ static bool check_and_handle_is_host_using_legacy_and_extended_commands(uint8_t
298298
break;
299299
#endif /* CONFIG_BT_BROADCASTER || CONFIG_BT_OBSERVER || CONFIG_BT_CENTRAL */
300300

301-
#if defined(CONFIG_BT_OBSERVER)
301+
#if defined(CONFIG_BT_OBSERVER) && !defined(CONFIG_BT_HCI_HOST)
302302
case SDC_HCI_OPCODE_CMD_LE_READ_ADV_PHYSICAL_CHANNEL_TX_POWER:
303303
/* Legacy command which generates a command complete with exactly one byte payload.
304304
*/
305305
command_complete_param_length += 1;
306306
event_out_params[0] = 0;
307307
type_of_adv_cmd_needed = ADV_COMMAND_TYPE_LEGACY;
308308
break;
309-
#endif /* CONFIG_BT_OBSERVER */
309+
#endif /* defined(CONFIG_BT_OBSERVER) && !defined(CONFIG_BT_HCI_HOST) */
310310

311311
case SDC_HCI_OPCODE_CMD_CB_RESET:
312312
type_of_adv_cmd_used_since_reset = ADV_COMMAND_TYPE_NONE;
@@ -383,7 +383,9 @@ void hci_internal_supported_commands(sdc_hci_ip_supported_commands_t *cmds)
383383

384384
#if defined(CONFIG_BT_BROADCASTER)
385385
cmds->hci_le_set_advertising_parameters = 1;
386+
#if !defined(CONFIG_BT_HCI_HOST)
386387
cmds->hci_le_read_advertising_physical_channel_tx_power = 1;
388+
#endif
387389
cmds->hci_le_set_advertising_data = 1;
388390
cmds->hci_le_set_scan_response_data = 1;
389391
cmds->hci_le_set_advertising_enable = 1;
@@ -403,7 +405,9 @@ void hci_internal_supported_commands(sdc_hci_ip_supported_commands_t *cmds)
403405
#endif
404406

405407
#if defined(CONFIG_BT_CTLR_FILTER_ACCEPT_LIST)
408+
#if !defined(CONFIG_BT_HCI_HOST)
406409
cmds->hci_le_read_filter_accept_list_size = 1;
410+
#endif
407411
cmds->hci_le_clear_filter_accept_list = 1;
408412
cmds->hci_le_add_device_to_filter_accept_list = 1;
409413
cmds->hci_le_remove_device_from_filter_accept_list = 1;
@@ -418,7 +422,9 @@ void hci_internal_supported_commands(sdc_hci_ip_supported_commands_t *cmds)
418422
#endif
419423

420424
#if defined(CONFIG_BT_CONN)
425+
#if !defined(CONFIG_BT_HCI_HOST)
421426
cmds->hci_le_read_channel_map = 1;
427+
#endif
422428
cmds->hci_le_read_remote_features = 1;
423429
#endif
424430

@@ -468,7 +474,9 @@ void hci_internal_supported_commands(sdc_hci_ip_supported_commands_t *cmds)
468474

469475
#if defined(CONFIG_BT_CTLR_DATA_LENGTH)
470476
cmds->hci_le_set_data_length = 1;
477+
#if !defined(CONFIG_BT_HCI_HOST)
471478
cmds->hci_le_read_suggested_default_data_length = 1;
479+
#endif
472480
cmds->hci_le_write_suggested_default_data_length = 1;
473481
#endif
474482

@@ -500,9 +508,13 @@ void hci_internal_supported_commands(sdc_hci_ip_supported_commands_t *cmds)
500508
cmds->hci_le_set_extended_scan_response_data = 1;
501509
cmds->hci_le_set_extended_advertising_enable = 1;
502510
cmds->hci_le_read_maximum_advertising_data_length = 1;
511+
#if !defined(CONFIG_BT_HCI_HOST)
503512
cmds->hci_le_read_number_of_supported_advertising_sets = 1;
513+
#endif
504514
cmds->hci_le_remove_advertising_set = 1;
515+
#if !defined(CONFIG_BT_HCI_HOST)
505516
cmds->hci_le_clear_advertising_sets = 1;
517+
#endif /* !defined(CONFIG_BT_HCI_HOST) */
506518
#if defined(CONFIG_BT_PER_ADV)
507519
cmds->hci_le_set_periodic_advertising_parameters = 1;
508520
cmds->hci_le_set_periodic_advertising_data = 1;
@@ -529,7 +541,9 @@ void hci_internal_supported_commands(sdc_hci_ip_supported_commands_t *cmds)
529541
cmds->hci_le_add_device_to_periodic_advertiser_list = 1;
530542
cmds->hci_le_remove_device_from_periodic_advertiser_list = 1;
531543
cmds->hci_le_clear_periodic_advertiser_list = 1;
544+
#if !defined(CONFIG_BT_HCI_HOST)
532545
cmds->hci_le_read_periodic_advertiser_list_size = 1;
546+
#endif
533547
cmds->hci_le_set_periodic_advertising_receive_enable = 1;
534548
#endif
535549
#if defined(CONFIG_BT_CTLR_SDC_PAWR_SYNC)
@@ -592,8 +606,10 @@ void hci_internal_supported_commands(sdc_hci_ip_supported_commands_t *cmds)
592606

593607
#if defined(CONFIG_BT_CTLR_SET_HOST_FEATURE)
594608
cmds->hci_le_set_host_feature = 1;
609+
#if !defined(CONFIG_BT_HCI_HOST)
595610
cmds->hci_le_set_host_feature_v2 = 1;
596611
#endif
612+
#endif
597613

598614
#if defined(CONFIG_BT_CTLR_CENTRAL_ISO)
599615
cmds->hci_le_set_cig_parameters = 1;
@@ -958,10 +974,12 @@ static uint8_t le_controller_cmd_put(uint8_t const * const cmd,
958974
case SDC_HCI_OPCODE_CMD_LE_SET_ADV_PARAMS:
959975
return sdc_hci_cmd_le_set_adv_params((void *)cmd_params);
960976

977+
#if !defined(CONFIG_BT_HCI_HOST)
961978
case SDC_HCI_OPCODE_CMD_LE_READ_ADV_PHYSICAL_CHANNEL_TX_POWER:
962979
*param_length_out +=
963980
sizeof(sdc_hci_cmd_le_read_adv_physical_channel_tx_power_return_t);
964981
return sdc_hci_cmd_le_read_adv_physical_channel_tx_power((void *)event_out_params);
982+
#endif
965983

966984
case SDC_HCI_OPCODE_CMD_LE_SET_ADV_DATA:
967985
return sdc_hci_cmd_le_set_adv_data((void *)cmd_params);
@@ -995,9 +1013,11 @@ static uint8_t le_controller_cmd_put(uint8_t const * const cmd,
9951013
#endif
9961014

9971015
#if defined(CONFIG_BT_CTLR_FILTER_ACCEPT_LIST)
1016+
#if !defined(CONFIG_BT_HCI_HOST)
9981017
case SDC_HCI_OPCODE_CMD_LE_READ_FILTER_ACCEPT_LIST_SIZE:
9991018
*param_length_out += sizeof(sdc_hci_cmd_le_read_filter_accept_list_size_return_t);
10001019
return sdc_hci_cmd_le_read_filter_accept_list_size((void *)event_out_params);
1020+
#endif
10011021

10021022
case SDC_HCI_OPCODE_CMD_LE_CLEAR_FILTER_ACCEPT_LIST:
10031023
return sdc_hci_cmd_le_clear_filter_accept_list();
@@ -1020,10 +1040,12 @@ static uint8_t le_controller_cmd_put(uint8_t const * const cmd,
10201040
#endif
10211041

10221042
#if defined(CONFIG_BT_CONN)
1043+
#if !defined(CONFIG_BT_HCI_HOST)
10231044
case SDC_HCI_OPCODE_CMD_LE_READ_CHANNEL_MAP:
10241045
*param_length_out += sizeof(sdc_hci_cmd_le_read_channel_map_return_t);
10251046
return sdc_hci_cmd_le_read_channel_map((void *)cmd_params,
10261047
(void *)event_out_params);
1048+
#endif
10271049

10281050
case SDC_HCI_OPCODE_CMD_LE_READ_REMOTE_FEATURES:
10291051
return sdc_hci_cmd_le_read_remote_features((void *)cmd_params);
@@ -1070,10 +1092,12 @@ static uint8_t le_controller_cmd_put(uint8_t const * const cmd,
10701092
*param_length_out += sizeof(sdc_hci_cmd_le_set_data_length_return_t);
10711093
return sdc_hci_cmd_le_set_data_length((void *)cmd_params, (void *)event_out_params);
10721094

1095+
#if !defined(CONFIG_BT_HCI_HOST)
10731096
case SDC_HCI_OPCODE_CMD_LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH:
10741097
*param_length_out +=
10751098
sizeof(sdc_hci_cmd_le_read_suggested_default_data_length_return_t);
10761099
return sdc_hci_cmd_le_read_suggested_default_data_length((void *)event_out_params);
1100+
#endif
10771101

10781102
case SDC_HCI_OPCODE_CMD_LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH:
10791103
return sdc_hci_cmd_le_write_suggested_default_data_length((void *)cmd_params);
@@ -1147,16 +1171,20 @@ static uint8_t le_controller_cmd_put(uint8_t const * const cmd,
11471171
*param_length_out += sizeof(sdc_hci_cmd_le_read_max_adv_data_length_return_t);
11481172
return sdc_hci_cmd_le_read_max_adv_data_length((void *)event_out_params);
11491173

1174+
#if !defined(CONFIG_BT_HCI_HOST)
11501175
case SDC_HCI_OPCODE_CMD_LE_READ_NUMBER_OF_SUPPORTED_ADV_SETS:
11511176
*param_length_out +=
11521177
sizeof(sdc_hci_cmd_le_read_number_of_supported_adv_sets_return_t);
11531178
return sdc_hci_cmd_le_read_number_of_supported_adv_sets((void *)event_out_params);
1179+
#endif
11541180

11551181
case SDC_HCI_OPCODE_CMD_LE_REMOVE_ADV_SET:
11561182
return sdc_hci_cmd_le_remove_adv_set((void *)cmd_params);
11571183

1184+
#if !defined(CONFIG_BT_HCI_HOST)
11581185
case SDC_HCI_OPCODE_CMD_LE_CLEAR_ADV_SETS:
11591186
return sdc_hci_cmd_le_clear_adv_sets();
1187+
#endif /* !defined(CONFIG_BT_HCI_HOST) */
11601188

11611189
#if defined(CONFIG_BT_PER_ADV)
11621190
case SDC_HCI_OPCODE_CMD_LE_SET_PERIODIC_ADV_PARAMS:
@@ -1203,10 +1231,12 @@ static uint8_t le_controller_cmd_put(uint8_t const * const cmd,
12031231
case SDC_HCI_OPCODE_CMD_LE_CLEAR_PERIODIC_ADV_LIST:
12041232
return sdc_hci_cmd_le_clear_periodic_adv_list();
12051233

1234+
#if !defined(CONFIG_BT_HCI_HOST)
12061235
case SDC_HCI_OPCODE_CMD_LE_READ_PERIODIC_ADV_LIST_SIZE:
12071236
*param_length_out +=
12081237
sizeof(sdc_hci_cmd_le_read_periodic_adv_list_size_return_t);
12091238
return sdc_hci_cmd_le_read_periodic_adv_list_size((void *)event_out_params);
1239+
#endif /* !defined(CONFIG_BT_HCI_HOST) */
12101240
#endif /* CONFIG_BT_PER_ADV_SYNC */
12111241
#endif /* CONFIG_BT_CTLR_ADV_EXT */
12121242

@@ -1475,10 +1505,12 @@ static uint8_t le_controller_cmd_put(uint8_t const * const cmd,
14751505
case SDC_HCI_OPCODE_CMD_LE_SET_HOST_FEATURE:
14761506
return sdc_hci_cmd_le_set_host_feature(
14771507
(sdc_hci_cmd_le_set_host_feature_t const *)cmd_params);
1508+
#if !defined(CONFIG_BT_HCI_HOST)
14781509
case SDC_HCI_OPCODE_CMD_LE_SET_HOST_FEATURE_V2:
14791510
return sdc_hci_cmd_le_set_host_feature_v2(
14801511
(sdc_hci_cmd_le_set_host_feature_v2_t const *)cmd_params);
14811512
#endif
1513+
#endif
14821514

14831515
#if defined(CONFIG_BT_CTLR_SDC_PAWR_ADV)
14841516
case SDC_HCI_OPCODE_CMD_LE_EXT_CREATE_CONN_V2:

0 commit comments

Comments
 (0)