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: Can MAC address be read within codebase?

Part Number: CC2340R5

Hi TI members,

We would like to use each of the MCU's MAC address to configure its scanned name.

How can we read the MAC address and assigned it to the scanResData1 in ti_ble_config.c / ti_ble_config.h ?

Thanks.

BR,

  • Hi,

    Thank you for reaching out. We will look into your query and get back to you as soon as possible.

    Best Regards,

    Jan

  • Hello YW, 

    Thanks for the question. Here is a link to the HCI_ReadBDADDRCmd API. This API will allow you to read the Bluetooth Address (MAC Address). Can you test this and let me know if it works for you? 

    Also, the Bluetooth address is provided and accessible through the scan response. Is there a reason you don't want to access the address through there? Let me know. 

    Thanks, 

    Isaac

  • Hi,

    Thanks for the advice, does data_stream project support HCI_ReadBDADDRCmd ?

    the Bluetooth address is provided and accessible through the scan response. Is there a reason you don't want to access the address through there?

    -> How to access the address through the scan response? Can you give us an example?

    Besides, where in the codebase can I modified the BLE scanned name in runtime? Is it the same as this thread?

    Thanks,

    BR,

  • Hello YW, 

    The data_stream project does support the HCI_ReadBDADDRCmd. 

    The scan response is available through BTool and the UART terminal. The Bluetooth address will be displayed on the serial terminal through UART. This is if the project is using two boards to connect. 

    For the modifying the bluetooth address in runtime, I will have to get back to you tomorrow with more information. 

    Thanks, 

    Isaac

  • Hi,

    Thanks for the clarification.

    Now our question left is how to modify the advertising data in runtime.

    I looked up the user guide in the SDK and found this:

    I now changed the scanResData1 under app/Profiles/app_dev_info.c.

    1. Should I use the GapAdv_loadByHandle API to update the new advertising data?

    2. How should I add these codes in app_dev_info.c? (or somewhere else TI would suggest)

    Thanks.

    BR,

  • Hello YW, 

    I am still looking into the ability to modify the Bluetooth address in runtime. Sorry for the inconvenience. 

    For your next question, the snippet you provided is exactly what you should do. The only thing that you should know is that the function needs to have access to the gap advertising handle and the advertisement data buffer (advertdata). As long as your program has access to these two items, the GapAdv_loadByHandle API will work. 

    Thanks, 

    Isaac

  • Hi,

    Thanks for helping.

    I still got some further questions:

    1. Before calling GapAdv_loadByHandle, do I need to call GapAdv_create() and GapAdv_setVirtualAdvAddr() before it?
    Since I saw this paragraph:

    But I supposed GapAdv_create() and GapAdv_setVirtualAdvAddr() had been called somewhere else.

    (but I didn't know where to find them, can you help to provide where they are?)

    2. Is it a proper idea to put these GapAdv APIs in app/Profiles/app_dev_info.c? Since I wanted to use its scanResData1 directly.

    But would there be any concern from TI's side if I do so?

    Thanks.

    BR,

  • Hello YW, 

    I don't think there would be any concern for implementing this, but I am going to reassign this thread to a topic expert to help you more. Sorry for the inconvenience. 

    Thanks, 

    Isaac

  • Hi YW,

    Q: How to modify the Bluetooth address in runtime

    Can you give us a bit of context on the reason why you would like to advertise with two different addresses?
    Can you also comment whether you have considered creating two advertising sets, each one configured to use a different address? It would then be possible to turn on/off each one of the advertising sets separately.
    Last but not least, I understand you are looking at using GapAdv_setVirtualAdvAddr(), however such function does not work on all the types of advertising sets.

    Q: Before calling GapAdv_loadByHandle, do I need to call GapAdv_create() and GapAdv_setVirtualAdvAddr()

    Generally speaking, I would recommend to leverage the BLEAppUtil framework functions.
    Otherwise, to answer your question, advertisement sets should be created using GapAdv_create (or BLEAppUtil_initAdvSet when using the BLEAppUtil framework) before calling the other functions.
    GapAdv_setVirtualAdvAddr has to be called after GapAdv_create, but it does not matter whether it is called before or after GapAdv_loadByHandle.

    Q: Is it a proper idea to put these GapAdv APIs in app/Profiles/app_dev_info.c?

    In my humble opinion, it would not be ideal, as the code architecture of the project would be a bit difficult to follow (I mean, you would have code altering the advertisement in several places which could make further code updates difficult). However, I do not know your project and you may think differently.
    My recommendation would be to leverage the BLEAppUtil framework as much as possible (e.g. BLEAppUtil_initAdvSet, BLEAppUtil_advStart, BLEAppUtil_advStop) and call it from file app/app_peripheral.c

    I hope this will help,

    Best regards,

  • Hi Clément,

    Can you give us a bit of context on the reason why you would like to advertise with two different addresses?

    -> We are not going to advertise with two different addresses but advertise with only one configurable addresses.

    We want every single MCU has its own MAC as its BLE name, rather than a fixed name that every MCU shares the same.

    We are just trying to update the advertising data of the advertising set that have already been created. (Somewhere that I didn't see in our codebase, though)

    But now we have come up with a solution, we modify the scanResData1 in app/app_peripheral.c before the scanResData1 was first called in advSetInitParamsSet_1 in TI's original codes.

    Then, we found the BLE name successfully changed as we expected.

    I think we can now bypass the need to create a new advertisement set.

    Anyway, we really appreciate you guys' help on this topic.

    BR,

    YuWen

  • Hi YuWen,

    Thank you for the details provided! I was about to suggest exactly the same as you have implemented.

    Glad it is now working!

    Kind regards,