Skip to content

Commit f08946d

Browse files
committed
Now advertising Frame plus last two digits of mac address
1 parent 056c247 commit f08946d

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

source/application/bluetooth.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,14 @@ void bluetooth_setup(bool factory_reset)
409409
LOG("Softdevice using 0x%lx bytes of RAM", ram_start - 0x20000000);
410410

411411
// Set device name
412+
ble_gap_addr_t mac_address;
413+
check_error(sd_ble_gap_addr_get(&mac_address));
414+
415+
char device_name[9] = "";
416+
sprintf(device_name, "Frame %02X", mac_address.addr[5]);
417+
412418
ble_gap_conn_sec_mode_t write_permission;
413419
BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&write_permission);
414-
const char device_name[] = "Frame";
415420
check_error(sd_ble_gap_device_name_set(&write_permission,
416421
(const uint8_t *)device_name,
417422
strlen(device_name)));
@@ -521,12 +526,10 @@ void bluetooth_setup(bool factory_reset)
521526
&ble_handles.repl_tx_notification));
522527

523528
// Add name to advertising payload
524-
adv.payload[adv.length++] = strlen((const char *)device_name) + 1;
529+
adv.payload[adv.length++] = strlen(device_name) + 1;
525530
adv.payload[adv.length++] = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME;
526-
memcpy(&adv.payload[adv.length],
527-
device_name,
528-
sizeof(device_name));
529-
adv.length += strlen((const char *)device_name);
531+
memcpy(&adv.payload[adv.length], device_name, strlen(device_name));
532+
adv.length += strlen(device_name);
530533

531534
// Set discovery mode flag
532535
adv.payload[adv.length++] = 0x02;

source/application/luaport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ void run_lua(bool factory_reset)
121121
}
122122

123123
// Show splash screen
124-
status = luaL_dostring(L, "frame.display.text('Frame Ready to Pair', 125, 140);"
125-
"frame.display.text('ID: '..frame.bluetooth.address():sub(-5, -4)..frame.bluetooth.address():sub(-2, -1), 250, 210, { color = 'ORANGE' });"
124+
status = luaL_dostring(L, "frame.display.text('Ready to Pair', 200, 140);"
125+
"frame.display.text('Frame '..frame.bluetooth.address():sub(-2, -1), 245, 210, { color = 'ORANGE' });"
126126
"frame.display.show();");
127127

128128
if (status != LUA_OK)

0 commit comments

Comments
 (0)