hci.c (de9f0299a489091c72fcfd2beea7fde1644d3387) | hci.c (c814a90472228b1be4a26c08c00bb28ad853a46a) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 4396 unchanged lines hidden (view full) --- 4405#ifdef ENABLE_BLE 4406#ifdef ENABLE_LE_PERIPHERAL 4407 if (!hci_can_send_command_packet_now()) return; 4408 4409 stop_advertismenets = (hci_stack->le_advertisements_state & LE_ADVERTISEMENT_STATE_ACTIVE) != 0; 4410 4411#ifdef ENABLE_LE_EXTENDED_ADVERTISING 4412 if (hci_extended_advertising_supported()){ | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 4396 unchanged lines hidden (view full) --- 4405#ifdef ENABLE_BLE 4406#ifdef ENABLE_LE_PERIPHERAL 4407 if (!hci_can_send_command_packet_now()) return; 4408 4409 stop_advertismenets = (hci_stack->le_advertisements_state & LE_ADVERTISEMENT_STATE_ACTIVE) != 0; 4410 4411#ifdef ENABLE_LE_EXTENDED_ADVERTISING 4412 if (hci_extended_advertising_supported()){ |
4413#ifdef ENABLE_LE_PERIODIC_ADVERTISING |
|
4413 btstack_linked_list_iterator_t it; 4414 btstack_linked_list_iterator_init(&it, &hci_stack->le_advertising_sets); 4415 // stop all periodic advertisements and check if an extended set is active 4416 while (btstack_linked_list_iterator_has_next(&it)){ 4417 le_advertising_set_t * advertising_set = (le_advertising_set_t*) btstack_linked_list_iterator_next(&it); 4418 if ((advertising_set->state & LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE) != 0) { 4419 advertising_set->state &= ~LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE; 4420 hci_send_cmd(&hci_le_set_periodic_advertising_enable, 0, advertising_set->advertising_handle); 4421 return; 4422 } 4423 if ((advertising_set->state & LE_ADVERTISEMENT_STATE_ACTIVE) != 0) { 4424 stop_advertismenets = true; 4425 advertising_set->state &= ~LE_ADVERTISEMENT_STATE_ACTIVE; 4426 } 4427 } | 4414 btstack_linked_list_iterator_t it; 4415 btstack_linked_list_iterator_init(&it, &hci_stack->le_advertising_sets); 4416 // stop all periodic advertisements and check if an extended set is active 4417 while (btstack_linked_list_iterator_has_next(&it)){ 4418 le_advertising_set_t * advertising_set = (le_advertising_set_t*) btstack_linked_list_iterator_next(&it); 4419 if ((advertising_set->state & LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE) != 0) { 4420 advertising_set->state &= ~LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE; 4421 hci_send_cmd(&hci_le_set_periodic_advertising_enable, 0, advertising_set->advertising_handle); 4422 return; 4423 } 4424 if ((advertising_set->state & LE_ADVERTISEMENT_STATE_ACTIVE) != 0) { 4425 stop_advertismenets = true; 4426 advertising_set->state &= ~LE_ADVERTISEMENT_STATE_ACTIVE; 4427 } 4428 } |
4429#endif /* ENABLE_LE_PERIODIC_ADVERTISING */ |
|
4428 if (stop_advertismenets){ 4429 hci_stack->le_advertisements_state &= ~LE_ADVERTISEMENT_STATE_ACTIVE; 4430 hci_send_cmd(&hci_le_set_extended_advertising_enable, 0, 0, NULL, NULL, NULL); 4431 return; 4432 } 4433 } 4434 else 4435#else --- 397 unchanged lines hidden (view full) --- 4833 // Phase 1: collect what to stop 4834 4835 bool scanning_stop = false; 4836 bool connecting_stop = false; 4837 bool advertising_stop = false; 4838 4839#ifdef ENABLE_LE_EXTENDED_ADVERTISING 4840 le_advertising_set_t * advertising_stop_set = NULL; | 4430 if (stop_advertismenets){ 4431 hci_stack->le_advertisements_state &= ~LE_ADVERTISEMENT_STATE_ACTIVE; 4432 hci_send_cmd(&hci_le_set_extended_advertising_enable, 0, 0, NULL, NULL, NULL); 4433 return; 4434 } 4435 } 4436 else 4437#else --- 397 unchanged lines hidden (view full) --- 4835 // Phase 1: collect what to stop 4836 4837 bool scanning_stop = false; 4838 bool connecting_stop = false; 4839 bool advertising_stop = false; 4840 4841#ifdef ENABLE_LE_EXTENDED_ADVERTISING 4842 le_advertising_set_t * advertising_stop_set = NULL; |
4843#ifdef ENABLE_LE_PERIODIC_ADVERTISING |
|
4841 bool periodic_stop = false; 4842#endif | 4844 bool periodic_stop = false; 4845#endif |
4846#endif |
|
4843 4844#ifndef ENABLE_LE_CENTRAL 4845 UNUSED(scanning_stop); 4846 UNUSED(connecting_stop); 4847#endif 4848#ifndef ENABLE_LE_PERIPHERAL 4849 UNUSED(advertising_stop); 4850#endif --- 125 unchanged lines hidden (view full) --- 4976 resolving_list_modification_pending || 4977 advertising_set_will_be_removed) { 4978 4979 advertising_stop = true; 4980 advertising_stop_set = advertising_set; 4981 break; 4982 } 4983 } | 4847 4848#ifndef ENABLE_LE_CENTRAL 4849 UNUSED(scanning_stop); 4850 UNUSED(connecting_stop); 4851#endif 4852#ifndef ENABLE_LE_PERIPHERAL 4853 UNUSED(advertising_stop); 4854#endif --- 125 unchanged lines hidden (view full) --- 4980 resolving_list_modification_pending || 4981 advertising_set_will_be_removed) { 4982 4983 advertising_stop = true; 4984 advertising_stop_set = advertising_set; 4985 break; 4986 } 4987 } |
4988#ifdef ENABLE_LE_PERIODIC_ADVERTISING |
|
4984 if ((advertising_set->state & LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE) != 0) { 4985 // stop if: 4986 // - it's disabled 4987 // - parameter change required 4988 bool periodic_enabled = (advertising_set->state & LE_ADVERTISEMENT_STATE_PERIODIC_ENABLED) != 0; 4989 bool periodic_parameter_change = (advertising_set->tasks & LE_ADVERTISEMENT_TASKS_SET_PERIODIC_PARAMS) != 0; 4990 if ((periodic_enabled == false) || periodic_parameter_change){ 4991 periodic_stop = true; 4992 advertising_stop_set = advertising_set; 4993 } 4994 } | 4989 if ((advertising_set->state & LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE) != 0) { 4990 // stop if: 4991 // - it's disabled 4992 // - parameter change required 4993 bool periodic_enabled = (advertising_set->state & LE_ADVERTISEMENT_STATE_PERIODIC_ENABLED) != 0; 4994 bool periodic_parameter_change = (advertising_set->tasks & LE_ADVERTISEMENT_TASKS_SET_PERIODIC_PARAMS) != 0; 4995 if ((periodic_enabled == false) || periodic_parameter_change){ 4996 periodic_stop = true; 4997 advertising_stop_set = advertising_set; 4998 } 4999 } |
5000#endif |
|
4995 } 4996 } 4997#endif 4998 4999#endif 5000 5001 5002 // Phase 2: stop everything that should be off during modifications --- 33 unchanged lines hidden (view full) --- 5036#endif 5037 { 5038 hci_stack->le_advertisements_state &= ~LE_ADVERTISEMENT_STATE_ACTIVE; 5039 hci_send_cmd(&hci_le_set_advertise_enable, 0); 5040 } 5041 return true; 5042 } 5043#ifdef ENABLE_LE_EXTENDED_ADVERTISING | 5001 } 5002 } 5003#endif 5004 5005#endif 5006 5007 5008 // Phase 2: stop everything that should be off during modifications --- 33 unchanged lines hidden (view full) --- 5042#endif 5043 { 5044 hci_stack->le_advertisements_state &= ~LE_ADVERTISEMENT_STATE_ACTIVE; 5045 hci_send_cmd(&hci_le_set_advertise_enable, 0); 5046 } 5047 return true; 5048 } 5049#ifdef ENABLE_LE_EXTENDED_ADVERTISING |
5050#ifdef ENABLE_LE_PERIODIC_ADVERTISING |
|
5044 if (periodic_stop){ 5045 advertising_stop_set->state &= ~LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE; 5046 hci_send_cmd(&hci_le_set_periodic_advertising_enable, 0, advertising_stop_set->advertising_handle); 5047 return true; 5048 } | 5051 if (periodic_stop){ 5052 advertising_stop_set->state &= ~LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE; 5053 hci_send_cmd(&hci_le_set_periodic_advertising_enable, 0, advertising_stop_set->advertising_handle); 5054 return true; 5055 } |
5056#endif /* ENABLE_LE_PERIODIC_ADVERTISING */ 5057#endif /* ENABLE_LE_EXTENDED_ADVERTISING */ |
|
5049#endif | 5058#endif |
5050#endif | |
5051 5052 // Phase 3: modify 5053 5054 if (random_address_change){ 5055 hci_stack->le_advertisements_todo &= ~LE_ADVERTISEMENT_TASKS_SET_ADDRESS; 5056#ifdef ENABLE_LE_EXTENDED_ADVERTISING 5057 if (hci_extended_advertising_supported()) { 5058 hci_send_cmd(&hci_le_set_advertising_set_random_address, 0, hci_stack->le_random_address); --- 175 unchanged lines hidden (view full) --- 5234 advertising_set->tasks &= ~LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA; 5235 } else { 5236 advertising_set->scan_data_pos += data_to_upload; 5237 } 5238 hci_stack->le_advertising_set_in_current_command = advertising_set->advertising_handle; 5239 hci_send_cmd(&hci_le_set_extended_scan_response_data, operation, 0x03, 0x01, data_to_upload, &advertising_set->scan_data[pos]); 5240 return true; 5241 } | 5059 5060 // Phase 3: modify 5061 5062 if (random_address_change){ 5063 hci_stack->le_advertisements_todo &= ~LE_ADVERTISEMENT_TASKS_SET_ADDRESS; 5064#ifdef ENABLE_LE_EXTENDED_ADVERTISING 5065 if (hci_extended_advertising_supported()) { 5066 hci_send_cmd(&hci_le_set_advertising_set_random_address, 0, hci_stack->le_random_address); --- 175 unchanged lines hidden (view full) --- 5242 advertising_set->tasks &= ~LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA; 5243 } else { 5244 advertising_set->scan_data_pos += data_to_upload; 5245 } 5246 hci_stack->le_advertising_set_in_current_command = advertising_set->advertising_handle; 5247 hci_send_cmd(&hci_le_set_extended_scan_response_data, operation, 0x03, 0x01, data_to_upload, &advertising_set->scan_data[pos]); 5248 return true; 5249 } |
5250#ifdef ENABLE_LE_PERIODIC_ADVERTISING |
|
5242 if ((advertising_set->tasks & LE_ADVERTISEMENT_TASKS_SET_PERIODIC_PARAMS) != 0){ 5243 advertising_set->tasks &= ~LE_ADVERTISEMENT_TASKS_SET_PERIODIC_PARAMS; 5244 hci_stack->le_advertising_set_in_current_command = advertising_set->advertising_handle; 5245 hci_send_cmd(&hci_le_set_periodic_advertising_parameters, 5246 advertising_set->advertising_handle, 5247 advertising_set->periodic_params.periodic_advertising_interval_min, 5248 advertising_set->periodic_params.periodic_advertising_interval_max, 5249 advertising_set->periodic_params.periodic_advertising_properties); --- 10 unchanged lines hidden (view full) --- 5260 advertising_set->tasks &= ~LE_ADVERTISEMENT_TASKS_SET_PERIODIC_DATA; 5261 } else { 5262 advertising_set->periodic_data_pos += data_to_upload; 5263 } 5264 hci_stack->le_advertising_set_in_current_command = advertising_set->advertising_handle; 5265 hci_send_cmd(&hci_le_set_periodic_advertising_data, advertising_set->advertising_handle, operation, data_to_upload, &advertising_set->periodic_data[pos]); 5266 return true; 5267 } | 5251 if ((advertising_set->tasks & LE_ADVERTISEMENT_TASKS_SET_PERIODIC_PARAMS) != 0){ 5252 advertising_set->tasks &= ~LE_ADVERTISEMENT_TASKS_SET_PERIODIC_PARAMS; 5253 hci_stack->le_advertising_set_in_current_command = advertising_set->advertising_handle; 5254 hci_send_cmd(&hci_le_set_periodic_advertising_parameters, 5255 advertising_set->advertising_handle, 5256 advertising_set->periodic_params.periodic_advertising_interval_min, 5257 advertising_set->periodic_params.periodic_advertising_interval_max, 5258 advertising_set->periodic_params.periodic_advertising_properties); --- 10 unchanged lines hidden (view full) --- 5269 advertising_set->tasks &= ~LE_ADVERTISEMENT_TASKS_SET_PERIODIC_DATA; 5270 } else { 5271 advertising_set->periodic_data_pos += data_to_upload; 5272 } 5273 hci_stack->le_advertising_set_in_current_command = advertising_set->advertising_handle; 5274 hci_send_cmd(&hci_le_set_periodic_advertising_data, advertising_set->advertising_handle, operation, data_to_upload, &advertising_set->periodic_data[pos]); 5275 return true; 5276 } |
5277#endif /* ENABLE_LE_PERIODIC_ADVERTISING */ |
|
5268 } 5269 } 5270#endif 5271 5272 5273#endif 5274 5275 --- 190 unchanged lines hidden (view full) --- 5466 if (((advertising_set->state & LE_ADVERTISEMENT_STATE_ENABLED) != 0) && ((advertising_set->state & LE_ADVERTISEMENT_STATE_ACTIVE) == 0)){ 5467 advertising_set->state |= LE_ADVERTISEMENT_STATE_ACTIVE; 5468 const uint8_t advertising_handles[] = { advertising_set->advertising_handle }; 5469 const uint16_t durations[] = { advertising_set->enable_timeout }; 5470 const uint16_t max_events[] = { advertising_set->enable_max_scan_events }; 5471 hci_send_cmd(&hci_le_set_extended_advertising_enable, 1, 1, advertising_handles, durations, max_events); 5472 return true; 5473 } | 5278 } 5279 } 5280#endif 5281 5282 5283#endif 5284 5285 --- 190 unchanged lines hidden (view full) --- 5476 if (((advertising_set->state & LE_ADVERTISEMENT_STATE_ENABLED) != 0) && ((advertising_set->state & LE_ADVERTISEMENT_STATE_ACTIVE) == 0)){ 5477 advertising_set->state |= LE_ADVERTISEMENT_STATE_ACTIVE; 5478 const uint8_t advertising_handles[] = { advertising_set->advertising_handle }; 5479 const uint16_t durations[] = { advertising_set->enable_timeout }; 5480 const uint16_t max_events[] = { advertising_set->enable_max_scan_events }; 5481 hci_send_cmd(&hci_le_set_extended_advertising_enable, 1, 1, advertising_handles, durations, max_events); 5482 return true; 5483 } |
5484#ifdef ENABLE_LE_PERIODIC_ADVERTISING |
|
5474 if (((advertising_set->state & LE_ADVERTISEMENT_STATE_PERIODIC_ENABLED) != 0) && ((advertising_set->state & LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE) == 0)){ 5475 advertising_set->state |= LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE; 5476 uint8_t enable = 1; 5477 if (advertising_set->periodic_include_adi){ 5478 enable |= 2; 5479 } 5480 hci_send_cmd(&hci_le_set_periodic_advertising_enable, enable, advertising_set->advertising_handle); 5481 return true; 5482 } | 5485 if (((advertising_set->state & LE_ADVERTISEMENT_STATE_PERIODIC_ENABLED) != 0) && ((advertising_set->state & LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE) == 0)){ 5486 advertising_set->state |= LE_ADVERTISEMENT_STATE_PERIODIC_ACTIVE; 5487 uint8_t enable = 1; 5488 if (advertising_set->periodic_include_adi){ 5489 enable |= 2; 5490 } 5491 hci_send_cmd(&hci_le_set_periodic_advertising_enable, enable, advertising_set->advertising_handle); 5492 return true; 5493 } |
5494#endif /* ENABLE_LE_PERIODIC_ADVERTISING */ |
|
5483 } 5484 } 5485#endif 5486#endif 5487 5488 return false; 5489} 5490#endif --- 1420 unchanged lines hidden (view full) --- 6911 6912uint8_t gap_extended_advertising_get_params(uint8_t advertising_handle, le_extended_advertising_parameters_t * advertising_parameters){ 6913 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6914 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6915 memcpy(advertising_parameters, &advertising_set->extended_params, sizeof(le_extended_advertising_parameters_t)); 6916 return ERROR_CODE_SUCCESS; 6917} 6918 | 5495 } 5496 } 5497#endif 5498#endif 5499 5500 return false; 5501} 5502#endif --- 1420 unchanged lines hidden (view full) --- 6923 6924uint8_t gap_extended_advertising_get_params(uint8_t advertising_handle, le_extended_advertising_parameters_t * advertising_parameters){ 6925 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6926 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6927 memcpy(advertising_parameters, &advertising_set->extended_params, sizeof(le_extended_advertising_parameters_t)); 6928 return ERROR_CODE_SUCCESS; 6929} 6930 |
6919uint8_t gap_periodic_advertising_set_params(uint8_t advertising_handle, const le_periodic_advertising_parameters_t * advertising_parameters){ 6920 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6921 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6922 // periodic advertising requires neither connectable, scannable, legacy or anonymous 6923 if ((advertising_set->extended_params.advertising_event_properties & 0x1f) != 0) return ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS; 6924 memcpy(&advertising_set->periodic_params, advertising_parameters, sizeof(le_periodic_advertising_parameters_t)); 6925 // set tasks and start 6926 advertising_set->tasks |= LE_ADVERTISEMENT_TASKS_SET_PERIODIC_PARAMS; 6927 hci_run(); 6928 return ERROR_CODE_SUCCESS; 6929} 6930 6931uint8_t gap_periodic_advertising_get_params(uint8_t advertising_handle, le_periodic_advertising_parameters_t * advertising_parameters){ 6932 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6933 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6934 memcpy(advertising_parameters, &advertising_set->extended_params, sizeof(le_periodic_advertising_parameters_t)); 6935 return ERROR_CODE_SUCCESS; 6936} 6937 | |
6938uint8_t gap_extended_advertising_set_random_address(uint8_t advertising_handle, bd_addr_t random_address){ 6939 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6940 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6941 memcpy(advertising_set->random_address, random_address, 6); 6942 // set tasks and start 6943 advertising_set->tasks |= LE_ADVERTISEMENT_TASKS_SET_ADDRESS; 6944 hci_run(); 6945 return ERROR_CODE_SUCCESS; --- 16 unchanged lines hidden (view full) --- 6962 advertising_set->scan_data = scan_response_data; 6963 advertising_set->scan_data_len = scan_response_data_length; 6964 // set tasks and start 6965 advertising_set->tasks |= LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA; 6966 hci_run(); 6967 return ERROR_CODE_SUCCESS; 6968} 6969 | 6931uint8_t gap_extended_advertising_set_random_address(uint8_t advertising_handle, bd_addr_t random_address){ 6932 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6933 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6934 memcpy(advertising_set->random_address, random_address, 6); 6935 // set tasks and start 6936 advertising_set->tasks |= LE_ADVERTISEMENT_TASKS_SET_ADDRESS; 6937 hci_run(); 6938 return ERROR_CODE_SUCCESS; --- 16 unchanged lines hidden (view full) --- 6955 advertising_set->scan_data = scan_response_data; 6956 advertising_set->scan_data_len = scan_response_data_length; 6957 // set tasks and start 6958 advertising_set->tasks |= LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA; 6959 hci_run(); 6960 return ERROR_CODE_SUCCESS; 6961} 6962 |
6970uint8_t gap_periodic_advertising_set_data(uint8_t advertising_handle, uint16_t periodic_data_length, const uint8_t * periodic_data){ | 6963uint8_t gap_extended_advertising_start(uint8_t advertising_handle, uint16_t timeout, uint8_t num_extended_advertising_events){ |
6971 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6972 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; | 6964 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6965 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; |
6973 advertising_set->periodic_data = periodic_data; 6974 advertising_set->periodic_data_len = periodic_data_length; | 6966 advertising_set->enable_timeout = timeout; 6967 advertising_set->enable_max_scan_events = num_extended_advertising_events; |
6975 // set tasks and start | 6968 // set tasks and start |
6976 advertising_set->tasks |= LE_ADVERTISEMENT_TASKS_SET_PERIODIC_DATA; | 6969 advertising_set->state |= LE_ADVERTISEMENT_STATE_ENABLED; |
6977 hci_run(); 6978 return ERROR_CODE_SUCCESS; 6979} 6980 | 6970 hci_run(); 6971 return ERROR_CODE_SUCCESS; 6972} 6973 |
6981uint8_t gap_extended_advertising_start(uint8_t advertising_handle, uint16_t timeout, uint8_t num_extended_advertising_events){ | 6974uint8_t gap_extended_advertising_stop(uint8_t advertising_handle){ |
6982 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6983 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; | 6975 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6976 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; |
6984 advertising_set->enable_timeout = timeout; 6985 advertising_set->enable_max_scan_events = num_extended_advertising_events; | |
6986 // set tasks and start | 6977 // set tasks and start |
6987 advertising_set->state |= LE_ADVERTISEMENT_STATE_ENABLED; | 6978 advertising_set->state &= ~LE_ADVERTISEMENT_STATE_ENABLED; |
6988 hci_run(); 6989 return ERROR_CODE_SUCCESS; 6990} 6991 | 6979 hci_run(); 6980 return ERROR_CODE_SUCCESS; 6981} 6982 |
6992uint8_t gap_extended_advertising_stop(uint8_t advertising_handle){ | 6983uint8_t gap_extended_advertising_remove(uint8_t advertising_handle){ |
6993 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6994 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6995 // set tasks and start | 6984 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6985 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 6986 // set tasks and start |
6996 advertising_set->state &= ~LE_ADVERTISEMENT_STATE_ENABLED; | 6987 advertising_set->tasks |= LE_ADVERTISEMENT_TASKS_REMOVE_SET; |
6997 hci_run(); 6998 return ERROR_CODE_SUCCESS; 6999} 7000 | 6988 hci_run(); 6989 return ERROR_CODE_SUCCESS; 6990} 6991 |
7001uint8_t gap_periodic_advertising_start(uint8_t advertising_handle, bool include_adi){ | 6992#ifdef ENABLE_LE_PERIODIC_ADVERTISING 6993uint8_t gap_periodic_advertising_set_params(uint8_t advertising_handle, const le_periodic_advertising_parameters_t * advertising_parameters){ |
7002 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 7003 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; | 6994 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 6995 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; |
6996 // periodic advertising requires neither connectable, scannable, legacy or anonymous 6997 if ((advertising_set->extended_params.advertising_event_properties & 0x1f) != 0) return ERROR_CODE_INVALID_HCI_COMMAND_PARAMETERS; 6998 memcpy(&advertising_set->periodic_params, advertising_parameters, sizeof(le_periodic_advertising_parameters_t)); |
|
7004 // set tasks and start | 6999 // set tasks and start |
7005 advertising_set->periodic_include_adi = include_adi; 7006 advertising_set->state |= LE_ADVERTISEMENT_STATE_PERIODIC_ENABLED; | 7000 advertising_set->tasks |= LE_ADVERTISEMENT_TASKS_SET_PERIODIC_PARAMS; |
7007 hci_run(); 7008 return ERROR_CODE_SUCCESS; 7009} 7010 | 7001 hci_run(); 7002 return ERROR_CODE_SUCCESS; 7003} 7004 |
7011uint8_t gap_periodic_advertising_stop(uint8_t advertising_handle){ | 7005uint8_t gap_periodic_advertising_get_params(uint8_t advertising_handle, le_periodic_advertising_parameters_t * advertising_parameters){ |
7012 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 7013 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; | 7006 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 7007 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; |
7008 memcpy(advertising_parameters, &advertising_set->extended_params, sizeof(le_periodic_advertising_parameters_t)); 7009 return ERROR_CODE_SUCCESS; 7010} 7011 7012uint8_t gap_periodic_advertising_set_data(uint8_t advertising_handle, uint16_t periodic_data_length, const uint8_t * periodic_data){ 7013 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 7014 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 7015 advertising_set->periodic_data = periodic_data; 7016 advertising_set->periodic_data_len = periodic_data_length; |
|
7014 // set tasks and start | 7017 // set tasks and start |
7015 advertising_set->state &= ~LE_ADVERTISEMENT_STATE_PERIODIC_ENABLED; | 7018 advertising_set->tasks |= LE_ADVERTISEMENT_TASKS_SET_PERIODIC_DATA; |
7016 hci_run(); 7017 return ERROR_CODE_SUCCESS; 7018} 7019 | 7019 hci_run(); 7020 return ERROR_CODE_SUCCESS; 7021} 7022 |
7020uint8_t gap_extended_advertising_remove(uint8_t advertising_handle){ | 7023uint8_t gap_periodic_advertising_start(uint8_t advertising_handle, bool include_adi){ |
7021 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 7022 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 7023 // set tasks and start | 7024 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 7025 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 7026 // set tasks and start |
7024 advertising_set->tasks |= LE_ADVERTISEMENT_TASKS_REMOVE_SET; | 7027 advertising_set->periodic_include_adi = include_adi; 7028 advertising_set->state |= LE_ADVERTISEMENT_STATE_PERIODIC_ENABLED; |
7025 hci_run(); 7026 return ERROR_CODE_SUCCESS; 7027} | 7029 hci_run(); 7030 return ERROR_CODE_SUCCESS; 7031} |
7032 7033uint8_t gap_periodic_advertising_stop(uint8_t advertising_handle){ 7034 le_advertising_set_t * advertising_set = hci_advertising_set_for_handle(advertising_handle); 7035 if (advertising_set == NULL) return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER; 7036 // set tasks and start 7037 advertising_set->state &= ~LE_ADVERTISEMENT_STATE_PERIODIC_ENABLED; 7038 hci_run(); 7039 return ERROR_CODE_SUCCESS; 7040} 7041#endif /* ENABLE_LE_PERIODIC_ADVERTISING */ 7042 |
|
7028#endif 7029 7030#endif 7031 7032void hci_le_set_own_address_type(uint8_t own_address_type){ 7033 log_info("hci_le_set_own_address_type: old %u, new %u", hci_stack->le_own_addr_type, own_address_type); 7034 if (own_address_type == hci_stack->le_own_addr_type) return; 7035 hci_stack->le_own_addr_type = own_address_type; --- 924 unchanged lines hidden --- | 7043#endif 7044 7045#endif 7046 7047void hci_le_set_own_address_type(uint8_t own_address_type){ 7048 log_info("hci_le_set_own_address_type: old %u, new %u", hci_stack->le_own_addr_type, own_address_type); 7049 if (own_address_type == hci_stack->le_own_addr_type) return; 7050 hci_stack->le_own_addr_type = own_address_type; --- 924 unchanged lines hidden --- |