Example #1
0
/*********************************************************************
 * @fn      timeAppProcessGattMsg
 *
 * @brief   Process GATT messages
 *
 * @return  none
 */
static void thermometerProcessGattMsg( gattMsgEvent_t *pMsg )
{


    //Measurement Indication Confirmation
    if( pMsg->method ==ATT_HANDLE_VALUE_CFM)
    {
        thermometerSendStoredMeas();
    }

    if ( pMsg->method == ATT_HANDLE_VALUE_NOTI ||
            pMsg->method == ATT_HANDLE_VALUE_IND )
    {
        timeAppIndGattMsg( pMsg );
    }
    else if ( pMsg->method == ATT_READ_RSP ||
              pMsg->method == ATT_WRITE_RSP )
    {
        timeAppConfigState = timeAppConfigGattMsg ( timeAppConfigState, pMsg );
        if ( timeAppConfigState == TIMEAPP_CONFIG_CMPL )
        {
            timeAppDiscoveryCmpl = TRUE;
        }
    }
    else
    {
        timeAppDiscState = timeAppDiscGattMsg( timeAppDiscState, pMsg );
        if ( timeAppDiscState == DISC_IDLE )
        {
            // Start characteristic configuration
            timeAppConfigState = timeAppConfigNext( TIMEAPP_CONFIG_START );
        }
    }
}
Example #2
0
/*********************************************************************
 * @fn      timeAppProcessGattMsg
 *
 * @brief   Process GATT messages
 *
 * @return  none
 */
static void timeAppProcessGattMsg( gattMsgEvent_t *pMsg )
{
  if ( pMsg->method == ATT_HANDLE_VALUE_NOTI ||
       pMsg->method == ATT_HANDLE_VALUE_IND )
  {
    timeAppIndGattMsg( pMsg );
  }
  else if ( ( pMsg->method == ATT_READ_RSP || pMsg->method == ATT_WRITE_RSP ) ||
            ( pMsg->method == ATT_ERROR_RSP &&
              ( pMsg->msg.errorRsp.reqOpcode == ATT_READ_REQ ||
                pMsg->msg.errorRsp.reqOpcode == ATT_WRITE_REQ ) ) )
  {
    timeAppConfigState = timeAppConfigGattMsg ( timeAppConfigState, pMsg );
    if ( timeAppConfigState == TIMEAPP_CONFIG_CMPL )
    {
      timeAppDiscoveryCmpl = TRUE;
    }
  }
  else
  {
    timeAppDiscState = timeAppDiscGattMsg( timeAppDiscState, pMsg );
    if ( timeAppDiscState == DISC_IDLE )
    {      
      // Start characteristic configuration
      timeAppConfigState = timeAppConfigNext( TIMEAPP_CONFIG_START );
    }
  }
}
Example #3
0
/*********************************************************************
 * @fn      timeAppDiscStart()
 *
 * @brief   Start service discovery. 
 *
 *
 * @return  New discovery state.
 */
uint8 timeAppDiscStart( void )
{
  // Clear handle cache
  osal_memset( timeAppHdlCache, 0, sizeof(timeAppHdlCache) );
  
  // Start discovery with first service
  return timeAppDiscGattMsg( DISC_CURR_TIME_START, NULL );
}