2 Replies Latest reply on Sep 30, 2014 9:42 AM by ArvindS_76 Branched to a new discussion.

    When does bleprofile_sendNotification() actually send?

    userc_3543

      I am working on a timing-critical project where the notifications should be sent in as close to real-time as possible. My question is, when I call bleprofile_sendNotification(), does the system wait until the next connection interval to send the notification, or does it try to send it immediately?

       

      If the former, how can I tell when the notification is actually sent before I send another one with new data? Is there a callback or a flag I can check or something?

       

      Since I am basically just implementing a serial "virtual wire", when I update the characteristic data and send the notification, I need to wait for the client to read that data before I overwrite the characteristic data with new data in the stream. New data in the stream is read every 1ms or so, but the connection interval is only 7.5ms-20ms, so I'm trying to understand the timing considerations so I don't lose packets. For instance if I receive new data from the stream and write it to the characteristic value, will I overwrite the previous notification that is still waiting for the next connection interval before it sends?

       

      Alternatively, I'd like to sync up my fine timer or other callback so it is called right before a connection interval, so I can make sure the maximum amount of data is sent each connection interval. Is there a way to register a callback to happen every connection interval?

        • 1. Re: When does bleprofile_sendNotification() actually send?
          MichaelF_56

          I will ask the developers to respond.

          • 2. Re: When does bleprofile_sendNotification() actually send?
            ArvindS_76

            > when I call bleprofile_sendNotification(), does the system wait until the next connection interval to send the notification, or does it try to send it immediately?

            Data can be exchanged over the air between the devices only during connection events, which are connection intervals apart (more than one packet can be exchanged per connection interval - there are some threads in the forum that explain this). App calling bleprofile_sendNotification() and that packet being sent over are the air are asynchronous.

             

            > If the former, how can I tell when the notification is actually sent before I send another one with new data? Is there a callback or a flag I can check or something?'

            There isn't one. The packets you send with bleprofile_sendNotification() are enqueued by the FW (the default queue size is 15 packets). Use blecm_getAvailableTxBuffers() [see speed_test sample app for usage] to check if you have space to enqueue one more. When the peer device acknowledges the packet (this is a baseband ack) the packet at the front of the queue will be released (making space for one more) and the next packet in the queue will be sent.

             

            > when I update the characteristic data and send the notification, I need to wait for the client to read that data before I overwrite the characteristic data with new data in the stream.

            Have you considered breaking up the data into chunks of 20 bytes and sending the data in notifications instead?

             

            > New data in the stream is read every 1ms or so, but the connection interval is only 7.5ms-20ms, so I'm trying to understand the timing considerations so I don't lose packets.

            If the data rate that is coming in is higher than about 80kbps or so, you will drop packets because that is the max rate you can transfer over the air using notifications (see speed_test sample app). If it is lower than this, then you have to packetize the stream of bytes into 20-byte packets that will fit into notifications.

             

            > For instance if I receive new data from the stream and write it to the characteristic value, will I overwrite the previous notification that is still waiting for the next connection interval before it sends?

            No. Packets are enqueued into a transmit queue. If you enqueue more than the queue will hold, then newer packets will be dropped.

             

            > Alternatively, I'd like to sync up my fine timer or other callback so it is called right before a connection interval,...

            This is available only on 20736/7 with SDK 2.1.x (not with 20732 and SDK 1.1). See Wiced-Smart/tier2/brcm/libraries/inc/application_poll_notification.h and the wiced_sense (see WICED Sense blog by JT) application for usage.

            1 of 1 people found this helpful