Merge pull request #1491 from dhalbert/ble-data-length-update

bleio: handle events sent by newer devices and by Android
This commit is contained in:
Scott Shawcroft 2019-01-24 09:53:59 -08:00 committed by GitHub
commit e77872f9c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

View File

@ -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/> miniQR Non-hardware QR code generator <https://circuitpython.readthedocs.io/projects/miniqr/en/latest/>
Slideshow <https://circuitpython.readthedocs.io/projects/slideshow/en/latest/> Slideshow <https://circuitpython.readthedocs.io/projects/slideshow/en/latest/>
LED Animation <https://circuitpython.readthedocs.io/projects/led-animation/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 Blinky
-------- --------

View File

@ -266,11 +266,19 @@ STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
break; 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: { case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: {
sd_ble_gatts_exchange_mtu_reply(self->conn_handle, BLE_GATT_ATT_MTU_DEFAULT); sd_ble_gatts_exchange_mtu_reply(self->conn_handle, BLE_GATT_ATT_MTU_DEFAULT);
break; break;
} }
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0);
break;
default: default:
// For debugging. // For debugging.
// mp_printf(&mp_plat_print, "Unhandled peripheral event: 0x%04x\n", ble_evt->header.evt_id); // mp_printf(&mp_plat_print, "Unhandled peripheral event: 0x%04x\n", ble_evt->header.evt_id);

View File

@ -48,6 +48,9 @@
//| :class:`Device` -- BLE device //| :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. //| 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, //| 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 //| it will be set to the Peripheral role. If a address is passed, the device

View File

@ -70,7 +70,7 @@ static const char default_name[] = "CIRCUITPY";
//| periph = bleio.Peripheral([service]) //| periph = bleio.Peripheral([service])
//| periph.start_advertising() //| periph.start_advertising()
//| //|
//| while not periph.connected(): //| while not periph.connected:
//| # Wait for connection. //| # Wait for connection.
//| pass //| pass
//| //|