FireSync API
 All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kStatus kSystem_SetDataHandler ( kSystem  system,
kCallbackFx  function,
kPointer  receiver 
)

Registers a callback function that can be used to receive data messages.

If a data callback will be used, it should be registered prior to opening any sensor data connections. The callback cannot be changed while sensors are sending data.

The callback function will be asynchronously invoked in a background thread. It can be called at any time, until the callback is unregistered. Various internal locks may be held by the thread that invokes the callback; accordingly, the implementation of the callback should avoid acquiring any locks that might result in deadlock. In particular, this includes any locks that might be held by the application when opening or closing data connections. If in doubt, the safest course is to enqueue the received data for processing by another application thread, or use the kSystem_ReceiveData method instead of kSystem_SetDataHandler.

Message objects (kMsgInfo) received by the registered callback function should be disposed (kObject_Dispose) when no longer needed. Data messages can be retained beyond the duration of the callback.

Callbacks can be used as an alternative to kSystem_ReceiveData, but cannot be used at the same time (registering a callback will prevent kSystem_ReceiveData from working).

Parameters
systemSystem object.
functionData handler function, or kNULL to unregister the callback.
receiverUser-defined context pointer, to be passed to the callback function.
Returns
Operation status.