Commit e025dce2 authored by David Lechner's avatar David Lechner

drv/bluetooth_btstack: only set AD params once when broadcasting

When broadcasting, the advertising parameters dont' change, so we only
need to set them once when we start broadcasting. This is done by
moving the code inside the if statement along with the enable function.
parent c2bb78d7
...@@ -748,9 +748,6 @@ static PT_THREAD(start_broadcasting_task(struct pt *pt, pbio_task_t *task)) { ...@@ -748,9 +748,6 @@ static PT_THREAD(start_broadcasting_task(struct pt *pt, pbio_task_t *task)) {
PT_EXIT(pt); PT_EXIT(pt);
} }
bd_addr_t null_addr = { };
gap_advertisements_set_params(0xA0, 0xA0, ADV_NONCONN_IND, 0, null_addr, 0x7, 0);
// have to keep copy of data here since BTStack doesn't copy // have to keep copy of data here since BTStack doesn't copy
static uint8_t static_data[LE_ADVERTISING_DATA_SIZE]; static uint8_t static_data[LE_ADVERTISING_DATA_SIZE];
memcpy(static_data, value->data, value->size); memcpy(static_data, value->data, value->size);
...@@ -758,6 +755,8 @@ static PT_THREAD(start_broadcasting_task(struct pt *pt, pbio_task_t *task)) { ...@@ -758,6 +755,8 @@ static PT_THREAD(start_broadcasting_task(struct pt *pt, pbio_task_t *task)) {
gap_advertisements_set_data(value->size, static_data); gap_advertisements_set_data(value->size, static_data);
if (!is_broadcasting) { if (!is_broadcasting) {
bd_addr_t null_addr = { };
gap_advertisements_set_params(0xA0, 0xA0, ADV_NONCONN_IND, 0, null_addr, 0x7, 0);
gap_advertisements_enable(true); gap_advertisements_enable(true);
is_broadcasting = true; is_broadcasting = true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment