Public Address

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

cross mob
MiEl_3261856
Level 2
Level 2
First like given

Hi,

I need to publish my public address in the device name so that I can connect to my IOS app .

I'm currently able to publish the address as follows: "00:05054885?" and it able connect to the app

this the code i use:

                cyBle_deviceAddress.bdAddr[0] = (uint8)bdAddrLoc;

                cyBle_deviceAddress.bdAddr[1] = (uint8)(bdAddrLoc >> 8u);

                cyBle_deviceAddress.bdAddr[2] = (uint8)(bdAddrLoc >> 16u);

               

            

               

        char DeviceName[16] = "NM2 ";

        // convert the values to ascii and store in the device name field.

        DeviceName[4] = ((cyBle_deviceAddress.bdAddr[5] & 0xF0) >> 4) + 48 ;

        DeviceName[5] = (cyBle_deviceAddress.bdAddr[5] & 0x0F) + 48 ;

        DeviceName[6] = ((cyBle_deviceAddress.bdAddr[4] & 0xF0) >> 4) + 48 ;

        DeviceName[7] = (cyBle_deviceAddress.bdAddr[4] & 0x0F) + 48 ;

        DeviceName[8] = ((cyBle_deviceAddress.bdAddr[3] & 0xF0) >> 4) + 48 ;

        DeviceName[9] = (cyBle_deviceAddress.bdAddr[3] & 0x0F) + 48 ;

        DeviceName[10] = ((cyBle_deviceAddress.bdAddr[2] & 0xF0) >> 4) + 48 ;

        DeviceName[11] = (cyBle_deviceAddress.bdAddr[2] & 0x0F) + 48 ;

        DeviceName[12] = ((cyBle_deviceAddress.bdAddr[1] & 0xF0) >> 4) + 48 ;

        DeviceName[13] = (cyBle_deviceAddress.bdAddr[1] & 0x0F) + 48 ;

        DeviceName[14] = ((cyBle_deviceAddress.bdAddr[0] & 0xF0) >> 4) + 48 ;

        DeviceName[15] = (cyBle_deviceAddress.bdAddr[0] & 0x0F) + 48 ;

  

        CyBle_GapSetLocalName(DeviceName);

       

            }

             


But I have to translate the symbols ( : , ? ) into letters, I used the following code to get the public address in the correct format and got this : "00A05054885F" but now it does not connect to the application

char inline ReadDataName(uint8_t num){

    char ch = num + 48;

    if(ch > 57){

        ch += 7;

    }

    return ch;

}

---------------------------------------------------------------------------------------------------------------------------

                cyBle_deviceAddress.bdAddr[0] = (uint8)bdAddrLoc;

                cyBle_deviceAddress.bdAddr[1] = (uint8)(bdAddrLoc >> 8u);

                cyBle_deviceAddress.bdAddr[2] = (uint8)(bdAddrLoc >> 16u);

               

            

        char DeviceName[16] = "NM2 ";

        // convert the values to ascii and store in the device name field.

        DeviceName[4] = ReadDataName((cyBle_deviceAddress.bdAddr[5] & 0xF0) >> 4) ;

        DeviceName[5] = ReadDataName(cyBle_deviceAddress.bdAddr[5] & 0x0F)  ;

        DeviceName[6] = ReadDataName((cyBle_deviceAddress.bdAddr[4] & 0xF0) >> 4) ;

        DeviceName[7] = ReadDataName(cyBle_deviceAddress.bdAddr[4] & 0x0F)  ;

        DeviceName[8] = ReadDataName((cyBle_deviceAddress.bdAddr[3] & 0xF0) >> 4) ;

        DeviceName[9] = ReadDataName(cyBle_deviceAddress.bdAddr[3] & 0x0F)  ;

        DeviceName[10] = ReadDataName((cyBle_deviceAddress.bdAddr[2] & 0xF0) >> 4)  ;

        DeviceName[11] = ReadDataName(cyBle_deviceAddress.bdAddr[2] & 0x0F)  ;

        DeviceName[12] = ReadDataName((cyBle_deviceAddress.bdAddr[1] & 0xF0) >> 4) ;

        DeviceName[13] = ReadDataName(cyBle_deviceAddress.bdAddr[1] & 0x0F) ;

        DeviceName[14] = ReadDataName((cyBle_deviceAddress.bdAddr[0] & 0xF0) >> 4) ;

        DeviceName[15] = ReadDataName(cyBle_deviceAddress.bdAddr[0] & 0x0F)  ;

      

        CyBle_GapSetLocalName(DeviceName);

       

            }

Does anyone have an idea what could be the source of the problem?


Thanks

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Mich,

You can use the CyBle_GapSetLocalName() API. The code attached does the hex to ascii conversion and later assigns the address as name.

Thanks,

Ranjith

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

CyBle_GapSetLocalName(DeviceName); has restrictions on when it can be called IIRC, you might need to have the unit not advertising in order to do so. Try calling this function after CyBle_Start() but before you call any other functions to ensure it is not an invalid state causing the issue.

Most likely it is an issue with your app not handling the raw bytes correctly for the device name. Try seeing if putting fixed/constant characters for the data values works, and test which characters will and won't connect with your app when used in the device name. (For example, *?&%$^#@!():;'"-_=+,.<>/\| etc.)

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Mich,

You can use the CyBle_GapSetLocalName() API. The code attached does the hex to ascii conversion and later assigns the address as name.

Thanks,

Ranjith

0 Likes