MPLAB Harmony Bluetooth Help
|
The function DRV_BM64_ReadByteFromBLE is used to receive data one byte at a time; the function DRV_BM64_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_BM64_ClearBLEData to clear out the receive buffer before starting.
Example:
uint8_t byte; // note generic versions of calls (DRV_BT instead of DRV_BM64) 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_BM64_SendByteOverBLE Is used to send one byte of data at a time; the function DRV_BM64_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_BM64) is used DRV_BT_SendDataOverBLE(appData.bt.handle, buf, BUFSIZE);
The function DRV_BM64_BLE_EnableAdvertising is called to enable or disable BLE advertising.
The function DRV_BM64_BLE_QueryStatus queries the BM64 to respond with a DRV_BM64_EVENT_BLE_STATUS_CHANGED event, which will indicate if the BM64 BLE status is standby, advertising, scanning or connected.
Example:
// note generic version of call (DRV_BT instead of DRV_BM64) 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_BM64_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_BM64_BLE_STATUS_STANDBY: case DRV_BM64_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_BM64_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_BM64_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
|