5 Replies Latest reply on Aug 4, 2017 10:02 AM by epr_1639216

    User Changed Device Name

      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.





        • 1. Re: User Changed Device Name

          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.

          • 2. Re: User Changed Device Name

            Thanks for the help.


            I am setting the local name with:


                /* Start the BLE Component and register the generic event handler */




            How do I set the length?





            • 3. Re: User Changed Device Name

              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.

              • 4. Re: User Changed Device Name

                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





                • 5. Re: User Changed Device Name

                  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.