Add flag for debug printing
This should normally be false, but can be set to true for debugging.
This commit is contained in:
parent
d715f7d4df
commit
f2f9a517d0
2 changed files with 15 additions and 0 deletions
|
@ -1,5 +1,8 @@
|
||||||
package bluetooth
|
package bluetooth
|
||||||
|
|
||||||
|
// Set this to true to print debug messages, for example for unknown events.
|
||||||
|
const debug = false
|
||||||
|
|
||||||
// SetEventHandler sets the callback that gets called on incoming events.
|
// SetEventHandler sets the callback that gets called on incoming events.
|
||||||
//
|
//
|
||||||
// Warning: must only be called when the Bluetooth stack has not yet been
|
// Warning: must only be called when the Bluetooth stack has not yet been
|
||||||
|
|
|
@ -129,6 +129,10 @@ func handleEvent() {
|
||||||
handler(&ConnectEvent{GAPEvent: gapEvent})
|
handler(&ConnectEvent{GAPEvent: gapEvent})
|
||||||
case C.BLE_GAP_EVT_DISCONNECTED:
|
case C.BLE_GAP_EVT_DISCONNECTED:
|
||||||
handler(&DisconnectEvent{GAPEvent: gapEvent})
|
handler(&DisconnectEvent{GAPEvent: gapEvent})
|
||||||
|
default:
|
||||||
|
if debug {
|
||||||
|
println("unknown GAP event:", id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case id >= C.BLE_GATTS_EVT_BASE && id <= C.BLE_GATTS_EVT_LAST:
|
case id >= C.BLE_GATTS_EVT_BASE && id <= C.BLE_GATTS_EVT_LAST:
|
||||||
gattsEvent := eventBuf.evt.unionfield_gatts_evt()
|
gattsEvent := eventBuf.evt.unionfield_gatts_evt()
|
||||||
|
@ -155,6 +159,14 @@ func handleEvent() {
|
||||||
// This event is generated by some devices. While we could support
|
// This event is generated by some devices. While we could support
|
||||||
// larger MTUs, this default MTU is supported everywhere.
|
// larger MTUs, this default MTU is supported everywhere.
|
||||||
C.sd_ble_gatts_exchange_mtu_reply(gattsEvent.conn_handle, C.BLE_GATT_ATT_MTU_DEFAULT)
|
C.sd_ble_gatts_exchange_mtu_reply(gattsEvent.conn_handle, C.BLE_GATT_ATT_MTU_DEFAULT)
|
||||||
|
default:
|
||||||
|
if debug {
|
||||||
|
println("unknown GATTS event:", id, id-C.BLE_GATTS_EVT_BASE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if debug {
|
||||||
|
println("unknown event:", id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue