BlueToe
an alternative GATT/BLE implementation
Loading...
Searching...
No Matches
Public Member Functions | List of all members
bluetoe::link_layer::synchronized_connection_event_callback< T, Obj, MaximumPeriodUS, PhaseShiftUS, MaximumExecutionTimeUS > Struct Template Reference

Install a callback that will be called with a maximum period synchronized to the connection events of established connections. More...

#include <bluetoe/link_layer/include/bluetoe/connection_event_callback.hpp>

Public Member Functions

void stop_synchronized_connection_event_callbacks ()
 stop the call of the synchronized callbacks.
 
void restart_synchronized_connection_event_callbacks ()
 restart the invocation of synchronized callbacks, after they where stopped.
 
void force_synchronized_connection_event_callback ()
 Ask Bluetoe to ignore the last return value of ll_synchronized_callback() and call the callback at the next possible time.
 

Detailed Description

template<typename T, T & Obj, unsigned MaximumPeriodUS, int PhaseShiftUS, unsigned MaximumExecutionTimeUS = 100>
struct bluetoe::link_layer::synchronized_connection_event_callback< T, Obj, MaximumPeriodUS, PhaseShiftUS, MaximumExecutionTimeUS >

Install a callback that will be called with a maximum period synchronized to the connection events of established connections.

Template Parameters
Thas to be of class type and fulfil this set of requirements:
Template Parameters
ObjA reference to an instance of T on which the specified functions will be called.
MaximumPeriodUSThe maximum period at which the callback shall be called, given in µs.
    If MaximumPeriodUS is larger than the connections interval, the callback will be called
    with a period that is the greatest multiple of the connection interval, that is smaller
    than the connections interval.

    If MaximumPeriodUS is smaller than the current connections
    interval, the callback will be called multiple times with a fixed period. The period is
    chosen to be smaller than or equal to the given MaximumPeriodUS and so that a whole number
    of calls fit into the connection interval.

    Example: Connection Interval = 22.5ms, MaximumPeriodUS = 4ms
                 => Effective Period = 3.75ms (callback will be call 6 times)

    Example: Connection Interval = 22.5ms, MaximumPeriodUS = 60ms
                 => Effective Period = 45ms (callback will be call every second connection event)

    If the connections interval changes, the period at which the callback is called also
    changes. The callback will be called irrespectively of the connection event. Even when the
    connect event times out or is planned to not happen, due to peripheral latency applied.
PhaseShiftUSThe offset to the connection anchor in µs. A positive value denotes that the call has to be called PhaseShiftUS µs after the anchor. Note, that in this case, high priority CPU processing near the connection event might interrupt the given callback invocation. A negative value denotes a call to the callback prior to the connection anchor by the given number of µs.
MaximumExecutionTimeUSThe estimated, maximum execution time of the callback. This helps the library to make sure, that the callback invocation in front of the connection event will return, before the connection event happens. If the hardware abstraction provides information about a minimum setup time, the library take that also into account.

If PhaseShiftUS is negative, a compile time check tests that the execution of the callback will not run into the setup of the connection event.

Once a new connection is established, Obj.ll_synchronized_callback_connect() is called (if given) with the connection interval and the number of times, the callback will be called during one interval. ll_synchronized_callback_connect() have to return the initial value of connection.

If the connection is closed, Obj.ll_synchronized_callback_disconnect() is called with the instance of connection that was created by ll_synchronized_callback_connect(). If T does not provide ll_synchronized_callback_connect(), a connection is default constructed.

If the connection interval changes, Obj.ll_synchronized_callback_period_update() is called (if given) with the connection interval and the number of times, the callback will be called during one interval.

ll_synchronized_callback() will be call with the first parameter being 0 for the first invocation after the connection event and then with increased values until the value calls_per_interval - 1 is reached (calls_per_interval can be obtained by having ll_synchronized_callback_connect() and ll_synchronized_callback_period_update() defined). The return value of ll_synchronized_callback() denotes the number of times, the invocation of the callback should be omitted. For example, when ll_synchronized_callback() returns 2, two planned callback invocations are omitted until the callback is called again.

If the anchor is going to move due to a planned connection update procedure, there is danger of overlapping calls to the callback due to the uncertainty given by the range of transmission window size and offset. In this case, the last callback call before the instant of the update will be omitted. And the next time, the callback will be called, is after the first connection event with updated connection parameters toke place.

Note
This feature requires support by the hardware abstraction and thus might not be available on all platforms.
due to connection parameter updates, there is no guaranty, that the callback will be called with the requested MaximumPeriodUS.
All callbacks will be called from the very same execution context (thus there is no need for synchronization between calls). The context is defined by the hardware and unspecified.

Member Function Documentation

◆ restart_synchronized_connection_event_callbacks()

template<typename T , T & Obj, unsigned MaximumPeriodUS, int PhaseShiftUS, unsigned MaximumExecutionTimeUS = 100>
void bluetoe::link_layer::synchronized_connection_event_callback< T, Obj, MaximumPeriodUS, PhaseShiftUS, MaximumExecutionTimeUS >::restart_synchronized_connection_event_callbacks ( )

restart the invocation of synchronized callbacks, after they where stopped.

Precondition
stop_synchronized_connection_event_callbacks()

The documentation for this struct was generated from the following file: