diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2019-01-24 09:53:59 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-24 09:53:59 -0800 |
| commit | e77872f9c6d4cdbb7ef1f9be2956e1d12b6d1e5e (patch) | |
| tree | 836a844400c380960e6f5165bfdc204fc340c0b1 | |
| parent | 49581f9e1cbe8446b9fc3a44f6176ff3f5285b4b (diff) | |
| parent | 04aa906fac7b57d56c3f7c1249ebe4b1e8690422 (diff) | |
Merge pull request #1491 from dhalbert/ble-data-length-update
bleio: handle events sent by newer devices and by Android
| -rw-r--r-- | docs/drivers.rst | 2 | ||||
| -rw-r--r-- | ports/nrf/common-hal/bleio/Peripheral.c | 8 | ||||
| -rw-r--r-- | shared-bindings/bleio/Device.c | 3 | ||||
| -rw-r--r-- | shared-bindings/bleio/Peripheral.c | 2 |
4 files changed, 14 insertions, 1 deletions
diff --git a/docs/drivers.rst b/docs/drivers.rst index fcd94bc3b..148db804d 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 <https://circuitpython.readthedocs.io/projects/miniqr/en/latest/> Slideshow <https://circuitpython.readthedocs.io/projects/slideshow/en/latest/> LED Animation <https://circuitpython.readthedocs.io/projects/led-animation/en/latest/> + Bluetooth Low Energy (BLE) <https://circuitpython.readthedocs.io/projects/ble/en/latest/> + Bluefruit LE Connect App <https://circuitpython.readthedocs.io/projects/bluefruitconnect/en/latest/> Blinky -------- diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c index 710825960..0a5a8069d 100644 --- a/ports/nrf/common-hal/bleio/Peripheral.c +++ b/ports/nrf/common-hal/bleio/Peripheral.c @@ -266,11 +266,19 @@ 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; } + 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); diff --git a/shared-bindings/bleio/Device.c b/shared-bindings/bleio/Device.c index cbad9fb7e..e40efbb59 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 eff4ca7f2..340485f35 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 //| |
