diff --git a/libraries/CurieBLE/src/internal/BLEDeviceManager.cpp b/libraries/CurieBLE/src/internal/BLEDeviceManager.cpp index d5ddd181..c4d493b0 100644 --- a/libraries/CurieBLE/src/internal/BLEDeviceManager.cpp +++ b/libraries/CurieBLE/src/internal/BLEDeviceManager.cpp @@ -132,6 +132,7 @@ bool BLEDeviceManager::begin(BLEDevice *device) { if (NULL == _local_ble) { + ble_cfw_init(); _local_ble = device; bt_le_set_mac_address(_local_bda); diff --git a/libraries/CurieBLE/src/internal/ble_client.c b/libraries/CurieBLE/src/internal/ble_client.c index 5a9e6164..2ba00dbb 100644 --- a/libraries/CurieBLE/src/internal/ble_client.c +++ b/libraries/CurieBLE/src/internal/ble_client.c @@ -77,6 +77,15 @@ static void *ble_client_update_param_event_param; extern "C" { #endif +static bool initilized = false; + +inline void ble_cfw_init() { + if (!initilized) { + ble_cfw_service_init(BLE_SERVICE_ID, cfw_get_service_queue()); + initilized = true; + } +} + static void on_connected(bt_conn_t *conn, uint8_t err) { if (ble_client_connect_event_cb) diff --git a/libraries/CurieBLE/src/internal/ble_client.h b/libraries/CurieBLE/src/internal/ble_client.h index 75c3d59f..df380f12 100644 --- a/libraries/CurieBLE/src/internal/ble_client.h +++ b/libraries/CurieBLE/src/internal/ble_client.h @@ -102,6 +102,7 @@ typedef void (*ble_client_update_param_event_cb_t)(struct bt_conn *conn, extern "C" { #endif +void ble_cfw_init(); void ble_client_init(ble_client_connect_event_cb_t connect_cb, void* connect_param, ble_client_disconnect_event_cb_t disconnect_cb, void* disconnect_param, ble_client_update_param_event_cb_t update_param_cb, void* update_param_param); diff --git a/system/libarc32_arduino101/framework/include/cfw_platform.h b/system/libarc32_arduino101/framework/include/cfw_platform.h index aa5cb29e..b59a8495 100644 --- a/system/libarc32_arduino101/framework/include/cfw_platform.h +++ b/system/libarc32_arduino101/framework/include/cfw_platform.h @@ -40,6 +40,7 @@ extern "C" { void cfw_platform_init(void); T_QUEUE cfw_get_service_queue(void); +void ble_cfw_service_init(int service_id, T_QUEUE queue); #ifdef __cplusplus } diff --git a/system/libarc32_arduino101/framework/src/cfw_platform.c b/system/libarc32_arduino101/framework/src/cfw_platform.c index 5daa0951..f8c8cbb0 100644 --- a/system/libarc32_arduino101/framework/src/cfw_platform.c +++ b/system/libarc32_arduino101/framework/src/cfw_platform.c @@ -46,7 +46,6 @@ /* FIXME: Service manager API */ extern void _cfw_init(void *); -extern void ble_cfw_service_init(int service_id, T_QUEUE queue); extern void *services; @@ -115,7 +114,7 @@ void cfw_platform_init(void) shared_data->services, shared_data->service_mgr_port_id); #else _cfw_init(service_mgr_queue); - ble_cfw_service_init(BLE_SERVICE_ID, service_mgr_queue); + //ble_cfw_service_init(BLE_SERVICE_ID, service_mgr_queue); /* Initialized shared structure. */ shared_data->ports = port_get_port_table(); diff --git a/variants/arduino_101/libarc32drv_arduino101.a b/variants/arduino_101/libarc32drv_arduino101.a index db6e5b45..46b88a79 100644 Binary files a/variants/arduino_101/libarc32drv_arduino101.a and b/variants/arduino_101/libarc32drv_arduino101.a differ