Drivers Libraries Help > BM71 Bluetooth Driver Library > Library Interface > a) System Functions > DRV_BM71_EventHandlerSet Function
MPLAB Harmony Bluetooth Help
DRV_BM71_EventHandlerSet Function

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

Description

Function DRV_BM71_EventHandlerSet: 

void DRV_BM71_EventHandlerSet(DRV_HANDLE handle, const DRV_BM71_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 BM71. 

The context parameter contains a handle to the client context, provided at the time the event handling function is registered using the DRV_BM71_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 "BM71 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_BM71_Open must have been called to obtain a valid opened device handle.

Parameters
Parameters 
Description 
handle 
valid handle to an opened BM71 device driver unique to client 
eventHandler 
pointer to a function to be called back (prototype defined by DRV_BM71_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_BM71) is used
    DRV_BT_EventHandlerSet(appData.bt.handle,
                                  appData.bt.eventHandler,
                                  (uintptr_t)0);                                  

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