mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-19 16:21:06 +00:00
add gap_scan_response_set_data
This commit is contained in:
parent
645e25ac83
commit
501f56b360
12
src/gap.h
12
src/gap.h
@ -246,6 +246,18 @@ void gap_advertisements_set_params(uint16_t adv_int_min, uint16_t adv_int_max, u
|
|||||||
* @param enabled
|
* @param enabled
|
||||||
*/
|
*/
|
||||||
void gap_advertisements_enable(int enabled);
|
void gap_advertisements_enable(int enabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set Scan Response Data
|
||||||
|
*
|
||||||
|
* @note For scan response data, scannable undirected advertising (ADV_SCAN_IND) need to be used
|
||||||
|
*
|
||||||
|
* @param advertising_data_length
|
||||||
|
* @param advertising_data (max 31 octets)
|
||||||
|
* @note data is not copied, pointer has to stay valid
|
||||||
|
*/
|
||||||
|
void gap_scan_response_set_data(uint8_t scan_response_data_length, uint8_t * scan_response_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Request an update of the connection parameter for a given LE connection
|
* @brief Request an update of the connection parameter for a given LE connection
|
||||||
* @param handle
|
* @param handle
|
||||||
|
45
src/hci.c
45
src/hci.c
@ -2361,12 +2361,18 @@ static void hci_run(void){
|
|||||||
hci_stack->le_advertisements_filter_policy);
|
hci_stack->le_advertisements_filter_policy);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hci_stack->le_advertisements_todo & LE_ADVERTISEMENT_TASKS_SET_DATA){
|
if (hci_stack->le_advertisements_todo & LE_ADVERTISEMENT_TASKS_SET_ADV_DATA){
|
||||||
hci_stack->le_advertisements_todo &= ~LE_ADVERTISEMENT_TASKS_SET_DATA;
|
hci_stack->le_advertisements_todo &= ~LE_ADVERTISEMENT_TASKS_SET_ADV_DATA;
|
||||||
hci_send_cmd(&hci_le_set_advertising_data, hci_stack->le_advertisements_data_len,
|
hci_send_cmd(&hci_le_set_advertising_data, hci_stack->le_advertisements_data_len,
|
||||||
hci_stack->le_advertisements_data);
|
hci_stack->le_advertisements_data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (hci_stack->le_advertisements_todo & LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA){
|
||||||
|
hci_stack->le_advertisements_todo &= ~LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA;
|
||||||
|
hci_send_cmd(&hci_le_set_scan_response_data, hci_stack->le_scan_response_data_len,
|
||||||
|
hci_stack->le_scan_response_data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (hci_stack->le_advertisements_todo & LE_ADVERTISEMENT_TASKS_ENABLE){
|
if (hci_stack->le_advertisements_todo & LE_ADVERTISEMENT_TASKS_ENABLE){
|
||||||
hci_stack->le_advertisements_todo &= ~LE_ADVERTISEMENT_TASKS_ENABLE;
|
hci_stack->le_advertisements_todo &= ~LE_ADVERTISEMENT_TASKS_ENABLE;
|
||||||
hci_send_cmd(&hci_le_set_advertise_enable, 1);
|
hci_send_cmd(&hci_le_set_advertise_enable, 1);
|
||||||
@ -3328,6 +3334,14 @@ int gap_request_connection_parameter_update(hci_con_handle_t con_handle, uint16_
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gap_advertisments_changed(void){
|
||||||
|
// disable advertisements before updating adv, scan data, or adv params
|
||||||
|
if (hci_stack->le_advertisements_active){
|
||||||
|
hci_stack->le_advertisements_todo |= LE_ADVERTISEMENT_TASKS_DISABLE | LE_ADVERTISEMENT_TASKS_ENABLE;
|
||||||
|
}
|
||||||
|
hci_run();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set Advertisement Data
|
* @brief Set Advertisement Data
|
||||||
* @param advertising_data_length
|
* @param advertising_data_length
|
||||||
@ -3337,12 +3351,21 @@ int gap_request_connection_parameter_update(hci_con_handle_t con_handle, uint16_
|
|||||||
void gap_advertisements_set_data(uint8_t advertising_data_length, uint8_t * advertising_data){
|
void gap_advertisements_set_data(uint8_t advertising_data_length, uint8_t * advertising_data){
|
||||||
hci_stack->le_advertisements_data_len = advertising_data_length;
|
hci_stack->le_advertisements_data_len = advertising_data_length;
|
||||||
hci_stack->le_advertisements_data = advertising_data;
|
hci_stack->le_advertisements_data = advertising_data;
|
||||||
hci_stack->le_advertisements_todo |= LE_ADVERTISEMENT_TASKS_SET_DATA;
|
hci_stack->le_advertisements_todo |= LE_ADVERTISEMENT_TASKS_SET_ADV_DATA;
|
||||||
// disable advertisements before setting data
|
gap_advertisments_changed();
|
||||||
if (hci_stack->le_advertisements_active){
|
}
|
||||||
hci_stack->le_advertisements_todo |= LE_ADVERTISEMENT_TASKS_DISABLE | LE_ADVERTISEMENT_TASKS_ENABLE;
|
|
||||||
}
|
/**
|
||||||
hci_run();
|
* @brief Set Scan Response Data
|
||||||
|
* @param advertising_data_length
|
||||||
|
* @param advertising_data (max 31 octets)
|
||||||
|
* @note data is not copied, pointer has to stay valid
|
||||||
|
*/
|
||||||
|
void gap_scan_response_set_data(uint8_t scan_response_data_length, uint8_t * scan_response_data){
|
||||||
|
hci_stack->le_scan_response_data_len = scan_response_data_length;
|
||||||
|
hci_stack->le_scan_response_data = scan_response_data;
|
||||||
|
hci_stack->le_advertisements_todo |= LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA;
|
||||||
|
gap_advertisments_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3372,11 +3395,7 @@ void gap_advertisements_set_data(uint8_t advertising_data_length, uint8_t * adve
|
|||||||
memcpy(hci_stack->le_advertisements_direct_address, direct_address, 6);
|
memcpy(hci_stack->le_advertisements_direct_address, direct_address, 6);
|
||||||
|
|
||||||
hci_stack->le_advertisements_todo |= LE_ADVERTISEMENT_TASKS_SET_PARAMS;
|
hci_stack->le_advertisements_todo |= LE_ADVERTISEMENT_TASKS_SET_PARAMS;
|
||||||
// disable advertisements before changing params
|
gap_advertisments_changed();
|
||||||
if (hci_stack->le_advertisements_active){
|
|
||||||
hci_stack->le_advertisements_todo |= LE_ADVERTISEMENT_TASKS_DISABLE | LE_ADVERTISEMENT_TASKS_ENABLE;
|
|
||||||
}
|
|
||||||
hci_run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
12
src/hci.h
12
src/hci.h
@ -497,10 +497,11 @@ typedef enum hci_init_state{
|
|||||||
} hci_substate_t;
|
} hci_substate_t;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
LE_ADVERTISEMENT_TASKS_DISABLE = 1 << 0,
|
LE_ADVERTISEMENT_TASKS_DISABLE = 1 << 0,
|
||||||
LE_ADVERTISEMENT_TASKS_SET_DATA = 1 << 1,
|
LE_ADVERTISEMENT_TASKS_SET_ADV_DATA = 1 << 1,
|
||||||
LE_ADVERTISEMENT_TASKS_SET_PARAMS = 1 << 2,
|
LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA = 1 << 2,
|
||||||
LE_ADVERTISEMENT_TASKS_ENABLE = 1 << 3,
|
LE_ADVERTISEMENT_TASKS_SET_PARAMS = 1 << 3,
|
||||||
|
LE_ADVERTISEMENT_TASKS_ENABLE = 1 << 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -633,6 +634,9 @@ typedef struct {
|
|||||||
uint8_t * le_advertisements_data;
|
uint8_t * le_advertisements_data;
|
||||||
uint8_t le_advertisements_data_len;
|
uint8_t le_advertisements_data_len;
|
||||||
|
|
||||||
|
uint8_t * le_scan_response_data;
|
||||||
|
uint8_t le_scan_response_data_len;
|
||||||
|
|
||||||
uint8_t le_advertisements_active;
|
uint8_t le_advertisements_active;
|
||||||
uint8_t le_advertisements_enabled;
|
uint8_t le_advertisements_enabled;
|
||||||
uint8_t le_advertisements_todo;
|
uint8_t le_advertisements_todo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user