User Changed Device Name

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

In our design the user may change the device name with a custom name, up to 20 characters.

   

This only seems to work if I "reserve" the 20 characters in the GUI dialog for device name.  For instance if the name in the gui is set to "test" and I programmatically change it to "abcdefghij" the name is saved as "abcd".  If I save the name as "testabcdefghij" in the GUI then I can change the name to anything that length or shorter.  I hope that makes sense.

   

 

   

Is this normal?  Seems dodgy.

   

 

   

Rich

0 Likes
1 Solution
Anonymous
Not applicable

Looking at the comments/documentation for the CyBle_GapSetLocalName(), it is stated that the code will cut the name to the same size as the name specified in the component customizer. The maximum name length possible is 248 bytes with a NULL character to signify the end of the string.

   

Hmmm, if you want more control, then you will need to dig into the code a little bit:

   

Look at the source code running in the CyBle_GapSetLocalName() and CyBle_ChangeAdLocalName() functions; The advertisement name is limited in size to the 31 byte length of the advertisement packet, but the scan response packet can be longer I think.

   

The simplest way to get a longer name would be to set the name as being much longer in the component customizer (top design GUI), and then shorten/write it on code startup to what you want to "initialize" with. Then, it will allow you to shorten and lengthen dynamically the way you want. Otherwise, you would need to allocate memory for the name to allow for dynamically lengthening the name past what the static buffer allocates in the component customizer.

View solution in original post

0 Likes
5 Replies
Anonymous
Not applicable

Are you programmatically modifying the length/size of the name when you update it? I believe the string data should have a length value associated with it. If you only change the string and not the length as well, then the name will only display the first "length" characters of the new name.

0 Likes
Anonymous
Not applicable

Thanks for the help.

   

I am setting the local name with:

   

CyBle_Stop();
    CyBle_GapSetLocalName(device_name);
 
    /* Start the BLE Component and register the generic event handler */
    CyBle_Start(GeneralEventHandler);

   

 

   

How do I set the length?

   

 

   

Rich

0 Likes
Anonymous
Not applicable

Looking at the comments/documentation for the CyBle_GapSetLocalName(), it is stated that the code will cut the name to the same size as the name specified in the component customizer. The maximum name length possible is 248 bytes with a NULL character to signify the end of the string.

   

Hmmm, if you want more control, then you will need to dig into the code a little bit:

   

Look at the source code running in the CyBle_GapSetLocalName() and CyBle_ChangeAdLocalName() functions; The advertisement name is limited in size to the 31 byte length of the advertisement packet, but the scan response packet can be longer I think.

   

The simplest way to get a longer name would be to set the name as being much longer in the component customizer (top design GUI), and then shorten/write it on code startup to what you want to "initialize" with. Then, it will allow you to shorten and lengthen dynamically the way you want. Otherwise, you would need to allocate memory for the name to allow for dynamically lengthening the name past what the static buffer allocates in the component customizer.

0 Likes
Anonymous
Not applicable

Ok, I thought the length was parameter in the API somewhere.  I will do as you suggest and leave spaces in the gui allocate space.  Clunky but seems the least convoluted.

   

Thanks for the help

   

 

   

Rich

0 Likes
Anonymous
Not applicable

Unfortunately not 😞

   

For most of the hardware/barebones customization you tend to need to write software to handle the underlying stack interactions with the BLE stack/module. Unfortunately, this is also pretty confusing/complicated at parts and thus why I suggested the name change in the component creator to speed it up. 

0 Likes