8000 Merge pull request #4522 from tannewt/ble_fixup · carlossless/circuitpython@d0ba75e · GitHub
[go: up one dir, main page]

Skip to content

Commit d0ba75e

Browse files
authored
Merge pull request adafruit#4522 from tannewt/ble_fixup
Fix central pairing and crash on clear
2 parents 3e8e683 + 0752bbd commit d0ba75e

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

locale/circuitpython.pot

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,7 @@ msgstr ""
11711171

11721172
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
11731173
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
1174+
#: ports/mimxrt10xx/common-hal/busio/UART.c
11741175
msgid "Invalid %q pin"
11751176
msgstr ""
11761177

@@ -1581,6 +1582,10 @@ msgstr ""
15811582
msgid "Nordic Soft Device failure assertion."
15821583
msgstr ""
15831584

1585+
#: ports/nrf/common-hal/_bleio/__init__.c
1586+
msgid "Nordic soft device out of memory"
1587+
msgstr ""
1588+
15841589
#: shared-bindings/ipaddress/IPv4Address.c shared-bindings/ipaddress/__init__.c
15851590
msgid "Not a valid IP string"
15861591
msgstr ""
@@ -1877,7 +1882,7 @@ msgstr ""
18771882
msgid "Read-only filesystem"
18781883
msgstr ""
18791884

1880-
#: shared-module/bitmaptools/__init__.c shared-module/displayio/Bitmap.c
1885+
#: shared-module/displayio/Bitmap.c
18811886
msgid "Read-only object"
18821887
msgstr ""
18831888

@@ -1952,14 +1957,6 @@ msgstr ""
19521957
msgid "Scan already in progess. Stop with stop_scan."
19531958
msgstr ""
19541959

1955-
#: ports/mimxrt10xx/common-hal/busio/UART.c
1956-
msgid "Selected CTS pin not valid"
1957-
msgstr ""
1958-
1959-
#: ports/mimxrt10xx/common-hal/busio/UART.c
1960-
msgid "Selected RTS pin not valid"
1961-
msgstr ""
1962-
19631960
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
19641961
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
19651962
msgid "Serializer in use"

ports/nrf/common-hal/_bleio/Adapter.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ STATIC uint32_t ble_stack_enable(void) {
147147
ble_conf.gap_cfg.role_count_cfg.periph_role_count = BLEIO_PERIPH_ROLE_COUNT;
148148
// central_role_count costs 648 bytes for 1 to 2, then ~1250 for each further increment.
149149
ble_conf.gap_cfg.role_count_cfg.central_role_count = BLEIO_CENTRAL_ROLE_COUNT;
150+
// The number of concurrent pairing processes. Takes 392 bytes.
151+
ble_conf.gap_cfg.role_count_cfg.central_sec_count = BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT;
150152
err_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_conf, sd_ram_end);
151153
if (err_code != NRF_SUCCESS) {
152154
return err_code;
@@ -283,6 +285,10 @@ STATIC bool adapter_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
283285
ble_drv_remove_event_handler(connection_on_ble_evt, connection);
284286
connection->conn_handle = BLE_CONN_HANDLE_INVALID;
285287
connection->pair_status = PAIR_NOT_PAIRED;
288+
289+
#if CIRCUITPY_VERBOSE_BLE
290+
mp_printf(&mp_plat_print, "disconnected %02x\n", ble_evt->evt.gap_evt.params.disconnected.reason);
291+
#endif
286292
if (connection->connection_obj != mp_const_none) {
287293
bleio_connection_obj_t *obj = connection->connection_obj;
288294
obj->connection = NULL;

ports/nrf/common-hal/_bleio/Connection.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
325325
}
326326

327327
void bleio_connection_clear(bleio_connection_internal_t *self) {
328-
mp_obj_list_clear(MP_OBJ_FROM_PTR(self->remote_service_list));
329-
328+
self->remote_service_list = NULL;
330329
self->conn_handle = BLE_CONN_HANDLE_INVALID;
331330
self->pair_status = PAIR_NOT_PAIRED;
332331
self->is_central = false;

ports/nrf/common-hal/_bleio/__init__.c

Lines changed: 3 additions & 0 deletions
5983
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ void check_nrf_error(uint32_t err_code) {
4646
return;
4747
}
4848
switch (err_code) {
49+
case NRF_ERROR_NO_MEM:
50+
mp_raise_msg(&mp_type_MemoryError, translate("Nordic soft device out of memory"));
51+
return;
4952
case NRF_ERROR_TIMEOUT:
5053
mp_raise_msg(&mp_type_TimeoutError, NULL);
5154
return;

0 commit comments

Comments
 (0)
0