AnsweredAssumed Answered

BlueNRG Nucleo Shield Change Advertising Interval

Question asked by pitman.tony on May 24, 2015
Latest reply on May 28, 2015 by pitman.tony
I am making a device that most of the time will be dormant. I want it to advertise as little as possible until an event I am interested in occurs. When that occurs I want it to advertise for a few seconds and then go back into advertising once in a while.

I based my code on the chat example. I have it working to send the advertising information that I want using the Manufacturer Specific Data in the advertising packet.

Initially I set my interval to 5000 (about 5 seconds). I can see it advertising. One problem here is that the advertising is not consistent. Sometimes it advertises after 3 seconds sometimes it takes 20 seconds. That is another problem though.

The main problem is that when the event I am looking for (I use a button press to test) I issue the following commands:

    aci_gap_set_non_discoverable();
    Clock_Wait(100);
    aci_gap_set_discoverable(ADV_NONCONN_IND, 160, 160, PUBLIC_ADDR, NO_WHITE_LIST_USE,0, NULL, 0, NULL, 0, 0);
    Clock_Wait(1000);
    aci_gap_set_non_discoverable();
    Clock_Wait(100);
    aci_gap_set_discoverable(ADV_NONCONN_IND, 5000, 5000, PUBLIC_ADDR, NO_WHITE_LIST_USE,0, NULL, 0, NULL, 0, 0);

When I do this it stops advertising completely. You can see that I am basically issuing the command to stop advertising, then start again using a much smaller interval, then stop again and then finally to go back to 5000 interval.

This doesn't work. Once I issue the aci_gap_set_non_discoverable(); command then no matter what I do after that it never advertises again.

What do I do?

Is there a better way to do this?

I am using the bluenrg_gap_aci.c API that the chat application uses. As far as I can tell it waits until it sends the command before it moves on.

Is there something I need to do to wait for a response from the BlueNRG? I hear about events, but don't know how to watch for them because I don't think the chat example does. It just issues commands and moves on.

Please help.

Outcomes