Added Bluefruit.setEventCallback()

close #181
This commit is contained in:
hathach committed 2018-11-09 12:00:50 +07:00
1 parent a733a566c6
commit 2135a173d0
3 files changed
+14

No files matched your search

+1
View File
@@ -22,6 +22,7 @@
- USE_LFRC or USE_LFXO must be defined in board's variant.h
- Fixed Scanner running state when timeout ( PR #186 thanks to @Ryscho )
- Fixed #192 Client Characteristic write() return number of writtent instead of error code
- Added #181 Bluefruit.setEventCallback() for user to handle ble event
## 0.8.6
@@ -140,6 +140,7 @@ AdafruitBluefruit::AdafruitBluefruit(void)
_connect_cb = NULL;
_disconnect_cb = NULL;
_event_cb = NULL;
COMMENT_OUT(
_auth_type = BLE_GAP_AUTH_KEY_TYPE_NONE;
@@ -618,6 +619,11 @@ void AdafruitBluefruit::setDisconnectCallback( BLEGap::disconnect_callback_t fp
_disconnect_cb = fp;
}
void AdafruitBluefruit::setEventCallback ( void (*fp) (ble_evt_t*) )
{
_event_cb = fp;
}
uint16_t AdafruitBluefruit::connHandle(void)
{
return _conn_hdl;
@@ -856,6 +862,9 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
// GATTs characteristics event handler
Gatt._eventHandler(evt);
// User callback if set
if (_event_cb) _event_cb(evt);
}
/*------------------------------------------------------------------*/
+4
View File
@@ -178,6 +178,8 @@ class AdafruitBluefruit
void setConnectCallback ( BLEGap::connect_callback_t fp);
void setDisconnectCallback( BLEGap::disconnect_callback_t fp);
void setEventCallback ( void (*fp) (ble_evt_t*) );
COMMENT_OUT ( bool setPIN(const char* pin); )
/*------------------------------------------------------------------*/
@@ -223,6 +225,8 @@ class AdafruitBluefruit
BLEGap::connect_callback_t _connect_cb;
BLEGap::disconnect_callback_t _disconnect_cb;
void (*_event_cb) (ble_evt_t*);
COMMENT_OUT(
uint8_t _auth_type;
char _pin[BLE_GAP_PASSKEY_LEN];