Drivers Libraries Help > BM64 Bluetooth Driver Library > Library Interface > b) Client Setup Functions > DRV_BM64_EventHandlerSet Function
MPLAB Harmony Bluetooth Help
DRV_BM64_EventHandlerSet Function

This function allows a client to identify an event handling function for the driver to call back.

Description

Function DRV_BM64_EventHandlerSet: 

void DRV_BM64_EventHandlerSet(DRV_HANDLE handle, const DRV_BM64_EVENT_HANDLER eventHandler, const uintptr_t contextHandle); 

This function allows a client to identify a command event handling function for the driver to call back when an event has been received from the BM64. 

The context parameter contains a handle to the client context, provided at the time the event handling function is registered using the DRV_BM64_BufferEventHandlerSet function. This context handle value is passed back to the client as the "context" parameter. It can be any value necessary to identify the client context or instance (such as a pointer to the client's data) instance of the client.* 

The event handler should be set before the client performs any "BM64 Bluetooth Specific Client Routines" operations that could generate events. The event handler once set, persists until the client closes the driver or sets another event handler (which could be a "NULL" pointer to indicate no callback).

Preconditions

DRV_BM64_Open must have been called to obtain a valid opened device handle.

Parameters
Parameters 
Description 
handle 
valid handle to an opened BM64 device driver unique to client 
eventHandler 
pointer to a function to be called back (prototype defined by DRV_BM64_EVENT_HANDLER
contextHandle 
handle to the client context 
Returns

None.

Example
case APP_STATE_SET_BT_BUFFER_HANDLER:
{
    DRV_BT_BufferEventHandlerSet(appData.bt.handle,
                                  appData.bt.bufferHandler,
                                  appData.bt.context); 

    // note generic version of call (DRV_BT instead of DRV_BM64) is used
    DRV_BT_EventHandlerSet(appData.bt.handle,
                                  appData.bt.eventHandler,
                                  (uintptr_t)0);                                  

    appData.state = APP_STATE_CODEC_OPEN;            
}
break; 
C
void DRV_BM64_EventHandlerSet(
    DRV_HANDLE handle, 
    const DRV_BM64_EVENT_HANDLER eventHandler, 
    const uintptr_t contextHandle
);