@@ -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 ;
0 commit comments