From 43be6a7aa6fb37ba04857f73cbe47ac998623d11 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 19 May 2017 17:32:13 +0200 Subject: [PATCH] Avoid exporting BLE symbols in sketches which don't use BLE By moving the BLE stack initialization to its library we can avoid including it in any build. --- .../src/internal/BLEDeviceManager.cpp | 1 + libraries/CurieBLE/src/internal/ble_client.c | 9 +++++++++ libraries/CurieBLE/src/internal/ble_client.h | 1 + .../framework/include/cfw_platform.h | 1 + .../framework/src/cfw_platform.c | 3 +-- variants/arduino_101/libarc32drv_arduino101.a | Bin 190830 -> 190896 bytes 6 files changed, 13 insertions(+), 2 deletions(-) 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 db6e5b4591162ed7abd8d50f81b0b7d077847d32..46b88a7911b24d91f8cc23a782b637928827524b 100644 GIT binary patch delta 6085 zcmc&&4RBP|6~5>0Zn8^QvRO8pkPT!>NLUisY&M(CpQRxvVH6E9C_hp+n`9w@kfggI zK|9H@fR1^Z3WIeyV-0r3%Y(Zn~U>{oI$m@W*8x` zosi5OgyhT^8u`-+an8SO_=CpPHH7@H(c~cHX83QVyji!ppO72z6z;@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