BlueToe
an alternative GATT/BLE implementation
|
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. | |
Install a callback that will be called with a maximum period synchronized to the connection events of established connections.
T | has to be of class type and fulfil this set of requirements: |
connection
A public, none static member function:
unsigned ll_synchronized_callback( unsigned instant, connection& )
Optional, T contains the following public, none static member functions:
connection ll_synchronized_callback_connect( bluetoe::link_layer::delta_time connection_interval, unsigned calls_per_interval )
void ll_synchronized_callback_period_update( bluetoe::link_layer::delta_time connection_interval, unsigned calls_per_interval, connection& )
void ll_synchronized_callback_disconnect( connection& )
Obj | A reference to an instance of T on which the specified functions will be called. |
MaximumPeriodUS | The 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. |
PhaseShiftUS | The 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. |
MaximumExecutionTimeUS | The 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.
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.