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.

RTOS/CC2640R2F: CC2640R2F: Disabling the advertisements

Part Number: CC2640R2F

Tool/software: TI-RTOS

Hello Guys,

I am trying to implement a application where the system goes from non connectable mode to connectable mode on a button press. to change these i will have to change the advertising parameters, since I m using BLE 4.2, I will have to stop the advertisement and chnage the parameters and then go online again. So when I am doing this, in the function 

GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &advertEnabled);

here advertEnabled is FALSE, and the system goes to an infinite loop in this function which inturn calls up  GAP_EndDiscoverable, How can I avoid these. Are there any other ways to get around this particular type of application? 

Also, I am able to turn on the advertisement after the button press but not able to disable it. 

Thank you.

Harsha

  • Hi Harsha,
    You are correct that you will need to stop/update/start advertisements in BT4.2 in order to switch advertising data. Could you share your implementation or describe how/where you have coded it?

    For BT5, it's possible to use advertisement sets as described in the users guide;
    dev.ti.com/.../gap.html
  • Hey Joakim.

    I am trying to implement this application where a system is beaconing and on a pin interrupt the advertisement is changed to connectable adv, and the central can connect to the peripheral. I am posting a semaphore on a pin interrupt to the task that is calling a function that changes the advertisement parameters. In this function where i am changing the advertisement I m trying to stop the adv, but then the system is going to infinite loop in the function GAPRole_SetParameter(GAPROLE_ADVERT_ENABLED, sizeof(uint8_t), &advertEnabled); this function inturn calls GAP_EndDiscoverable() so in here it enters the infinte loop, however i have noticed that the advertisement does stop, but after that none of the code runs.

    Regards,
    Harsha
  • Hi Harsha,

    There shouldn't be any infinite loops. Are you calling this API from the button callback? The only runtime context where you can call stack APIs is from the Task context. So in case you are calling SetParameter from a Swi or Hwi you need to send a message or event to your task function, and call SetParameter there instead.

    Best regards,
    Aslak
  • Hey,

    I am using it in a task context, but not in the SBP task, but my own task. Should I consider setting an event in the SBP task and then set the parameters there?

    Regards,
    Harsha
  • Hi Harsha,

    If you do it from your own task you need to register your task with ICall. Please see the developer's guide about it: dev.ti.com/.../creating-a-custom-bluetooth-low-energy-application.html and about ICall in general: dev.ti.com/.../the-application.html

    Alternatively yes, it's probably easier to have just one task that deals with the stack, and your own task that deals with the fun and profitable stuff.

    Best regards,
    Aslak