File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
libraries/Bluefruit52Lib/src Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 22
22
- USE_LFRC or USE_LFXO must be defined in board's variant.h
23
23
- Fixed Scanner running state when timeout ( PR #186 thanks to @Ryscho )
24
24
- Fixed #192 Client Characteristic write() return number of writtent instead of error code
25
+ - Added #181 Bluefruit.setEventCallback() for user to handle ble event
25
26
26
27
## 0.8.6
27
28
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ AdafruitBluefruit::AdafruitBluefruit(void)
140
140
141
141
_connect_cb = NULL ;
142
142
_disconnect_cb = NULL ;
143
+ _event_cb = NULL ;
143
144
144
145
COMMENT_OUT (
145
146
_auth_type = BLE_GAP_AUTH_KEY_TYPE_NONE;
@@ -618,6 +619,11 @@ void AdafruitBluefruit::setDisconnectCallback( BLEGap::disconnect_callback_t fp
618
619
_disconnect_cb = fp;
619
620
}
620
621
622
+ void AdafruitBluefruit::setEventCallback ( void (*fp) (ble_evt_t *) )
623
+ {
624
+ _event_cb = fp;
625
+ }
626
+
621
627
uint16_t AdafruitBluefruit::connHandle (void )
622
628
{
623
629
return _conn_hdl;
@@ -856,6 +862,9 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
856
862
857
863
// GATTs characteristics event handler
858
864
Gatt._eventHandler (evt);
865
+
866
+ // User callback if set
867
+ if (_event_cb) _event_cb (evt);
859
868
}
860
869
861
870
/* ------------------------------------------------------------------*/
Original file line number Diff line number Diff line change @@ -178,6 +178,8 @@ class AdafruitBluefruit
178
178
void setConnectCallback ( BLEGap::connect_callback_t fp);
179
179
void setDisconnectCallback ( BLEGap::disconnect_callback_t fp);
180
180
181
+ void setEventCallback ( void (*fp) (ble_evt_t *) );
182
+
181
183
COMMENT_OUT ( bool setPIN (const char * pin); )
182
184
183
185
/* ------------------------------------------------------------------*/
@@ -223,6 +225,8 @@ class AdafruitBluefruit
223
225
BLEGap::connect_callback_t _connect_cb;
224
226
BLEGap::disconnect_callback_t _disconnect_cb;
225
227
228
+ void (*_event_cb) (ble_evt_t *);
229
+
226
230
COMMENT_OUT (
227
231
uint8_t _auth_type;
228
232
char _pin[BLE_GAP_PASSKEY_LEN];
You can’t perform that action at this time.
0 commit comments