static void centralProcessGATTMsg( gattMsgEvent_t *pMsg )
{
if ( centralState != BLE_STATE_CONNECTED )
{
// In case a GATT message came after a connection has dropped,
// ignore the message
return;
}
if ( ( pMsg->method == ATT_EXCHANGE_MTU_RSP ) ||
( ( pMsg->method == ATT_ERROR_RSP ) &&
( pMsg->msg.errorRsp.reqOpcode == ATT_EXCHANGE_MTU_REQ ) ) )
{
if ( pMsg->method == ATT_ERROR_RSP )
{
uint8 status = pMsg->msg.errorRsp.errCode;
PRINT( "Exchange MTU Error: %x\n", status );
}
centralProcedureInProgress = FALSE;
}
if ( pMsg->method == ATT_MTU_UPDATED_EVENT )
{
PRINT("MTU: %x\n",pMsg->msg.mtuEvt.MTU);
}
if ( ( pMsg->method == ATT_READ_RSP ) ||
( ( pMsg->method == ATT_ERROR_RSP ) &&
( pMsg->msg.errorRsp.reqOpcode == ATT_READ_REQ ) ) )
{
if ( pMsg->method == ATT_ERROR_RSP )
{
uint8 status = pMsg->msg.errorRsp.errCode;
PRINT( "Read Error: %x\n", status );
}
else
{
// After a successful read, display the read value
PRINT("Read rsp: %x\n",*pMsg->msg.readRsp.pValue);
}
centralProcedureInProgress = FALSE;
}
else if ( ( pMsg->method == ATT_WRITE_RSP ) ||
( ( pMsg->method == ATT_ERROR_RSP ) &&
( pMsg->msg.errorRsp.reqOpcode == ATT_WRITE_REQ ) ) )
{
if ( pMsg->method == ATT_ERROR_RSP )
{
uint8 status = pMsg->msg.errorRsp.errCode;
PRINT( "Write Error: %x\n", status );
}
else
{
// Write success
PRINT( "Write success \n" );
}
centralProcedureInProgress = FALSE;
}
else if ( pMsg->method == ATT_HANDLE_VALUE_NOTI )
{
PRINT("Receive noti: %x\n",*pMsg->msg.handleValueNoti.pValue);
}
else if ( centralDiscState != BLE_DISC_STATE_IDLE )
{
centralGATTDiscoveryEvent( pMsg );
}
GATT_bm_free(&pMsg->msg, pMsg->method);
}
|