Skip to content

Commit

Permalink
drv/bluetooth_stm32_cc2640: remove #if for ADV_INT in broadcast
Browse files Browse the repository at this point in the history
This was missed in 416a29e. Since Technic hub also uses ADV_IND
sometimes now, it will be easiest to just always change the
advertising interval when broadcasting.
  • Loading branch information
dlech committed Jun 6, 2023
1 parent fa13e6c commit 3317369
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions lib/pbio/drv/bluetooth/bluetooth_stm32_cc2640.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,9 +840,20 @@ static PT_THREAD(broadcast_task(struct pt *pt, pbio_task_t *task)) {
PT_WAIT_UNTIL(pt, hci_command_complete);

if (!is_broadcasting) {
#if PBDRV_CONFIG_BLUETOOTH_STM32_CC2640_QUIRK_BROKEN_NONCONN_IND
// On city hub, since we have to use connectable advertisement, we
// Since we have to sometimes use connectable advertisement, we
// set the advertising interval to 100ms to match other platforms.
// We have to do this for both general discoverable and connectable
// depending on if the hub is connected to another device or not.

PT_WAIT_WHILE(pt, write_xfer_size);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN, 0xA0);
PT_WAIT_UNTIL(pt, hci_command_status);
// ignoring response data

PT_WAIT_WHILE(pt, write_xfer_size);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX, 0xA0);
PT_WAIT_UNTIL(pt, hci_command_status);
// ignoring response data

PT_WAIT_WHILE(pt, write_xfer_size);
GAP_SetParamValue(TGAP_CONN_ADV_INT_MIN, 0xA0);
Expand All @@ -854,8 +865,6 @@ static PT_THREAD(broadcast_task(struct pt *pt, pbio_task_t *task)) {
PT_WAIT_UNTIL(pt, hci_command_status);
// ignoring response data

#endif // PBDRV_CONFIG_BLUETOOTH_STM32_CC2640_QUIRK_BROKEN_NONCONN_IND

PT_WAIT_WHILE(pt, write_xfer_size);
GAP_makeDiscoverable(
#if PBDRV_CONFIG_BLUETOOTH_STM32_CC2640_QUIRK_BROKEN_NONCONN_IND
Expand Down Expand Up @@ -910,9 +919,18 @@ static PT_THREAD(stop_broadcast_task(struct pt *pt, pbio_task_t *task)) {
// Status could also be bleIncorrectMode which means "Not advertising".
// This is not expected, but should be safe to ignore.

#if PBDRV_CONFIG_BLUETOOTH_STM32_CC2640_QUIRK_BROKEN_NONCONN_IND
// Restore advertising interval from gap_init().

PT_WAIT_WHILE(pt, write_xfer_size);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN, 40);
PT_WAIT_UNTIL(pt, hci_command_status);
// ignoring response data

PT_WAIT_WHILE(pt, write_xfer_size);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX, 40);
PT_WAIT_UNTIL(pt, hci_command_status);
// ignoring response data

PT_WAIT_WHILE(pt, write_xfer_size);
GAP_SetParamValue(TGAP_CONN_ADV_INT_MIN, 40);
PT_WAIT_UNTIL(pt, hci_command_status);
Expand All @@ -923,8 +941,6 @@ static PT_THREAD(stop_broadcast_task(struct pt *pt, pbio_task_t *task)) {
PT_WAIT_UNTIL(pt, hci_command_status);
// ignoring response data

#endif // PBDRV_CONFIG_BLUETOOTH_STM32_CC2640_QUIRK_BROKEN_NONCONN_IND

is_broadcasting = false;
}

Expand Down

0 comments on commit 3317369

Please sign in to comment.