From d21f839dbeb756b49b823fd2732385ba6313eb54 Mon Sep 17 00:00:00 2001 From: PolyPakhomova <155804625+PolyPakhomova@users.noreply.github.com> Date: Mon, 7 Jul 2025 18:17:14 +0300 Subject: [PATCH 1/3] Update Adapter.c- ble hci --- devices/ble_hci/common-hal/_bleio/Adapter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/devices/ble_hci/common-hal/_bleio/Adapter.c b/devices/ble_hci/common-hal/_bleio/Adapter.c index fac7eb9f5fddf..dae4d205f2a20 100644 --- a/devices/ble_hci/common-hal/_bleio/Adapter.c +++ b/devices/ble_hci/common-hal/_bleio/Adapter.c @@ -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) @@ -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( From a7013d67ac1642a614981529e3be04e16e5500ca Mon Sep 17 00:00:00 2001 From: PolyPakhomova <155804625+PolyPakhomova@users.noreply.github.com> Date: Mon, 7 Jul 2025 18:21:15 +0300 Subject: [PATCH 2/3] Update Adapter.c-ports-common-hal --- ports/nordic/common-hal/_bleio/Adapter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nordic/common-hal/_bleio/Adapter.c b/ports/nordic/common-hal/_bleio/Adapter.c index b252cc49e58e2..601d4df720917 100644 --- a/ports/nordic/common-hal/_bleio/Adapter.c +++ b/ports/nordic/common-hal/_bleio/Adapter.c @@ -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; From 0aa98ba294a823ee3d2160d40a55efbd56de098a Mon Sep 17 00:00:00 2001 From: PolyPakhomova <155804625+PolyPakhomova@users.noreply.github.com> Date: Mon, 7 Jul 2025 18:30:13 +0300 Subject: [PATCH 3/3] Update Adapter.c --- shared-bindings/_bleio/Adapter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index 92b910c8b2e0f..70d65b43ee3fc 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -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 @@ -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} }, };