4 Replies Latest reply on Oct 7, 2014 7:36 AM by ArvindS_76 Branched to a new discussion.

    Connection Event Callback API

    userc_2062

      Hi Broadcom Wiced Folks,

       

      In this thread Arvind mentioned an optional API that provides a callback right before or right after the connection event:

      Re: How best to implement bulk data transport

       

      Is the "optional API available with SDK 2.0" the bt_clock_based_periodic_timer library? 

       

      Specifically Wiced-Smart/tier2/brcm/libraries/lib/20737/bt_clock_based_periodic_timer.a. 

      From the ibeacon examples, I think I see how to include that library in my project (by adding it to APP_PATCHES_AND_LIBS in the makefile), and the bt_clock_based_timer.h has plenty of helpful comments on how to use this API.

       

      --Blake Setlow.

        • 1. Re: Connection Event Callback API
          userc_2062

          Hmm,

           

          Actually, I'm starting to wonder if this "optional API" is actually the application_poll_notification.a file.  But I can't find the appropriate .h file to include for the declarations of:

          blecm_connectionEventNotifiationInit

          blecm_connectionEventNotifiationEnable

          blecm_connectionEventNotifiationDisable

           

          Some direction on how to proceed with this would be helpful.

          --Blake.

          • 2. Re: Connection Event Callback API
            ArvindS_76

            Yes it is application_poll_notification.a.

             

            /// Enable the connection event notification notification mechanism. Needs to be done once in the

            /// app_create function.

            void blecm_connectionEventNotifiationInit(void);

             

            /// Register for notifications from the baseband of upcoming TX opportunities.

            /// \param clientCallback - the callback to be invoked

            /// \param clientContext The context (the UINT32 parameter to clientCallback) that must be passed

            ///                                 back to the callback.

            /// \param offset Number of BT slots before/after the TX opportunity to call the callback. When negative,

            ///                    callback will be invoked before TX and when positive, callback will be invoked after the TX.

            ///                    This has to be an even number of slots (multiples of 1.25mS).

            /// \param defaultPeriod When not connected, period of the callback in BT slots. Has to be an even number

            ///                     of slots. Don't set this to under ~5mS (8 slots).

            /// \param connHandle - the connection handle of the connection for which we need the notifications.

            void blecm_connectionEventNotifiationEnable(void (*clientCallback)(void*, UINT32), UINT32 clientContext, INT16 offset,

                    UINT16 defaultPeriod, UINT32 connHandle);

             

            /// Stop the connection event notification.

            void blecm_connectionEventNotifiationDisable(void);

             

             

            Here is some pseudo-code:

             

            void app_create(void)

            {

                // All other app initialization.

             

                // Initialize the connection event notification mechanism.

                blecm_connectionEventNotifiationInit();

            }

             

            void app_connection_up(void)

            {

                // All other connection up activity.

             

                // Set callback to app_conn_event_callback, no context needed, 5mS before TX, default = 30mS interval for the current connection.

                blecm_connectionEventNotifiationEnable(app_conn_event_callback, NULL, -5000/625, 30000/625, emconinfo_getConnHandle());

            }

             

            void app_conn_down(void)

            {

                // Stop connection event notifications.

                blecm_connectionEventNotifiationDisable();

             

                // All other connection down activity.

            }

             

             

            void app_conn_event_callback(void* context, UINT32 unused)

            {

                 // TX coming up in ~5mS from now.

            }

            1 of 1 people found this helpful
            • 3. Re: Connection Event Callback API
              userc_3543

              Sorry if this is a stupid question, but why use "-5000/625" for 5mS? By my calculations:

               

              -5000/625 = 8 frames

              8 * 1.25mS = 10mS

               

              Am I missing something?

              • 4. Re: Connection Event Callback API
                ArvindS_76

                The parameter is in BT slots which is 625uS each. The parameter also needs to be an even number so it is always at a frame boundary. So for 5ms, the parameter has to be 8 (which is an even number of BT slots).

                1 of 1 people found this helpful