diff --git a/source/application/bluetooth.c b/source/application/bluetooth.c index 9388dbd0..482bf0b7 100644 --- a/source/application/bluetooth.c +++ b/source/application/bluetooth.c @@ -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))); @@ -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; diff --git a/source/application/lua_libraries/bluetooth.c b/source/application/lua_libraries/bluetooth.c index 78b19412..5e471b34 100644 --- a/source/application/lua_libraries/bluetooth.c +++ b/source/application/lua_libraries/bluetooth.c @@ -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]); diff --git a/source/application/luaport.c b/source/application/luaport.c index 2af54175..d2db1b80 100644 --- a/source/application/luaport.c +++ b/source/application/luaport.c @@ -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)