diff --git a/epicardium/ble/ble.c b/epicardium/ble/ble.c index 0b066379664dd565edf62cf4b16b2b93796a744d..afe02ec285e7bc3657decab7ad0d9e624e136c3f 100644 --- a/epicardium/ble/ble.c +++ b/epicardium/ble/ble.c @@ -269,17 +269,26 @@ void RSV11_IRQHandler(void) notify(); } /*************************************************************************************************/ -bool ble_shall_start(void) +bool ble_is_enabled(void) { - bool ble_enabled = config_get_boolean_with_default("ble_enable", false); + /* + * 0 = unknown, check config + * 1 = disabled + * 2 = enabled + */ + static int ble_state = 0; - if (ble_enabled) { - LOG_INFO("ble", "BLE is enabled."); - } else { - LOG_INFO("ble", "BLE is disabled."); + if (ble_state == 0) { + if (config_get_boolean_with_default("ble_enable", false)) { + ble_state = 2; + LOG_INFO("ble", "BLE is enabled."); + } else { + ble_state = 1; + LOG_INFO("ble", "BLE is disabled."); + } } - return ble_enabled; + return ble_state == 2; } /*************************************************************************************************/ static void scheduleTimer(void) diff --git a/epicardium/main.c b/epicardium/main.c index f4c7d9d94f3d135acc3d8de757e3143553829a72..20c0d325900c069acbea5082d86fe7f4486f297c 100644 --- a/epicardium/main.c +++ b/epicardium/main.c @@ -156,7 +156,7 @@ int main(void) } /* BLE */ - if (ble_shall_start()) { + if (ble_is_enabled()) { if (xTaskCreate( vBleTask, (const char *)"BLE", diff --git a/epicardium/modules/modules.h b/epicardium/modules/modules.h index a1aab4c47bf76f87a61ab69484aa066982cbf542..33c7526d148b569d58b6877e60ea93cdea7edc40 100644 --- a/epicardium/modules/modules.h +++ b/epicardium/modules/modules.h @@ -93,7 +93,7 @@ int pmic_read_amux(enum pmic_amux_signal sig, float *result); /* ---------- BLE ---------------------------------------------------------- */ void vBleTask(void *pvParameters); -bool ble_shall_start(void); +bool ble_is_enabled(void); void ble_uart_write(uint8_t *pValue, uint8_t len); /* ---------- Hardware (Peripheral) Locks ---------------------------------- */ diff --git a/epicardium/modules/sleep.c b/epicardium/modules/sleep.c index 1468940cdcbafe48026fbb621625a3c05d84b0d8..abeea8127a650e52bf61119ef9bd53c6e97fc6a3 100644 --- a/epicardium/modules/sleep.c +++ b/epicardium/modules/sleep.c @@ -190,7 +190,9 @@ void sleep_deepsleep(void) core1_stop(); MAX77650_getINT_GLBL(); gpio_low_power(); - BbDrvDisable(); + if (ble_is_enabled()) { + BbDrvDisable(); + } turnOffClocks(); old_clkcn = MXC_GCR->clkcn; switchToHIRC();