From b1f1bb1389809e07c8b315aa9891d58e79c247e9 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 23 Jan 2019 21:07:23 -0500 Subject: [PATCH 1/3] support BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST, sent by newer devices --- ports/nrf/common-hal/bleio/Peripheral.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 7108259607..9dedc33e9b 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -266,6 +266,10 @@ STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { break; } + case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST: + sd_ble_gap_data_length_update(self->conn_handle, NULL, NULL); + break; + case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: { sd_ble_gatts_exchange_mtu_reply(self->conn_handle, BLE_GATT_ATT_MTU_DEFAULT); break; From 7998a7696d31c68c8837af86173ec5d507567ca2 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 23 Jan 2019 22:12:38 -0500 Subject: [PATCH 2/3] also handle BLE_GATTS_EVT_SYS_ATTR_MISSING: fixes Android: --- ports/nrf/common-hal/bleio/Peripheral.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 9dedc33e9b..0a5a8069de 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -275,6 +275,10 @@ STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) { break; } + case BLE_GATTS_EVT_SYS_ATTR_MISSING: + sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0); + break; + default: // For debugging. // mp_printf(&mp_plat_print, "Unhandled peripheral event: 0x%04x\n", ble_evt->header.evt_id); From 04aa906fac7b57d56c3f7c1249ebe4b1e8690422 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 24 Jan 2019 00:13:15 -0500 Subject: [PATCH 3/3] fix a few ble-related doc issues --- docs/drivers.rst | 2 ++ shared-bindings/bleio/Device.c | 3 +++ shared-bindings/bleio/Peripheral.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/drivers.rst b/docs/drivers.rst index fcd94bc3b8..148db804d7 100644 --- a/docs/drivers.rst +++ b/docs/drivers.rst @@ -70,6 +70,8 @@ These libraries build on top of the low level APIs to simplify common tasks. miniQR Non-hardware QR code generator Slideshow LED Animation + Bluetooth Low Energy (BLE) + Bluefruit LE Connect App Blinky -------- diff --git a/shared-bindings/bleio/Device.c b/shared-bindings/bleio/Device.c index cbad9fb7ea..e40efbb595 100644 --- a/shared-bindings/bleio/Device.c +++ b/shared-bindings/bleio/Device.c @@ -48,6 +48,9 @@ //| :class:`Device` -- BLE device //| ========================================================= //| +//| **IGNORE ``Device`` and all its documentation. +//| It is being replaced by `Peripheral` and other classes.** +//| //| Provides access a to BLE device, either in a Peripheral or Central role. //| When a device is created without any parameter passed to the constructor, //| it will be set to the Peripheral role. If a address is passed, the device diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c index eff4ca7f26..340485f353 100644 --- a/shared-bindings/bleio/Peripheral.c +++ b/shared-bindings/bleio/Peripheral.c @@ -70,7 +70,7 @@ static const char default_name[] = "CIRCUITPY"; //| periph = bleio.Peripheral([service]) //| periph.start_advertising() //| -//| while not periph.connected(): +//| while not periph.connected: //| # Wait for connection. //| pass //|