Skip to content

Commit

Permalink
Avoid exporting BLE symbols in sketches which don't use BLE
Browse files Browse the repository at this point in the history
By moving the BLE stack initialization to its library we can avoid including it in any build.
  • Loading branch information
facchinm committed May 19, 2017
1 parent c8ea5d0 commit 43be6a7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions libraries/CurieBLE/src/internal/BLEDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
9 changes: 9 additions & 0 deletions libraries/CurieBLE/src/internal/ble_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions libraries/CurieBLE/src/internal/ble_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions system/libarc32_arduino101/framework/src/cfw_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
Binary file modified variants/arduino_101/libarc32drv_arduino101.a
Binary file not shown.

0 comments on commit 43be6a7

Please sign in to comment.