Skip to content
Snippets Groups Projects
Commit c7be3eec authored by schneider's avatar schneider
Browse files

ble: Don't panic when initializing BLE from mpy if ble is off

parent b238f9e0
No related branches found
No related tags found
No related merge requests found
......@@ -97,6 +97,10 @@ void ble_epic_ble_api_trigger_event(enum epic_ble_event_type type, void *data)
int epic_ble_get_event(struct epic_ble_event *e)
{
if (!ble_is_enabled()) {
return -EIO;
}
if (xQueueReceive(ble_event_queue, e, 0) != pdTRUE) {
return -ENOENT;
}
......@@ -162,6 +166,10 @@ void vDmTimerCallback()
int epic_ble_init(void)
{
if (!ble_is_enabled()) {
return -EIO;
}
if (dm_timer == NULL) {
dm_timer = xTimerCreateStatic(
"dmtimer",
......
......@@ -474,9 +474,14 @@ int mp_bluetooth_init(void)
MP_ROM_INT(EPIC_INT_BLE), (mp_obj_t *)&ble_event_obj
);
clear_events();
epic_ble_init();
int ret = epic_ble_init();
if (ret == 0) {
active = true;
return 0;
} else {
active = false;
}
return ret;
}
// Disables the Bluetooth stack. Is a no-op when not enabled.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment