DA14531 Name Change Service/Characteristic

I was curious if there's a characteristic to change the GAP device name.

I know there's one to see the name, but I didn't see one to change the name. Is this one I'd have to manually create or is there a simple way to do so?

Thanks!

EDIT:

For those reading this in the future, I verified 3 answers for this. 1 is for a service and characteristic. The other 2 are for AT commands to accomplish the same task, 1 with persistent data and the other without.

Parents
  • Hi There,

    Thank you for posting your question online.
    Yes, it is possible to change the Device Name. 
    I worked on the ble_app_peripheral example with SDK v6.0.18.
    I created a custom characteristic for the Custom Service 1.
    On user_custs1_impl.c file:

    void user_svc1_dev_name_wr_ind_handler (ke_msg_id_t const msgid,
                                          struct custs1_val_write_ind const *param,
                                          ke_task_id_t const dest_id,
                                          ke_task_id_t const src_id)
    {
    
    	char new_device_name[NEW_DEVICE_NAME_LENGTH] = "\0";
    
    	memcpy(&new_device_name, &param->value, param->length);
    
    	device_info.dev_name.length = (strlen(new_device_name) <= GAP_MAX_NAME_SIZE) ?strlen(new_device_name) : GAP_MAX_NAME_SIZE;
    
    	memcpy(device_info.dev_name.name, new_device_name, device_info.dev_name.length);
    
    	
    }

    On user_peripheral.c file:
    void user_catch_rest_hndl(ke_msg_id_t const msgid,
                              void const *param,
                              ke_task_id_t const dest_id,
                              ke_task_id_t const src_id)
    {
        switch(msgid)
        {
            case CUSTS1_VAL_WRITE_IND:
            {
                struct custs1_val_write_ind const *msg_param = (struct custs1_val_write_ind const *)(param);
    
                switch (msg_param->handle)
                {
                    case SVC1_IDX_CONTROL_POINT_VAL:
                        user_svc1_ctrl_wr_ind_handler(msgid, msg_param, dest_id, src_id);
                        break;
    								
                    case SVC1_IDX_DEV_NAME_VAL:
                        user_svc1_dev_name_wr_ind_handler(msgid, msg_param, dest_id, src_id);
                        break;
                        .
                        .
                        .

    With the SmartBond App I connect into my device and I can change the Device name like this:


    ble_app_peripheral_dev_name.zip

    Kind Regards,
    OV_Renesas


  • Quick follow up to this actually: what compiler is required for these changes?

  • Hi There,

    Thank you for the reply.
    If you are working on Codeless v6.380.16.55 you will need ARM Compiler v6.
    If you are working on Codeless v6.380.14.22 or any older version you will need ARM Compiler v5.

    Kind Regards,
    OV_Renesas

  • Thanks for your time so far, I really appreciate it.

    Two more questions about your solution: 1) would your solution be applicable to the data pump firmware? 2) as far as I can tell there's two names attached to a "barebones" chip if you will: CLv2 and CodeLess. I believe your solution changes the CodeLess name. Do you know how to change the other name as well?

    Also, is there documentation that includes changing names? A quick search yielded no results.

  • Hi There,

    Thank you for the reply.
    1) Yes, a custom at command to change the Device Name can be used on the datapump firmware.
    2) No, there is only one name being used, which is the CLv2-CodeLess, the CLv2 is also the Short Device name which is being placed on the Advertising Data, while the CLv2-CodeLess is the full Device Name which is placed on the Scan Response Data and saved on the device_info struct.

    I worked on the CodeLess SDK v6.380.16.55 and followed the instructions mentioned on the CodeLess User Manual  6. Adding Custom Commands.
    The custom AT command I created is the AT+DEVNAME.
    On the user_at_commands.c file you can find the user_at_devname function:

    char new_device_name[GAP_MAX_NAME_SIZE] = "\0";
    bool flag_devname= false;
    // Custom AT command to change the Device Name
    #ifdef USE_AT_DEVNAME
    
    void user_at_devname(struct at_cmd_params_t* arg, char* reply_string)
    {
    	
    	
    	char zeroed[GAP_MAX_NAME_SIZE] = "0";
    	//Empty the new_device_name array
    	memcpy(new_device_name, &zeroed, GAP_MAX_NAME_SIZE);
    	//If AT+DEVNAME
    	if( arg->arg_count ==0)
    	{
    		//We only printed out the name, so keep flag_devname = false;
    		flag_devname = false; 
    		//Print the existing Device Name
    		arch_sprintf(reply_string, "%s", device_info.dev_name.name);
    		arg->success_flag = true;
    	}
    	else //else if AT+DEVNAME=
    	{
    		//We will change the Device Name (short and long) so change flag_devname= true
    		flag_devname= true;
    
    		//Empty the device_info struct 
    		memcpy(device_info.dev_name.name, &zeroed, GAP_MAX_NAME_SIZE);
    		//Save the New device name into the new_device_name variable
    		memcpy(&new_device_name, &arg->cmd_buffer[arg->arg_index[0]], GAP_MAX_NAME_SIZE);
    		device_info.dev_name.length = (strlen(new_device_name) <= GAP_MAX_NAME_SIZE) ?strlen(new_device_name) : GAP_MAX_NAME_SIZE;
    		//Save the New device name into the device_info struct
    		memcpy(device_info.dev_name.name, new_device_name, device_info.dev_name.length);
    		/* Set the Device Name to the codeless_env struct  */	
    	   memcpy(&codeless_env.resp_data, &device_info.dev_name.name, device_info.dev_name.length);
         codeless_env.resp_data_len = strlen(new_device_name);
    		 // Instantiate the advertising update message to be sent
        struct gapm_update_advertise_data_cmd *cmd = KE_MSG_ALLOC(GAPM_UPDATE_ADVERTISE_DATA_CMD,
                                                                  TASK_GAPM,
                                                                  TASK_APP,
                                                                  gapm_update_advertise_data_cmd);
    
        cmd->operation = GAPM_UPDATE_ADVERTISE_DATA;
    		//Set the Advertising Data as specifiec in user_app_init custom callback function
    		#ifdef USE_AT_BINARY_MODE
        const uint8_t advertisement_data[] =
        #else 
        uint8_t advertisement_data[] =
        #endif 
        { // Complete list of 128bit service UUIDs
        #ifdef USE_AT_BINARY_MODE 
            17, GAP_AD_TYPE_COMPLETE_LIST_128_BIT_UUID, SPS_SERV_ADV_UUID_REV_BYTES, 
        #else
            17, GAP_AD_TYPE_COMPLETE_LIST_128_BIT_UUID, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
        #endif
             3, GAP_AD_TYPE_MORE_16_BIT_UUID, 0xF5, 0xFE, //SUOTA Service
          // Bluetooth Device Name
             5, GAP_AD_TYPE_SHORTENED_NAME, 
             new_device_name[0],
             new_device_name[1],
             new_device_name[2],
             new_device_name[3]
        };
        #ifndef USE_AT_BINARY_MODE
        for (uint8_t i = 0; i < 16; i++) {
                advertisement_data[2 + i] = codeless_const_env.adv_service_uuid[i]; 
        }    
        #endif   
    		 //Save the advertisemnt_data into the codeless_env struct
        memcpy(&codeless_env.adv_data, &advertisement_data, sizeof(advertisement_data));
         //Save the Advertisment  data length into the codeless_env struct
        codeless_env.adv_data_len = sizeof(advertisement_data);
    		// Update the Advertising data 
        cmd->adv_data_len = codeless_env.adv_data_len;
        memcpy(cmd->adv_data, codeless_env.adv_data, codeless_env.adv_data_len);
    
     		/* Set the Device Name to Scan response data and show it */
    	  append_device_name(&cmd->scan_rsp_data_len,
    										   codeless_env.resp_data_len,
                           &(cmd->scan_rsp_data[cmd->scan_rsp_data_len]),
                           codeless_env.resp_data);
    
        // Send the message
        ke_msg_send(cmd);
    
    		//Print the New name
    		arch_sprintf(reply_string, "%s", device_info.dev_name.name);
    		arg->success_flag = true;
    	}
    	
    
    }
    #endif

    However, when disconnected or when we use the AT+ADVSTOP and AT+ADVSTART commands we restart advertising via the user_advertise custom callback function.
    I modified the user_disconnect and the user_at_advstart functions in order to use the new device name set by the AT+DEVNAME command. 
    Please see the screenshots below on how the AT command is being used:
       
    By default the Device Name is CLv2-CodeLess and you can see on the Advertising Data the Short Name: CLv2.
    When you use the AT+DEVNAME without any arguments, then it will print out the existing Device Name. When you use the AT+DEVNAME with arguments, it will use the arguments you used as the new Device Name:

    After that I can see on the SmartBond App:

    As you can see the first 4 characters are saved on the Advertising Data on the Short Name.
    When we Connect, the Device Name is shown in the first Service (Generic Access 0x1800) on the Characteristic Device Name:

    If you use the AT+DEVNAME command while connected, it will change the Device Name as well:

    After that, you should be able to see on the SmartBond App:

    Finally, when we disconnect we will keep advertising with the last name we used on the AT+DEVNAME command.
    If you use the AT+ADVSTOP command to stop advertising, change the Device Name via the AT+DEVNAME command and start advertising with the AT+ADVSTART command, you should see the new device name.

    codeless_5xx_devname.zip

    Kind Regards,
    OV_Renesas

  • This is interesting, I see two names only: CLv2 and CodeLess, never a CLv2-CodeLess. This is on 14531 v_6.380.14.22 by the way. I'll have to investigate why that is. I wanted to figure out a way to rename both.

  • Hi There,

    Thank you for the response.
    In Codeless SDK v6.380.14.22 we had set the USER_DEVICE_NAME as CodeLess and we have not inserted the Short Name into the Advertising Data. 
    Where did you see the CLv2 name on this CodeLess version?
    Are you facing any issues with the AT+DEVNAME command on CodeLess SDK v6.380.16.55?

    Kind Regards,
    OV_Renesas

  • The library I'm using to communicate with the device has two values: name (defined as "Device name if present") and localName (defined as "User friendly name of device"). 

    name returns CLv2 and localName returns CodeLess. Ideally I was hoping to rename both.

    I admittedly haven't yet tried implementing AT+DEVNAME, I'll soon try. I just wanted to ask ahead of time to try to further my knowledge of this. 

Reply
  • The library I'm using to communicate with the device has two values: name (defined as "Device name if present") and localName (defined as "User friendly name of device"). 

    name returns CLv2 and localName returns CodeLess. Ideally I was hoping to rename both.

    I admittedly haven't yet tried implementing AT+DEVNAME, I'll soon try. I just wanted to ask ahead of time to try to further my knowledge of this. 

Children
No Data