mirror of
https://github.com/tpunix/HMCLOCK.git
synced 2025-12-06 08:12:48 +08:00
根据MAC地址动态生成设备名字
This commit is contained in:
@@ -120,7 +120,7 @@
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>DLGUARM</Key>
|
||||
<Name>d</Name>
|
||||
<Name></Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
||||
@@ -213,7 +213,7 @@ static const struct advertise_configuration user_adv_conf = {
|
||||
****************************************************************************************
|
||||
*/
|
||||
/// Device name
|
||||
#define USER_DEVICE_NAME "DLG-CLOCK"
|
||||
#define USER_DEVICE_NAME ""
|
||||
|
||||
/// Device name length
|
||||
#define USER_DEVICE_NAME_LEN (sizeof(USER_DEVICE_NAME)-1)
|
||||
|
||||
@@ -292,21 +292,36 @@ void user_app_on_db_init_complete( void )
|
||||
|
||||
void user_app_adv_start(void)
|
||||
{
|
||||
// Schedule the next advertising data update
|
||||
//app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb);
|
||||
u32 ba0 = *(volatile u32*)(0x40000024);
|
||||
u32 ba1 = *(volatile u32*)(0x40000028);
|
||||
char adv_name[20];
|
||||
|
||||
struct gapm_start_advertise_cmd* cmd;
|
||||
cmd = app_easy_gap_undirected_advertise_get_active();
|
||||
ba1 = (ba1<<8)|(ba0>>24);
|
||||
ba0 &= 0x00ffffff;
|
||||
ba0 ^= ba1;
|
||||
|
||||
// Add manufacturer data to initial advertising or scan response data, if there is enough space
|
||||
app_add_ad_struct(cmd, &mnf_data, sizeof(struct mnf_specific_data_ad_structure), 1);
|
||||
u8 *ba = (u8*)&ba0;
|
||||
sprintf(adv_name+2, "DLG-CLOCK-%02x%02x%02x", ba[2], ba[1], ba[0]);
|
||||
int name_len = strlen(adv_name+2);
|
||||
|
||||
if(device_info.dev_name.length==0){
|
||||
device_info.dev_name.length = name_len;
|
||||
memcpy(device_info.dev_name.name, adv_name+2, name_len);
|
||||
}
|
||||
|
||||
adv_name[0] = name_len+1;
|
||||
adv_name[1] = GAP_AD_TYPE_COMPLETE_NAME;
|
||||
|
||||
struct gapm_start_advertise_cmd* cmd = app_easy_gap_undirected_advertise_get_active();
|
||||
app_add_ad_struct(cmd, adv_name, name_len+2, 1);
|
||||
|
||||
//default_advertise_operation();
|
||||
//app_easy_gap_undirected_advertise_start();
|
||||
app_easy_gap_undirected_advertise_with_timeout_start(user_default_hnd_conf.advertise_period, NULL);
|
||||
printk("\nuser_app_adv_start!\n");
|
||||
printk("\nuser_app_adv_start! %s\n", adv_name+2);
|
||||
}
|
||||
|
||||
|
||||
void user_app_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param)
|
||||
{
|
||||
printk("user_app_connection: %d\n", connection_idx);
|
||||
|
||||
Reference in New Issue
Block a user