This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: CC2340R5 launchpad

Part Number: CC2340R5
Other Parts Discussed in Thread: SYSCONFIG,

Tool/software:

Hi I want  to read the BD address of my device ad append it to the attDeviceName and start advertisement but I am unable to do that because attDeviceName is mentioned as uint8_t and I cannot change ti_ble_config.c and cannot use any functions like snprintf to append the address to attDeviceName. 

Please help me as I am new to TI.

  • Hi, 

    Thank you for reaching out. 

    You can find a similar topic discussed here: https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1254208/cc2340r5-can-mac-address-be-read-within-codebase 

    I hope this will help,

    Best regards, 

  • Hi,

    My usecase is different. I want to change the attDevicename I am setting through the sysconfig and append BD address of device to the attDeviceName and advertise it. Please help me as I am not able to figure out on how to do it

  • Hi,

    Is this simply to have the address within the actual advertisement itself? If so, then it would likely be easier to append the address to the advertising data during runtime. Would this work for your use-case? If not, then an alternative would be to get the address before setting up attDeviceName and appending it early on in boot.

    Best Regards,

    Jan

  • Hi,

    In sysconfig I have defined the attDeviceName as BLE_. Then before initializing the stack using BlEAppUtil_init api I want to fetch the device address and append it to the attDeviceName BLE_ then pass it to the appMainParams that will be using by the BLEAppUtil_init api. I defined a function where I am using the below line of code

    uint8_t *devAddr = GAP_GetDevAddress( TRUE ); and then doing a memcpy to put the address after the BLE_ attDeviceName. Then I am calling the function in appMain before calling stack init API but nothing is happening. I cannot understand what is going wrong as there is no error.

    I request you to please give an example on how to do this so that I get a hang of it

  • Hi,

    If I am not mistaken the Gap_GetDevAddress() function requires that the BLE stack already be initialized for it to work properly. If you move the API call after the stack has been initialized, does it work?

    Best Regards,

    Jan

  • Hi,

    Thanks for the info. Currently facing some issues with CCS. I will try this method and update you. Meanwhile if you can try and let me know if that works, it will really be helpful.

  • Hi,

    By default, the basic_ble example does call that API after the stack is initialized:

    Best Regards,

    Jan

  • I have written this function where I have appended the address in attDeviceName and then calling it after initializing the stack but nothing  is changing. Whatever name I have defined in sysconfig, with that itself advertisement is happening. Nothing else is happening

  • Hi,

    Based on the code you have written it seems you are retaining the attDeviceName and adding the address at the end. Have you added some dummy values to the attDeviceName variable in Sysconfig? Something like:

    attDeviceName = "myDeviceName=123456" or something along these lines.

    I would recommend doing something like that to ensure you do not go out of bounds of the memory allocated to that variable. The BLEAppUtil_convertBdAddr2Str assumes you are giving it an array of length 6 that only contains the hex values of the address. So I do not expect the function to work properly the way you are attempting to do so.

    I would recommend adding a custom function that takes the address array, converts it to a string and appends it to the attDeviceName (after ensuring the attDeviceName string is long enough to accommodate the name + the address. Afterwards, try using the MenuModule_printf() to print the newly appended string to see if we have updated it correctly.

    Best Regards,

    Jan

  • Hi ,

    I am able to make it work successfully by updating the scanResData1

    uint8_t *addr = NULL;
    addr = GAP_GetDevAddress(TRUE);
    uint8_t num = 6;
    char *arr = BLEAppUtil_convertBdAddr2Str(addr);
    memcpy(&scanResData1[8],&arr[8],num);
    advSetInitParamsSet_1.scanRespData = scanResData1;

    The below line of code helped me to update address to the attDeviceName and it is working as per my expectations.

    The intention behind doing this is we will have many devices in production so we want unique name based on the BT address of each device thats why we want to write a code in a way such that each device gets a unique name rather than one name for many production hardware

  • My next issue is I want to set custom 128 nit service and characteristics and not expose it in advertisement data. I will register it and it can be viewed by central only after connection.

    The example given shows I can only update it in sysconfig advertisement parameters. Pleas help me to know how and which API will help me to register a custom service not exposed in advertiement hanlde?

  • Hi,

    Glad to hear you were able to resolve the issue! Thank you for sharing the solution! You should be able to set the UUIDs displayed in the advertisement manully through sysconfig and this does not need to correspond to the actual services used by the example. If you do not wish to advertise a specific service UUID, then do not add it to the UUID section of the advertising payload in SysConfig.

    Best Regards,

    Jan

  • Hi,

    If I do not add the UUID in advertising payload of Sysconfig, then where and how should I define it?

    Can you please show some examples?

    I want to define the services and characteristics and register the service using service_register API 

  • Hi,

    I am a bit confused. Would you like to add the UUID to the advertising payload? If so, then you can do this through sysconfig. If you do not wish to add it, then you may leave it blank. Depending on the profile / service you are implementing, you do not need to also advertise the UUID of that profile/service.

    Best Regards,

    Jan

  • Hi, 

    Everything is working properly.

    If I have to define multiple primary services, can I add it in one attribute table or I have to make separate attribute tables for that? 

    Currently I added 2 primary services in one attribute table but the second service is not discovered by the central.

  • Hi,

    Understood, thank you for clarifying. You have two options. You could add it all to a single table or have it as separate tables. Can you connect to the CC2340R5 with the SimpleLink Connect app and check if the services are both showing up there?

    Best Regards,

    Jan

  • Hello,

    It is working properly now. Some modifications in declaration was done.

    I have one more doubt.

    BLEAppUtil_init(&criticalErrorHandler, &App_StackInitDoneHandler,
    &appMainParams, &appMainPeriCentParams) - calles the stackInitDoneHandler inside which we will start_Peripheral(), start_Connection(), start_Pairing(), start_GATT().

    My problem is I want to enable everything separateley one by one after calling bleapputil_init() . 

    1. First I do stack init

    2. Then I do start_Peripheral() - defined and called from a different function

    3. Then I do start_Connection()

    But I cannot understand how to do. If I define and call these functions separately and call after bleapputil_init, its not working. Is there any way out to decouple these initializations from stackInitDoneHandler callback and call everything separately?

  • Hi,

    Glad to hear you were able to fix the issue! You should be able to call the start() functions seperately. However, you must ensure that they are called from within  the BLE Task context. You should be able to use the bleapputil_invoke functions to guarantee these functions are called from the proper context.

    Best Regards,

    Jan

  • Hi,

    I used like this but not getting any result.

    Kindly provide an example.

  • Hi,

    Thank you for clarifying. My guess is that the enableAdvertisement() function is being called before the BLEAppUtil_init() has finished. Can you try  adding the call to enableAdvertisement() at the end of the App_StackInitDoneHandler? Or potentially pending on a semaphore after stackInit() and posting the semaphore at the end of the App_StackInitDoneHandler?

    Best Regards,

    Jan

  • Hi,

    Its working syccessfully.

    Thanks for the support

  • Hello Jan,

    I have defined 2 128 bit services and put them in 1 attribute table and registered the service. However from phone to phone the service discovery is varying. I have oneplus 10 pro in that only 1 service is getting discovered. In Iphone both services are getting discovered, in other android phones both services are getting discovered. In one samsung only the first service is getting discovered? Why is this variation happening? Please help. However If I define the services in 2 different tables  its working but I want it in one table only.

  • Hi Jan,

    Also I want to have more than 4 characteristics but in sysconfig it shows NV can store only 4 characteristic at max per bond. What am I supposed to do in that case?

  • Hi,

    The discrepancy could be due to an issue with the OnePlus device as it is not occuring on the other two. Can you confirm what Android version the OnePlus phone is using as well as the Samsung phone? You should be able to have more than 4 characteristics, but if I am not mistaken their values wont be saved with the bond after disconnection.

    Best Regards,

    Jan

  • Hi Jan,

    but if I am not mistaken their values wont be saved with the bond after disconnection: Can you please elaborate this statement because my application needs more than 4 characteristics throughout its lifecycle. 

    Also, why android version will play a role in discovering services differently? Is there anything I need to modify in the stack?

  • Hi Jan,

    I need your support to add 2 128 services in one attribute table and register it and let me know what is happening. Also, what does this API do GATTServApp_AddService()? I used this to add the second service but it is not getting discovered by the central

    Please help me

  • Hi,

    We have seen in the past that specific Android versions on specific build versions with certain phones may not behave exactly as expected during a BLE connection which is why it may be helpful to know which Android device is being used. I believe the max characteristics for bonding will just be the number of characteristics saved locally when the disconnection occurs. You can still have more than that number, but will need to re-read them once connected or save them outside of the GapBondMgr.

    It should be possible to have multiple services. Can you reference the following GATT table generator? The provided generator is for the F2 SDK and not the F3 SDK, but the vast majority of the code should be reusable.

    https://dev.ti.com/tirex/content/simplelink_academy_cc13xx_cc26xxsdk_6_40_00_00/modules/ble5stack/ble_01_custom_profile/ble_01_custom_profile.html#example-service-generator

    Can you try creating a single service and seeing if your code matches what the output  provides?

    Best Regards,

    Jan

  • Hi Jan,

    I am using Android version 14 and Oneplus 10 pro 5G

    My problem is I want to add 2 128 bit services in one attribute table. Currently, I have added 2 primary services in 2 attribute tables and I am registering it separately. It is working properly. 

    When I add 2 primary services in one attribute table, then the second service is not getting registered. All the examples show only one service in 1 attribute table.

    Also, I need  5 characteristics to be saved in the bond table and be there througout my application.

    Please tell why is there a limit to put only 4 characteristics onto the bond table?

  • Hi,

    Understood. I think there was some confusion on my side and for that I apologize. It should be fine to keep a service in its separate attribute table. I believe most of our examples implement each service in its own table. For example, the Simple GATT Profile and the OAD services are each in their own tables. Is there a particular reason why you want everything in a single table?

    To be clear, the max number of characteristics refers to the max number of characteristic configurations:

    This refers to the notification/indication setting for each characteristic, so you can have five or more characteristic but the characteristic configuration you can have saved and persist between connections is for four of those. You are not limited in the characteristic amount by this.

    Best Regards,

    Jan

  • Hi Jan,

    Thanks a lot for the information. As suggested by you, I will use 2 services in its own table. 

    Thanks a lot for the clarification Jan. I will add more characteristics and set only 4 notificatio n/indication configuration for a service and see the result. If I face issues, will let you  know Jan.

  • Thanks Jan,

    Everything is working properly now. Initially I was setting notification property for 5 characteristics thats why it was behaving like that. I changed it and now its working.

    Thanks a lot Jan.

  • Hi,

    No problem! Glad we were able to resolve this issue together! If you run into any further issues or have any additional questions then feel free to open a new thread and we will be happy to help!

    Best Regards,

    Jan