Fix connection handle tracking in PacketBuffer when a server.
This commit is contained in:
parent
59eb35da30
commit
3551b769a2
@ -156,8 +156,7 @@ STATIC bool packet_buffer_on_ble_server_evt(ble_evt_t *ble_evt, void *param) {
|
||||
return false;
|
||||
}
|
||||
write_to_ringbuf(self, evt_write->data, evt_write->len);
|
||||
} else if (evt_write->handle == self->characteristic->cccd_handle &&
|
||||
self->conn_handle == BLE_CONN_HANDLE_INVALID) {
|
||||
} else if (evt_write->handle == self->characteristic->cccd_handle) {
|
||||
uint16_t cccd = *((uint16_t*) evt_write->data);
|
||||
if (cccd & BLE_GATT_HVX_NOTIFICATION) {
|
||||
self->conn_handle = conn_handle;
|
||||
@ -167,6 +166,11 @@ STATIC bool packet_buffer_on_ble_server_evt(ble_evt_t *ble_evt, void *param) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BLE_GAP_EVT_DISCONNECTED: {
|
||||
if (self->conn_handle == conn_handle) {
|
||||
self->conn_handle = BLE_CONN_HANDLE_INVALID;
|
||||
}
|
||||
}
|
||||
case BLE_GATTS_EVT_HVN_TX_COMPLETE: {
|
||||
queue_next_write(self);
|
||||
}
|
||||
@ -192,6 +196,8 @@ void common_hal_bleio_packet_buffer_construct(
|
||||
incoming = outgoing;
|
||||
outgoing = temp;
|
||||
self->conn_handle = bleio_connection_get_conn_handle(MP_OBJ_TO_PTR(self->characteristic->service->connection));
|
||||
} else {
|
||||
self->conn_handle = BLE_CONN_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
if (incoming) {
|
||||
|
Loading…
Reference in New Issue
Block a user