From 15f99475676ceb0fbddfe7ba6f79843ffb9f2393 Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Sun, 24 Jan 2021 21:48:02 +0100
Subject: [PATCH] feat(mp-ble): Allow to check if module is initialized

---
 pycardium/modules/modbluetooth_card10.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pycardium/modules/modbluetooth_card10.c b/pycardium/modules/modbluetooth_card10.c
index 25b9e2e42..f9852382e 100644
--- a/pycardium/modules/modbluetooth_card10.c
+++ b/pycardium/modules/modbluetooth_card10.c
@@ -151,6 +151,8 @@ typedef struct {
 	enum notification_status notification_status;
 } gatts_status_entry_t;
 
+static bool active = false;
+
 static void gatts_status_create_entry(mp_gatts_db_t db, uint16_t handle)
 {
 	mp_map_elem_t *elem = mp_map_lookup(
@@ -305,20 +307,21 @@ int mp_bluetooth_init(void)
 	);
 	clear_events();
 	epic_interrupt_enable(EPIC_INT_BLE);
+	active = true;
 	return 0;
 }
 
 // Disables the Bluetooth stack. Is a no-op when not enabled.
 void mp_bluetooth_deinit(void)
 {
-	//raise();
 	epic_interrupt_disable(EPIC_INT_BLE);
+	active = false;
 }
 
 // Returns true when the Bluetooth stack is enabled.
 bool mp_bluetooth_is_active(void)
 {
-	return true;
+	return active;
 }
 
 // Gets the MAC addr of this device in big-endian format.
-- 
GitLab