From 040baa12c08b439f9a09f0c1594ac625e58e2ad1 Mon Sep 17 00:00:00 2001 From: Joe Finney Date: Wed, 1 Mar 2017 16:53:28 +0000 Subject: [PATCH] Add NRF event loop handler hook. --- source/btle/btle.cpp | 8 ++++++++ source/btle/btle.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/source/btle/btle.cpp b/source/btle/btle.cpp index 04b8ef6..7b0c6f7 100644 --- a/source/btle/btle.cpp +++ b/source/btle/btle.cpp @@ -48,10 +48,13 @@ void app_error_handler(uint32_t error_code, uint32_t line_num, const static void btle_handler(ble_evt_t *p_ble_evt); static uint32_t gatt_table_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT; +static void (*user_cb)(uint32_t) = NULL; static void sys_evt_dispatch(uint32_t sys_evt) { pstorage_sys_event_handler(sys_evt); + if (user_cb) + user_cb(sys_evt); } /** @@ -90,6 +93,11 @@ btle_set_gatt_table_size(uint32_t size) return ERROR_INVALID_PARAM; } +void btle_set_user_evt_handler(void (*func)(uint32_t)) +{ + user_cb = func; +} + error_t btle_init(void) { nrf_clock_lfclksrc_t clockSource; diff --git a/source/btle/btle.h b/source/btle/btle.h index ca50b2a..f2b78ed 100644 --- a/source/btle/btle.h +++ b/source/btle/btle.h @@ -28,6 +28,8 @@ extern "C" { error_t btle_init(void); error_t btle_set_gatt_table_size(uint32_t size); +void btle_set_user_evt_handler(void (*func)(uint32_t)); + #ifdef __cplusplus }