nrf: handle other GAP events even without event handler

There was a bug (fixed by this commit) that if there was no event
handler, other GAP events would also be ignored.
This commit is contained in:
Ayke van Laethem 2020-05-27 16:50:41 +02:00
parent 5ed4112930
commit 93550127da
No known key found for this signature in database
GPG key ID: E97FF5335DFDFDED

View file

@ -117,19 +117,21 @@ func handleEvent() {
id := eventBuf.header.evt_id
switch {
case id >= C.BLE_GAP_EVT_BASE && id <= C.BLE_GAP_EVT_LAST:
handler := defaultAdapter.handler
if handler == nil {
return
}
connHandle := eventBuf.evt.unionfield_gap_evt().conn_handle
gapEvent := GAPEvent{
Connection: Connection(connHandle),
}
switch id {
case C.BLE_GAP_EVT_CONNECTED:
handler(&ConnectEvent{GAPEvent: gapEvent})
handler := defaultAdapter.handler
if handler != nil {
handler(&ConnectEvent{GAPEvent: gapEvent})
}
case C.BLE_GAP_EVT_DISCONNECTED:
handler(&DisconnectEvent{GAPEvent: gapEvent})
handler := defaultAdapter.handler
if handler != nil {
handler(&DisconnectEvent{GAPEvent: gapEvent})
}
case C.BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST:
// Respond with the default PPCP connection parameters by passing
// nil: