@@ -66,6 +66,7 @@ class NimBLEConnInfo;
6666# endif
6767
6868class NimBLEAddress ;
69+ class NimBLEDeviceCallbacks ;
6970
7071# define BLEDevice NimBLEDevice
7172# define BLEClient NimBLEClient
@@ -129,6 +130,7 @@ class NimBLEDevice {
129130 static bool setOwnAddrType (uint8_t type);
130131 static bool setOwnAddr (const NimBLEAddress& addr);
131132 static bool setOwnAddr (const uint8_t * addr);
133+ static void setDeviceCallbacks (NimBLEDeviceCallbacks* cb);
132134 static void setScanDuplicateCacheSize (uint16_t cacheSize);
133135 static void setScanFilterMode (uint8_t type);
134136 static bool setCustomGapHandler (gap_event_handler handler);
@@ -213,6 +215,8 @@ class NimBLEDevice {
213215 static ble_gap_event_listener m_listener;
214216 static uint8_t m_ownAddrType;
215217 static std::vector<NimBLEAddress> m_whiteList;
218+ static NimBLEDeviceCallbacks* m_pDeviceCallbacks;
219+ static NimBLEDeviceCallbacks defaultDeviceCallbacks;
216220
217221# if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
218222 static NimBLEScan* m_pScan;
@@ -295,5 +299,27 @@ class NimBLEDevice {
295299
296300# include " NimBLEUtils.h"
297301
302+ /* *
303+ * @brief Callbacks associated with a BLE device.
304+ */
305+ class NimBLEDeviceCallbacks {
306+ public:
307+ virtual ~NimBLEDeviceCallbacks () {};
308+
309+ /* *
310+ * @brief Indicates an inability to perform a store operation.
311+ * This callback should do one of two things:
312+ * -Address the problem and return 0, indicating that the store operation
313+ * should proceed.
314+ * -Return nonzero to indicate that the store operation should be aborted.
315+ * @param event Describes the store event being reported.
316+ * BLE_STORE_EVENT_FULL; or
317+ * BLE_STORE_EVENT_OVERFLOW
318+ * @return 0 if the store operation should proceed;
319+ * nonzero if the store operation should be aborted.
320+ */
321+ virtual int onStoreStatus (struct ble_store_status_event * event, void * arg);
322+ };
323+
298324#endif // CONFIG_BT_ENABLED
299325#endif // NIMBLE_CPP_DEVICE_H_
0 commit comments