MPLAB Harmony Bluetooth Help
|
The function DRV_BM71_ReadByteFromBLE is used to receive data one byte at a time; the function DRV_BM71_ReadDataFromBLE is used to receive multiple bytes. Each of them return a Boolean, which is true if data is returned or false if there is no data to return. You can use the function DRV_BM71_ClearBLEData to clear out the receive buffer before starting.
Example:
uint8_t byte; // note generic versions of calls (DRV_BT instead of DRV_BM71) are used DRV_BT_ClearBLEData(appData.bt.handle); // wait for byte to arrive while (!DRV_BT_ReadByteFromBLE(appData.bt.handle, &byte)) { // should have some sort of way to break out of here if byte never arrives }
The function DRV_BM71_SendByteOverBLE Is used to send one byte of data at a time; the function DRV_BM71_SendDataOverBLE is used to send multiple bytes of data.
Example:
#define BUFSIZE 100 uint8_t buf [BUFSIZE]; // (code goes here to fill in buffer with data) // note generic version of call (DRV_BT instead of DRV_BM71) is used DRV_BT_SendDataOverBLE(appData.bt.handle, buf, BUFSIZE);
The function DRV_BM71_BLE_EnableAdvertising is called to enable or disable BLE advertising.
The function DRV_BM71_BLE_QueryStatus queries the BM71 to respond with a DRV_BM71_EVENT_BLE_STATUS_CHANGED event, which will indicate if the BM71 BLE status is standby, advertising, scanning or connected.
Example:
// note generic version of call (DRV_BT instead of DRV_BM71) is used DRV_BT_BLE_QueryStatus(appData.bt.handle); . . . // later, a call will come back to the event handler callback function // (previously set up via a call to DRV_BM71_EventHandlerSet) static void _BLEEventHandler(DRV_BT_EVENT event, uint32_t param, uintptr_t context) { switch(event) { case DRV_BT_EVENT_BLE_STATUS_CHANGED: { // do case switch based on param variable switch(param) { case DRV_BM71_BLE_STATUS_STANDBY: case DRV_BM71_BLE_STATUS_SCANNING: laWidget_SetVisible((laWidget*)GFX_CONNECTED, LA_FALSE); laWidget_SetVisible((laWidget*)GFX_PAIRED, LA_FALSE); laWidget_SetVisible((laWidget*)GFX_NOPAIR_NOCONNECTION, LA_TRUE); break; case DRV_BM71_BLE_STATUS_ADVERTISING: laWidget_SetVisible((laWidget*)GFX_CONNECTED, LA_FALSE); laWidget_SetVisible((laWidget*)GFX_PAIRED, LA_TRUE); // actually, advertising laWidget_SetVisible((laWidget*)GFX_NOPAIR_NOCONNECTION, LA_FALSE); break; case DRV_BM71_BLE_STATUS_CONNECTED: laWidget_SetVisible((laWidget*)GFX_CONNECTED, LA_TRUE); laWidget_SetVisible((laWidget*)GFX_PAIRED, LA_FALSE); laWidget_SetVisible((laWidget*)GFX_NOPAIR_NOCONNECTION, LA_FALSE); break; } } }
MPLAB Harmony Bluetooth Help
|