Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing last four digits of mac address on display at boot-up #244

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions source/application/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,14 @@ void bluetooth_setup(bool factory_reset)
LOG("Softdevice using 0x%lx bytes of RAM", ram_start - 0x20000000);

// Set device name
ble_gap_addr_t mac_address;
check_error(sd_ble_gap_addr_get(&mac_address));

char device_name[9] = "";
sprintf(device_name, "Frame %02X", mac_address.addr[5]);

ble_gap_conn_sec_mode_t write_permission;
BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&write_permission);
const char device_name[] = "Frame";
check_error(sd_ble_gap_device_name_set(&write_permission,
(const uint8_t *)device_name,
strlen(device_name)));
Expand Down Expand Up @@ -521,12 +526,10 @@ void bluetooth_setup(bool factory_reset)
&ble_handles.repl_tx_notification));

// Add name to advertising payload
adv.payload[adv.length++] = strlen((const char *)device_name) + 1;
adv.payload[adv.length++] = strlen(device_name) + 1;
adv.payload[adv.length++] = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME;
memcpy(&adv.payload[adv.length],
device_name,
sizeof(device_name));
adv.length += strlen((const char *)device_name);
memcpy(&adv.payload[adv.length], device_name, strlen(device_name));
adv.length += strlen(device_name);

// Set discovery mode flag
adv.payload[adv.length++] = 0x02;
Expand Down
2 changes: 1 addition & 1 deletion source/application/lua_libraries/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static int lua_bluetooth_address(lua_State *L)
check_error(sd_ble_gap_addr_get(&addr));

char mac_addr_string[18];
sprintf(mac_addr_string, "%02x:%02x:%02x:%02x:%02x:%02x",
sprintf(mac_addr_string, "%02X:%02X:%02X:%02X:%02X:%02X",
addr.addr[0], addr.addr[1], addr.addr[2],
addr.addr[3], addr.addr[4], addr.addr[5]);

Expand Down
3 changes: 2 additions & 1 deletion source/application/luaport.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ void run_lua(bool factory_reset)
}

// Show splash screen
status = luaL_dostring(L, "frame.display.text('FRAME', 280, 176);"
status = luaL_dostring(L, "frame.display.text('Ready to Pair', 200, 140);"
"frame.display.text('Frame '..frame.bluetooth.address():sub(-2, -1), 245, 210, { color = 'ORANGE' });"
"frame.display.show();");

if (status != LUA_OK)
Expand Down