Skip to content
Closed

9.2.x #10459

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions devices/ble_hci/common-hal/_bleio/Adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#define MAX_ADVERTISEMENT_SIZE (31)

// TODO make this settable from Python.
#define DEFAULT_TX_POWER 0 // 0 dBm
#define DEFAULT_TX_POWER -20 // -20 dBm
#define MAX_ANONYMOUS_ADV_TIMEOUT_SECS (60 * 15)
#define MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS (180)

Expand Down Expand Up @@ -802,8 +802,8 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
}
}

if (tx_power != 0) {
mp_raise_NotImplementedError(MP_ERROR_TEXT("Only tx_power=0 supported"));
if (tx_power != -20) {
mp_raise_NotImplementedError(MP_ERROR_TEXT("Only tx_power=-20 supported"));
}

const uint32_t result = _common_hal_bleio_adapter_start_advertising(
Expand Down
2 changes: 1 addition & 1 deletion ports/nordic/common-hal/_bleio/Adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ static bool advertising_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
switch (ble_evt->header.evt_id) {
case BLE_GAP_EVT_CONNECTED: // Connecting also stops an advertisement.
// Set the tx_power for the connection higher than the advertisement.
sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, ble_evt->evt.gap_evt.conn_handle, 0);
sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, ble_evt->evt.gap_evt.conn_handle, -20);
common_hal_bleio_adapter_stop_advertising(self);
return false;
break;
Expand Down
4 changes: 2 additions & 2 deletions shared-bindings/_bleio/Adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ MP_PROPERTY_GETSET(bleio_adapter_name_obj,
//| anonymous: bool = False,
//| timeout: int = 0,
//| interval: float = 0.1,
//| tx_power: int = 0,
//| tx_power: int = -20,
//| directed_to: Optional[Address] = None,
//| ) -> None:
//| """Starts advertising until `stop_advertising` is called or if connectable, another device
Expand Down Expand Up @@ -195,7 +195,7 @@ static mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t
{ MP_QSTR_anonymous, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_interval, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_tx_power, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_tx_power, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -20} },
{ MP_QSTR_directed_to, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
};

Expand Down
Loading