From b3eec4e7ec85f688276e39dcfbec9579f94dd675 Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Sun, 4 Aug 2019 01:14:26 +0200
Subject: [PATCH] fix(ble): Remove app callback to set BT MAC

---
 epicardium/ble/ble.c | 45 +++++++++++++++-----------------------------
 1 file changed, 15 insertions(+), 30 deletions(-)

diff --git a/epicardium/ble/ble.c b/epicardium/ble/ble.c
index a071f067..588c3f0c 100644
--- a/epicardium/ble/ble.c
+++ b/epicardium/ble/ble.c
@@ -91,37 +91,25 @@ static void WsfInit(void)
     WsfTraceEnable(TRUE);
 }
 /* TODO: We need a source of MACs */
-/*
- * In two-chip solutions, setting the address must wait until the HCI interface is initialized.
- * This handler can also catch other Application events, but none are currently implemented.
- * See ble-profiles/sources/apps/app/common/app_ui.c for further details.
- *
- */
-void SetAddress(uint8_t event)
+static void setAddress(void)
 {
     uint8_t bdAddr[6] = {0x02, 0x02, 0x44, 0x8B, 0x05, 0x00};
     char buf[32];
 
-    switch (event) {
-    case APP_UI_RESET_CMPL:
-        fs_read_text_file("mac.txt", buf, sizeof(buf));
-        printf("mac file: %s\n", buf);
-        int a, b, c, d, e, f;
-        if(sscanf(buf, "%x:%x:%x:%x:%x:%x", &a, &b, &c, &d, &e, &f) == 6) {
-            bdAddr[0] = f;
-            bdAddr[1] = e;
-            bdAddr[2] = d;
-            bdAddr[3] = c;
-            bdAddr[4] = b;
-            bdAddr[5] = a;
-        }
-
-        printf("Setting address -- MAC %02X:%02X:%02X:%02X:%02X:%02X\n", bdAddr[5], bdAddr[4], bdAddr[3], bdAddr[2], bdAddr[1], bdAddr[0]);
-        HciVsSetBdAddr(bdAddr);
-        break;
-    default:
-        break;
+    fs_read_text_file("mac.txt", buf, sizeof(buf));
+    printf("mac file: %s\n", buf);
+    int a, b, c, d, e, f;
+    if(sscanf(buf, "%x:%x:%x:%x:%x:%x", &a, &b, &c, &d, &e, &f) == 6) {
+        bdAddr[0] = f;
+        bdAddr[1] = e;
+        bdAddr[2] = d;
+        bdAddr[3] = c;
+        bdAddr[4] = b;
+        bdAddr[5] = a;
     }
+
+    printf("Setting address -- MAC %02X:%02X:%02X:%02X:%02X:%02X\n", bdAddr[5], bdAddr[4], bdAddr[3], bdAddr[2], bdAddr[1], bdAddr[0]);
+    HciVsSetBdAddr(bdAddr);
 }
 
 static StaticTimer_t x;
@@ -329,6 +317,7 @@ static void ble_init(void)
 {
     WsfInit();
     StackInitFit();
+    setAddress();
     NVIC_SetPriority(BTLE_SFD_TO_IRQn, 2);
     NVIC_SetPriority(BTLE_TX_DONE_IRQn, 2);
     NVIC_SetPriority(BTLE_RX_RCVD_IRQn, 2);
@@ -341,10 +330,6 @@ static void ble_init(void)
     AttsDynRegister(pSHdl, UARTReadCback, UARTWriteCback);
     //AttsDynRegister(pSHdl, NULL, UARTWriteCback);
 
-
-    /* Register a handler for Application events */
-    AppUiActionRegister(SetAddress);
-
     lasttick = xTaskGetTickCount();
 
     timerWakeup = xTimerCreateStatic(
-- 
GitLab