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.

BLE modifying scanRspData

Hi all,


I'm using the "SimpleBLEPeripheral" example and trying to change the scanRspData value through the execution of my application, but I find trouble doing so.

It seems I can only modify scanRspData during the "SimpleBLEPeripheral_Init" process, but my intention is changing it during the "SimpleBLEPeripheral_ProcessEvent" section of the code.

Many thanks in advance. Best regards,

Arturo

  • Hi,

    You can change it easily. 

    Change the array value in "SimpleBLEPeripheral_ProcessEvent" and then use following function :

    //Set parameters
    GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( scanRspData ), scanRspData );

    It'll change parameters. 

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

    Press "Verify" button if your question is answered.

  • Hi,

    Many thanks for your response, but I'm afraid that's the approach I'm using and it's not working properly; when the device does the following advertising its name is the same as it was before.

    As I tried to express yesterday in my original inquiry, I have noticed that when using that approach on the "Initialization" part of the code it seems to work (the name updates properly), but I need to modify it in the "SimpleBLEPeripheral_ProcessEvent" section.

    //

    * @fn SimpleBLEPeripheral_ProcessEvent

    *
    * @brief Simple BLE Peripheral Application Task event processor. This function
    * is called to process all events for the task. Events
    * include timers, messages and any other user defined events.

    Thanks again for your help. 

  • Hi,

    I am using almost same approach and for me it works fine. 

    Please check that length and parameters are ok. 

    Sometimes if device is paired with phone it may show same name. Try to check with BLE device monitor. 

    Can you post that code snippet where you are changing name?

  • Hi,

    Below you can find a piece of code that shows what I'm trying to accomplish and how, maybe it helps to clarify 

    the issue I'm facing:

    // When "new periodic event", modify device name

    if ( events & NEW_PERIODIC_EVT )
    {
                        if(scanRspData[9] == 0x30)
                        {
                                     scanRspData[9] = 0x31; //modify last character to "1"
                         }
    else
                         {
                                     scanRspData[9] = 0x30; //modify last character to "0"
                         }
    GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( scanRspData ), scanRspData );
    osal_start_timerEx( simpleBLEPeripheral_TaskID, NEW_PERIODIC_EVT, NEW_PERIODIC_EVT_TIMEOUT );
    return (events ^ NEW_PERIODIC_EVT);
    }

  • Hi,

    When do you set an event for first time? what is timeout period?

    If you want to change name continuously during advertisement, I think it's difficult. 

  • Hi again,

    Yes, that's what I'm trying to accomplish: changing the name continuously during advertisement. After trying in a lot different ways, I'm not able to do so yet. It seems at certain point the device stucks with the name it was given and it is not possible to change it any further.

  • Hi,

    Name change is possible but not during advertisement.

    Reason may be that central device/phone may pick one name once and may not show change in name because MAC address will be same for different name. 

    Same happens when your device is paired with central. Even if you change  name of device, name change will not reflect  as device name and MAC is stored in database and it'll pick name from database first.

  • Maybe you have ruled these out already, but I think you are running into one or both of these issues.

    First, I don't have access to the BLE stack source, so I can't confirm this. However, it would be reasonable to me that trying to change the advertising data while advertising is active would not be permitted. Therefore, you may want/need to disable advertising, post the changed data, then turn advertising back on.

    The second issue is that the mobile devices you are connecting to cache data about the devices they have seen and will not update the data unless your device or the application on the mobile device commands it to or flushes the cache. I found this to be the case with Android devices specifically. I haven't had much test time with iOS, but I am reasonable sure it caches also.

    Hope this helps.

  • Have you verified that the name hasn't changed with a packet sniffer? Like Maulik says, a central device often "remembers" a peripheral's name, so an app may not show the new name depending on how its coded

  • Hi everyone,

    Many thanks for your interest and advice. I had already done some test turning on/off the advertising, but in the end I have tried something in the line of what is shown in this other thread:

    http://e2e.ti.com/support/wireless_connectivity/f/538/t/72681.aspx

    The solution proposed there by GregS seems to work fine.