3 Replies Latest reply on Mar 17, 2017 7:06 AM by e.pratt_1639216

    Fixed Number Advertisement Packets

    e.pratt_1639216

      Has anyone worked with sending only a fixed number of advertisement packets from the radio before?

         

      I tried using the cypress function CyBle_GappSetNumOfAdvPkts(&cyBle_discoveryModeInfo,3) to send 3 packets, but it seems to only want to send one. Even trying to count the number of advertisement start_stop messages didn't work for manually sending each packet.

         

      Does everyone use timers for advertising for a flat amount of time instead? I would think there is a way to do a fixed number of packets; e.g exactly 7 or something.

        • 1. Re: Fixed Number Advertisement Packets
          yssu

          Hi! The CyBle_GappSetNumOfAdvPkts() API sends a fixed number of advertisement packets. In your case, I believe you are advertising on all 3 channels: 37, 38, 39. Since, you have set the count to 3, the API will send 1 packet on these 3 channels in a single advertisement event and stop advertisement. If you see the air logs(using a sniffer), you will be able to see that there were 1 packet each on channel 37, 38  and 39.

             

          I reckon you would want to use the count as 9 = 3 times * 3 channels, or you could choose to advertise only on a single channel.

          • 2. Re: Fixed Number Advertisement Packets
            e.pratt_1639216

            Hello yssu,

               

            How do I tell when it has finished sending all three packets?

               

            I tried using the CyBle_GappSetNumOfAdvPkts() with a count of 3 (sniffing it using the CySmart USB dongle), but if I try to detect when the packets have finished with the CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP event and a DISCONNECTED state, the unit then seems to disconnect as soon as it has sent the first packet.

               

            Is there a different way I should be checking to see when the unit has finished sending the packets? Polling the BLESS state in main for example?

               

            It seems easy enough to start the fixed-packet-number of advertisements, but using the usual checking of cyble_state when receiving an advertisement start/stop event makes it disconnect as soon as it starts. 

            • 3. Re: Fixed Number Advertisement Packets
              e.pratt_1639216

              For those interested:

                 

              the CyBle_GappSetNumOfAdvPkts() function works as intended, but since the cyble_blessstate does not seem to be accurate in the event handler, I had to implement my own boolean that keeps track of whether the advertisement_start_stop event is a start or a stop event.

                 

              Once I started keeping track of the state in main, it made the code work much more reliably.

              1 of 1 people found this helpful