コード例 #1
0
ファイル: timeapp_ind.c プロジェクト: billy-wang/IOT
/*********************************************************************
 * @fn      timeAppIndGattMsg
 *
 * @brief   Handle indications and notifications. 
 *
 * @param   pMsg - GATT message.
 *
 * @return  none
 */
void timeAppIndGattMsg( gattMsgEvent_t *pMsg )
{
  uint8 i;
  
  // Look up the handle in the handle cache
  for ( i = 0; i < HDL_CACHE_LEN; i++ )
  {
    if ( pMsg->msg.handleValueNoti.handle == timeAppHdlCache[i] )
    {
      break;
    }
  }

  // Perform processing for this handle 
  switch ( i )
  {
    case HDL_CURR_TIME_CT_TIME_START:
      // Set clock to time read from time server
      timeAppClockSet( pMsg->msg.handleValueNoti.pValue );
      break;
      
 
     default:
      break;
  }
  
  // Send confirm for indication
  if ( pMsg->method == ATT_HANDLE_VALUE_IND )
  {
    ATT_HandleValueCfm( pMsg->connHandle );
  }
}
コード例 #2
0
/*********************************************************************
 * @fn      simpleProfileChangeCB
 *
 * @brief   Callback from SimpleBLEProfile indicating a value change
 *
 * @param   paramID - parameter ID of the value that was changed.
 *
 * @return  none
 */
static void simpleProfileChangeCB( uint8 paramID )
{
    uint8 data[20];
    uint8 len;
    switch( paramID )
    {
    case SIMPLEPROFILE_CHAR1:
        //SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR1, &newValue );

        break;

    case SIMPLEPROFILE_CHAR3:
        SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &data );
        len = data[0];
        UART_SEND_DEBUG_MSG(&data[1], len);
        // << Wayne >> << RepeatCmd >> ++
        if(repeatCmdSendData(&data[1], len))
        // << Wayne >> << RepeatCmd >> --
        {
            // << Wayne >> << dBCmd Service  >> ++
            dBCommand_Service(&data[1]);
            // << Wayne >> << dBCmd Service  >> --
        }
        break;
      case SIMPLEPROFILE_CHAR5:
        SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR5, &data );
        timeAppClockSet(&data[0]);
        break;
    default:
        // should not reach here!
        break;
    }
}
コード例 #3
0
ファイル: timeapp_config.c プロジェクト: AubrCool/BLE
/*********************************************************************
 * @fn      timeAppConfigGattMsg()
   *
 * @brief   Handle GATT messages for characteristic configuration.
 *
 * @param   state - Discovery state.
 * @param   pMsg - GATT message.
 *
 * @return  New configuration state.
 */
uint8 timeAppConfigGattMsg( uint8 state, gattMsgEvent_t *pMsg )
{
  
  if ( (pMsg->method == ATT_READ_RSP || pMsg->method == ATT_WRITE_RSP) &&
       (pMsg->hdr.status == SUCCESS) )
  {
    // Process response
    switch ( timeAppConfigList[state] )
    {
      case HDL_CURR_TIME_CT_TIME_START:
        // Set clock to time read from time server
        timeAppClockSet( pMsg->msg.readRsp.value );
        break;

      default:
        break;
    }
  }
  return timeAppConfigNext( state + 1 );
}
コード例 #4
0
/*********************************************************************
 * @fn      timeAppIndGattMsg
 *
 * @brief   Handle indications and notifications. 
 *
 * @param   pMsg - GATT message.
 *
 * @return  none
 */
void timeAppIndGattMsg( gattMsgEvent_t *pMsg )
{
  uint8 i;
  
  // Look up the handle in the handle cache
  for ( i = 0; i < HDL_CACHE_LEN; i++ )
  {
    if ( pMsg->msg.handleValueNoti.handle == timeAppHdlCache[i] )
    {
      break;
    }
  }

  // Perform processing for this handle 
  switch ( i )
  {
    case HDL_CURR_TIME_CT_TIME_START:
      // Set clock to time read from time server
      timeAppClockSet( pMsg->msg.handleValueNoti.pValue );
      break;
      
    case HDL_NWA_NWA_START:             
      // Display network availability state
      if ( pMsg->msg.handleValueInd.pValue[0] == 1 )
      {
        LCD_WRITE_STRING( "Network: Yes", HAL_LCD_LINE_1 );
      }
      else
      {
        LCD_WRITE_STRING( "Network: None", HAL_LCD_LINE_1 );
      }
      break;
      
    case HDL_ALERT_NTF_UNREAD_START:
      // Display unread message alert
      {
        uint8 *p = pMsg->msg.handleValueNoti.pValue;
        uint8 len = pMsg->msg.handleValueNoti.len;
        
        if ( p[0] <= ALERT_CAT_ID_MAX && len == 2 )
        {
          LCD_WRITE_STRING_VALUE( (char *) timeAppAlertCatStr[p[0]], p[1], 10, HAL_LCD_LINE_1 );
          LCD_WRITE_STRING( "", HAL_LCD_LINE_2 );
        }
      }
      break;
      
    case HDL_ALERT_NTF_NEW_START:
      // Display incoming message
      timeAppDisplayAlert( pMsg->msg.handleValueNoti.pValue,
                           pMsg->msg.handleValueNoti.len );
      break;

    case HDL_BATT_LEVEL_START:
      // Display battery level
      LCD_WRITE_STRING_VALUE( "Battery%", pMsg->msg.handleValueNoti.pValue[0], 10, HAL_LCD_LINE_2 );
      break;

    case HDL_PAS_ALERT_START:
      // Display phone alert status
      LCD_WRITE_STRING_VALUE( "Phone Alert:",  pMsg->msg.handleValueNoti.pValue[0], 16, HAL_LCD_LINE_1 );
      break;

    case HDL_PAS_RINGER_START:
      // Display ringer state
      if ( pMsg->msg.handleValueNoti.pValue[0] == 0 )
      {
        LCD_WRITE_STRING( "Ringer Off", HAL_LCD_LINE_2 );
      }
      else
      {
        LCD_WRITE_STRING( "Ringer On", HAL_LCD_LINE_2 );
      }    
      break;

    default:
      break;
  }
  
  // Send confirm for indication
  if ( pMsg->method == ATT_HANDLE_VALUE_IND )
  {
    ATT_HandleValueCfm( pMsg->connHandle );
  }
}
コード例 #5
0
ファイル: timeapp_ind.c プロジェクト: JensenSung/shred444
/*********************************************************************
 * @fn      timeAppIndGattMsg
 *
 * @brief   Handle indications and notifications. 
 *
 * @param   pMsg - GATT message.
 *
 * @return  none
 */
void timeAppIndGattMsg( gattMsgEvent_t *pMsg )
{
  uint8 i;
  
  // Look up the handle in the handle cache
  for ( i = 0; i < HDL_CACHE_LEN; i++ )
  {
    if ( pMsg->msg.handleValueNoti.handle == timeAppHdlCache[i] )
    {
      break;
    }
  }

  // Perform processing for this handle 
  switch ( i )
  {
    case HDL_CURR_TIME_CT_TIME_START:
      // Set clock to time read from time server
      timeAppClockSet( pMsg->msg.handleValueNoti.value );
      break;
      
    case HDL_NWA_NWA_START:             
      // Display network availability state
      if ( pMsg->msg.handleValueInd.value[0] == 1 )
      {
        LCD_WRITE_STRING( "Network: Yes", HAL_LCD_LINE_1 );
      }
      else
      {
        LCD_WRITE_STRING( "Network: None", HAL_LCD_LINE_1 );
      }
      break;
      
    case HDL_ALERT_NTF_UNREAD_START:
      // Display unread message alerts
      {
        uint8 *p = pMsg->msg.handleValueNoti.value;
        uint8 len = pMsg->msg.handleValueNoti.len;
        uint8 line;
        
        for ( line = 1; line <= 2 && len >= 2; line++, len -= 2 )
        {
          if ( ALERT_MAJOR_CAT(p[0]) <= ALERT_CAT_ID_MAX )
          {
            LCD_WRITE_STRING_VALUE( (char *) timeAppAlertCatStr[ALERT_MAJOR_CAT(p[0])],
                                    p[1], 10, line );
          }
          p += 2;
        }
      }
      break;
      
    case HDL_ALERT_NTF_INCOM_START:
      // Display incoming message
      timeAppDisplayAlert( pMsg->msg.handleValueNoti.value,
                           pMsg->msg.handleValueNoti.len );
      break;

    case HDL_BATT_LEVEL_STATE_START:
      // Display battery level
      LCD_WRITE_STRING_VALUE( "Battery%", pMsg->msg.handleValueNoti.value[0], 10, HAL_LCD_LINE_2 );
      break;
        
     default:
      break;
  }
  
  // Send confirm for indication
  if ( pMsg->method == ATT_HANDLE_VALUE_IND )
  {
    ATT_HandleValueCfm( pMsg->connHandle );
  }
}
コード例 #6
0
/*********************************************************************
 * @fn      timeAppConfigGattMsg()
   *
 * @brief   Handle GATT messages for characteristic configuration.
 *
 * @param   state - Discovery state.
 * @param   pMsg - GATT message.
 *
 * @return  New configuration state.
 */
uint8 timeAppConfigGattMsg( uint8 state, gattMsgEvent_t *pMsg )
{
  if ( state > TIMEAPP_CONFIG_MAX )
  {
    return TIMEAPP_CONFIG_CMPL;
  }
  
  if ( (pMsg->method == ATT_READ_RSP || pMsg->method == ATT_WRITE_RSP) &&
       (pMsg->hdr.status == SUCCESS) )
  {
    // Process response
    switch ( timeAppConfigList[state] )
    {
      case HDL_CURR_TIME_CT_TIME_START:
        // Set clock to time read from time server
        timeAppClockSet( pMsg->msg.readRsp.value );
        break;

      case HDL_CURR_TIME_LOC_INFO:
        break;

      case HDL_CURR_TIME_REF_INFO:
        break;

      case HDL_DST_CHG_TIME_DST:
        break;

      case HDL_NWA_NWA_START:
        // Display network availability state
        if ( pMsg->msg.readRsp.value[0] == 1 )
        {
          LCD_WRITE_STRING( "Network: Yes", HAL_LCD_LINE_1 );
        }
        else
        {
          LCD_WRITE_STRING( "Network: None", HAL_LCD_LINE_1 );
        }    
        break;

      case HDL_BATT_LEVEL_START:
        // Display battery level
        LCD_WRITE_STRING_VALUE( "Battery%", pMsg->msg.readRsp.value[0], 10, HAL_LCD_LINE_2 );
        break;

      case HDL_CURR_TIME_CT_TIME_CCCD:
        break;

      case HDL_ALERT_NTF_NEW_CAT:
        break;

      case HDL_ALERT_NTF_UNREAD_CAT:
        break;
        
      case HDL_ALERT_NTF_UNREAD_CCCD:
        break;

      case HDL_ALERT_NTF_NEW_CCCD:
        break;

      case HDL_NWA_NWA_CCCD:
        break;

      case HDL_PAS_ALERT_START:
        // Display phone alert status
        LCD_WRITE_STRING_VALUE( "Phone Alert:", pMsg->msg.readRsp.value[0], 16, HAL_LCD_LINE_1 );
        break;

      case HDL_PAS_RINGER_START:
        // Display ringer state
        if ( pMsg->msg.readRsp.value[0] == 0 )
        {
          LCD_WRITE_STRING( "Ringer Off", HAL_LCD_LINE_2 );
        }
        else
        {
          LCD_WRITE_STRING( "Ringer On", HAL_LCD_LINE_2 );
        }    
        break;

      default:
        break;
    }
  }

  return timeAppConfigNext( state + 1 );
}