/*********************************************************************
 * @fn      gapRole_ProcessOSALMsg
 *
 * @brief   Process an incoming task message.
 *
 * @param   pMsg - message to process
 *
 * @return  none
 */
static void gapRole_ProcessOSALMsg( osal_event_hdr_t *pMsg )
{
  switch ( pMsg->event )
  {
    case HCI_GAP_EVENT_EVENT:
      if ( pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE )
      {
        hciEvt_CmdComplete_t *pPkt = (hciEvt_CmdComplete_t *)pMsg;

        if ( pPkt->cmdOpcode == HCI_READ_RSSI )
        {
          int8 rssi = (int8)pPkt->pReturnParam[3];

          if ( ((gapRole_state == GAPROLE_CONNECTED)
                      || (gapRole_state == GAPROLE_CONNECTED_ADV))
              && (rssi != RSSI_NOT_AVAILABLE) )
          {
            // Report RSSI to app
            if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnRssiRead )
            {
              pGapRoles_AppCGs->pfnRssiRead( rssi );
            }
          }
        }
      }
      break;

    case GAP_MSG_EVENT:
      gapRole_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
      break;

    case L2CAP_SIGNAL_EVENT:
      {
        l2capSignalEvent_t *pPkt = (l2capSignalEvent_t *)pMsg;

        // Process the Parameter Update Response
        if ( pPkt->opcode == L2CAP_PARAM_UPDATE_RSP )
        {
          l2capParamUpdateRsp_t *pRsp = (l2capParamUpdateRsp_t *)&(pPkt->cmd.updateRsp);
          if ( pRsp->result == SUCCESS )
          {
            // All is good stop Update Parameters timeout
            VOID osal_stop_timerEx( gapRole_TaskID, UPDATE_PARAMS_TIMEOUT_EVT );
          }
        }
      }
      break;

    default:
      break;
  }
}
Ejemplo n.º 2
0
/*********************************************************************
 * @fn      gapRole_ProcessOSALMsg
 *
 * @brief   Process an incoming task message.
 *
 * @param   pMsg - message to process
 *
 * @return  none
 */
static void gapRole_ProcessOSALMsg( osal_event_hdr_t *pMsg )
{
  switch ( pMsg->event )
  {
    case HCI_GAP_EVENT_EVENT:
      if ( pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE )
      {
        //hciEvt_CmdComplete_t *pPkt = (hciEvt_CmdComplete_t *)pMsg;
      }
      break;

    case GAP_MSG_EVENT:
      gapRole_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
      break;

    default:
      break;
  }
}
Ejemplo n.º 3
0
/*********************************************************************
 * @fn      gapRole_ProcessOSALMsg
 *
 * @brief   Process an incoming task message.
 *
 * @param   pMsg - message to process
 *
 * @return  none
 */
static void gapRole_ProcessOSALMsg( osal_event_hdr_t *pMsg )
{
  switch ( pMsg->event )
  {
    case HCI_GAP_EVENT_EVENT:
      if ( pMsg->status == HCI_COMMAND_COMPLETE_EVENT_CODE )
      {
        hciEvt_CmdComplete_t *pPkt = (hciEvt_CmdComplete_t *)pMsg;

        if ( pPkt->cmdOpcode == HCI_READ_RSSI )
        {
          int8 rssi = (int8)pPkt->pReturnParam[3];

          if ( (gapRole_state == GAPROLE_CONNECTED) && (rssi != RSSI_NOT_AVAILABLE) )
          {
            // Report RSSI to app
            if ( pGapRoles_AppCGs && pGapRoles_AppCGs->pfnRssiRead )
            {
              pGapRoles_AppCGs->pfnRssiRead( rssi );
            }
          }
        }
      }
      break;

    case GAP_MSG_EVENT:
      gapRole_ProcessGAPMsg( (gapEventHdr_t *)pMsg );
      break;

    case L2CAP_SIGNAL_EVENT:
      {
        l2capSignalEvent_t *pPkt = (l2capSignalEvent_t *)pMsg;

        // Process the Parameter Update Response
        if ( pPkt->opcode == L2CAP_PARAM_UPDATE_RSP )
        {
          l2capParamUpdateRsp_t *pRsp = (l2capParamUpdateRsp_t *)&(pPkt->cmd.updateRsp);
                  
          if ( ( pRsp->result == L2CAP_CONN_PARAMS_REJECTED ) &&
               ( paramUpdateNoSuccessOption == GAPROLE_TERMINATE_LINK ) )
          {
            // Cancel connection param update timeout timer
            VOID osal_stop_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT );
                      
            // Terminate connection immediately
            GAPRole_TerminateConnection();
          }
          else
          {
            uint16 timeout = GAP_GetParamValue( TGAP_CONN_PARAM_TIMEOUT );
            
            // Let's wait for Controller to update connection parameters if they're
            // accepted. Otherwise, decide what to do based on no success option.
            VOID osal_start_timerEx( gapRole_TaskID, CONN_PARAM_TIMEOUT_EVT, timeout );
          }
        }
      }
      break;

    default:
      break;
  }
}