CyBle_GapSetLocalName doesn't affect Device Name characteristic

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

cross mob
euggersh
Level 5
Level 5
5 sign-ins First solution authored 50 replies posted

Since my application needs to set the BLE device name programmatically and CyBle_GapSetLocalName() can only set a name that's no longer than the name set at compile time, I have a long placeholder name in the configuration of the BLE component.

The name that's set from CyBle_GapSetLocalName() appears correctly in the scan response packet.  However, reading the Device Name characteristic (0x2A00) in the GAP service (0x2800) returns the original placeholder name.

Is this expected behaviour?  If so, how can I change the value of the Device Name characteristic to match the name I'm setting in CyBle_GapSetLocalName().  Or, if this is a bug in the CyBle_GapSetLocalName() implementation, when will it get fixed?

Thanks.

0 Likes
1 Solution
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

CyBle_GapSetLocalName API copies the new name to device name characteristic. If the name contained in the parameter of CyBle_GapSetLocalName is shorter than the length from the customizer, the end of the name is indicated by a NULL octet (0x00). In your case, the read value stands for 'Short name' and ends in NULL, as expected.

SetlocalName_v2.png

View solution in original post

5 Replies
lock attach
Attachments are accessible only for community members.
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

CyBle_GapSetLocalName (const char8 name[]) description in BLE component datasheet says; If the characteristic length entered in the component customizer is shorter than the string specified by the "name", the local device name will be cut to the length specified in the customizer.

I am unable to recreate the name mismatch issue at my end. Please test attached project at your end and share your observation. Also, can you attach a simple project that reproduces the issue?

SetlocalName.png

GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

CyBle_GapSetLocalName API copies the new name to device name characteristic. If the name contained in the parameter of CyBle_GapSetLocalName is shorter than the length from the customizer, the end of the name is indicated by a NULL octet (0x00). In your case, the read value stands for 'Short name' and ends in NULL, as expected.

SetlocalName_v2.png

So it sounds like there's a bug in the CyBle_GapSetLocalName() API where it fails to zero out the rest of the characteristic beyond the first 0x00 byte which terminates the string.  Will this get fixed, or is there a way for me to set the value of the characteristic myself to get around this bug?

0 Likes
GeonaP_26
Moderator
Moderator
Moderator
250 solutions authored 100 solutions authored 50 solutions authored

If you would like to update the length of device name characteristic before CyBle_GapSetLocalName API, please use following code snippet.

CYBLE_GATT_DB_ATTR_GET_ATTR_GEN_LEN(cyBle_gaps.deviceNameCharHandle) = sizeof(localName);

if(CYBLE_ERROR_OK == CyBle_GapSetLocalName(localName))

     // Application code

}

Note:  If the characteristic length entered in the component customizer is shorter than the string specified by the "name", the local device name will be cut to the length specified in the customizer.

0 Likes