diff --git a/epicardium/ble/ble.c b/epicardium/ble/ble.c index a667f9d1f739d8f7b15210971adb0caec78e1bd6..7d0125f1f600611b91c20150e4e3615dda80a341 100644 --- a/epicardium/ble/ble.c +++ b/epicardium/ble/ble.c @@ -90,16 +90,13 @@ static void WsfInit(void) /* TODO: We need a source of MACs */ static void setAddress(void) { - uint8_t bdAddr[6] = { 0x02, 0x02, 0x44, 0x8B, 0x05, 0x00 }; + uint8_t bdAddr[6] = { 0xCA, 0x4D, 0x10, 0x00, 0x00, 0x00 }; char buf[32]; int result = fs_read_text_file("mac.txt", buf, sizeof(buf)); if (result == -1) { APP_TRACE_INFO0("mac.txt not found, generating random MAC"); - bdAddr[0] = 0xCA; - bdAddr[1] = 0x4D; - bdAddr[2] = 0x10; epic_trng_read(bdAddr + 3, 3); sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x\n", @@ -123,7 +120,7 @@ static void setAddress(void) bdAddr[4] = b; bdAddr[5] = a; } - + LOG_INFO( "ble", "Setting MAC address to %02X:%02X:%02X:%02X:%02X:%02X", diff --git a/epicardium/ble/ble_main.c b/epicardium/ble/ble_main.c index a20b197d92c0224ccdad664dccba7d6be717b22d..a19c798322de2edaa08bbb7b287cd6304d842f27 100644 --- a/epicardium/ble/ble_main.c +++ b/epicardium/ble/ble_main.c @@ -13,9 +13,11 @@ */ /* clang-format off */ /* clang-formet turned off for easier diffing against orginal file */ +#include <stdio.h> #include <string.h> #include "wsf_types.h" #include "util/bstream.h" +#include "fs_util.h" #include "wsf_msg.h" #include "wsf_trace.h" #include "hci_api.h" @@ -155,12 +157,12 @@ static const uint8_t bleAdvDataDisc[] = }; /*! scan data, discoverable mode */ -static const uint8_t bleScanDataDisc[] = +uint8_t bleScanDataDisc[] = { /*! device name */ - 7, /*! length */ + 14, /*! length */ DM_ADV_TYPE_LOCAL_NAME, /*! AD type */ - 'c','a','r','d','1','0' + 'c','a','r','d','1','0','-','0','0','0','0','0','0' }; /************************************************************************************************** @@ -323,6 +325,22 @@ static void bleClose(bleMsg_t *pMsg) /*************************************************************************************************/ static void bleSetup(bleMsg_t *pMsg) { + char buf[32]; + char a, b, c, d, e, f; + + if (fs_read_text_file("mac.txt", buf, sizeof(buf))) + { + if (sscanf(buf, "**:**:**:%c%c:%c%c:%c%c", &a, &b, &c, &d, &e, &f) == 6) + { + bleScanDataDisc[9] = a; + bleScanDataDisc[10] = b; + bleScanDataDisc[11] = c; + bleScanDataDisc[12] = d; + bleScanDataDisc[13] = e; + bleScanDataDisc[14] = f; + } + } + /* set advertising and scan response data for discoverable mode */ AppAdvSetData(APP_ADV_DATA_DISCOVERABLE, sizeof(bleAdvDataDisc), (uint8_t *) bleAdvDataDisc); AppAdvSetData(APP_SCAN_DATA_DISCOVERABLE, sizeof(bleScanDataDisc), (uint8_t *) bleScanDataDisc); diff --git a/flash-all.gdb b/flash-all.gdb index 2b372841b4d911489d8bfe4e055c787334c3d417..5851c180c489598557e3aeba7cfa2c89fb9b4222 100644 --- a/flash-all.gdb +++ b/flash-all.gdb @@ -2,6 +2,9 @@ source init.gdb set confirm off +mon max32xxx mass_erase 0 +mon max32xxx mass_erase 1 + echo #### BOOTLOADER ####\n load build/bootloader/bootloader.elf echo #### EPICARDIUM ####\n