Drivers Libraries Help > BM64 Bluetooth Driver Library > Using the Library > How the Library Works > Data Transfer Function
MPLAB Harmony Bluetooth Help
Data Transfer Function

The function DRV_BM64_BufferAddRead schedules a non-blocking read operation. It returns with a valid buffer handle in the bufferHandle argument if the read request was scheduled successfully. 

If the requesting client registered an event callback with the driver, the driver will issue a DRV_BM64_BUFFER_EVENT_COMPLETE event if the buffer was processed successfully or DRV_BM64_BUFFER_EVENT_ERROR event if the buffer was not processed successfully. 

Example:  

case APP_STATE_BT_BUFFER_COMPLETE:
{
    if (!_bufferUsed[appData.readIndex])
    {
       //Next BT Read Queued
       // note generic version of call (DRV_BT instead of DRV_BM64) is used
       DRV_BT_BufferAddRead(appData.bt.handle, &appData.bt.readBufHandle,
               audioBuffer[appData.readIndex],   appData.bt.bufferSize);
       if(appData.bt.readBufHandle != DRV_BT_BUFFER_HANDLE_INVALID)
       {
           appData.bt.readBufHandle = DRV_BT_BUFFER_HANDLE_INVALID;
           _bufferUsed[appData.readIndex] = true;
           appData.readIndex++;
           if(appData.readIndex >= AUDIO_QUEUE_SIZE)
           {
               appData.readIndex = 0;
           }
           appData.state = APP_STATE_BT_WAIT_FOR_BUFFER_COMPLETE;
       }
    }
}