Skip to content

Commit

Permalink
Merge pull request #244 from brilliantlabsAR/pairing-improvements
Browse files Browse the repository at this point in the history
Showing last four digits of mac address on display at boot-up
  • Loading branch information
siliconwitch authored Aug 7, 2024
2 parents 9c2704d + f08946d commit 7f76ee6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
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

0 comments on commit 7f76ee6

Please sign in to comment.