summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-03-25 17:41:47 -0700
committerScott Shawcroft <scott@tannewt.org>2020-03-25 17:41:47 -0700
commit8a5d3cd6c4a5c68606aafa7373a7b5fc2079a936 (patch)
treec2ff20916a87e29f5913f81bbc46d621a9c2171a /ports
parent3551b769a27c442780e978ea7a58cc56170cdfc8 (diff)
Add exception on small buffer and fix Connecion WRITE handling
Diffstat (limited to 'ports')
-rw-r--r--ports/nrf/common-hal/_bleio/Connection.c3
-rw-r--r--ports/nrf/common-hal/_bleio/PacketBuffer.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c
index 96e8b8fbe..d4c7308fd 100644
--- a/ports/nrf/common-hal/_bleio/Connection.c
+++ b/ports/nrf/common-hal/_bleio/Connection.c
@@ -162,7 +162,8 @@ bool connection_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
self->do_bond_cccds = true;
self->do_bond_cccds_request_time = supervisor_ticks_ms64();
}
- break;
+ // Return false so other handlers get this event as well.
+ return false;
case BLE_GATTS_EVT_SYS_ATTR_MISSING:
sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0);
diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.c b/ports/nrf/common-hal/_bleio/PacketBuffer.c
index 8382a0970..6ed6d1451 100644
--- a/ports/nrf/common-hal/_bleio/PacketBuffer.c
+++ b/ports/nrf/common-hal/_bleio/PacketBuffer.c
@@ -148,6 +148,7 @@ STATIC bool packet_buffer_on_ble_server_evt(ble_evt_t *ble_evt, void *param) {
// A client wrote to this server characteristic.
ble_gatts_evt_write_t *evt_write = &ble_evt->evt.gatts_evt.params.write;
+
// Event handle must match the handle for my characteristic.
if (evt_write->handle == self->characteristic->handle) {
if (self->conn_handle == BLE_CONN_HANDLE_INVALID) {
@@ -261,8 +262,7 @@ int common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self, uin
sd_nvic_critical_region_enter(&is_nested_critical_region);
if (packet_length > len) {
- // TODO: raise an exception.
- packet_length = len;
+ return len - packet_length;
}
ringbuf_get_n(&self->ringbuf, data, packet_length);