• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GATTServApp_ProcessCCCWriteReq函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GATTServApp_ProcessCCCWriteReq函数的典型用法代码示例。如果您正苦于以下问题:C++ GATTServApp_ProcessCCCWriteReq函数的具体用法?C++ GATTServApp_ProcessCCCWriteReq怎么用?C++ GATTServApp_ProcessCCCWriteReq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GATTServApp_ProcessCCCWriteReq函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: BloodPressure_WriteAttrCB

/*********************************************************************
 * @fn      BloodPressure_WriteAttrCB
 *
 * @brief   Validate attribute data prior to a write operation
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr - pointer to attribute
 * @param   pValue - pointer to data to be written
 * @param   len - length of data
 * @param   offset - offset of the first octet to be written
 *
 * @return  Success or Failure
 */
static bStatus_t BloodPressure_WriteAttrCB(uint16_t connHandle, 
                                           gattAttribute_t *pAttr, 
                                           uint8_t *pValue, uint16_t len, 
                                           uint16_t offset, uint8_t method)
{
  bStatus_t status = SUCCESS;
  uint16 uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
  
  switch (uuid)
  {
    case GATT_CLIENT_CHAR_CFG_UUID:
      if (pAttr->handle == 
           bloodPressureAttrTbl[BLOODPRESSURE_MEAS_CONFIG_POS].handle)
      {
        // BloodPressure Indications.
        status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
                                                offset, 
                                                GATT_CLIENT_CFG_INDICATE);
        if (status == SUCCESS)
        {
          uint16 value = BUILD_UINT16(pValue[0], pValue[1]);

          (*bloodPressureServiceCB)((value == GATT_CFG_NO_OPERATION) ? 
                                     BLOODPRESSURE_MEAS_NOTI_DISABLED :
                                     BLOODPRESSURE_MEAS_NOTI_ENABLED);
        }
      }
      else if (pAttr->handle == 
                bloodPressureAttrTbl[BLOODPRESSURE_IMEAS_CONFIG_POS].handle)
      {
        // BloodPressure Notifications.
        status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
                                                offset, GATT_CLIENT_CFG_NOTIFY);
        if (status == SUCCESS)
        {
          uint16 value = BUILD_UINT16(pValue[0], pValue[1]);

          (*bloodPressureServiceCB)((value == GATT_CFG_NO_OPERATION)  ? 
                                     BLOODPRESSURE_IMEAS_NOTI_DISABLED :
                                     BLOODPRESSURE_IMEAS_NOTI_ENABLED);
        }
      }
      else
      {
        status = ATT_ERR_INVALID_HANDLE;
      }
      break;       
 
    default:
      status = ATT_ERR_ATTR_NOT_FOUND;
      break;
  }
  
  return (status);
}
开发者ID:victor-zheng,项目名称:BLE,代码行数:68,代码来源:bpservice.c


示例2: accel_WriteAttrCB

/*********************************************************************
 * @fn      accel_WriteAttrCB
 *
 * @brief   Validate attribute data prior to a write operation
 *
 * @param   connHandle – connection message was received on
 * @param   pReq - pointer to request
 *
 * @return  Success or Failure
 */
static bStatus_t accel_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                    uint8 *pValue, uint8 len, uint16 offset )
{
  bStatus_t status = SUCCESS;
  uint8 notify = 0xFF;

  if ( pAttr->type.len == ATT_BT_UUID_SIZE )
  {
    
    uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
    switch ( uuid )
    {
      case ACCEL_ENABLER_UUID:
        //Validate the value
        // Make sure it's not a blob oper
        if ( offset == 0 )
        {
          if ( len > 1 )
            status = ATT_ERR_INVALID_VALUE_SIZE;
          else if ( pValue[0] != FALSE && pValue[0] != TRUE )
            status = ATT_ERR_INVALID_VALUE;
        }
        else
        {
          status = ATT_ERR_ATTR_NOT_LONG;
        }
        
        //Write the value
        if ( status == SUCCESS )
        {
          uint8 *pCurValue = (uint8 *)pAttr->pValue;
          
          *pCurValue = pValue[0];
          notify = ACCEL_ENABLER;        
        }
             
        break;
          
      case GATT_CLIENT_CHAR_CFG_UUID:
        status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                                 offset, GATT_CLIENT_CFG_NOTIFY );
        break;      
          
      default:
          // Should never get here!
          status = ATT_ERR_ATTR_NOT_FOUND;
    }
  }
  else
  {
    // 128-bit UUID
    status = ATT_ERR_INVALID_HANDLE;
  }  

  // If an attribute changed then callback function to notify application of change
  if ( (notify != 0xFF) && accel_AppCBs && accel_AppCBs->pfnAccelEnabler )
    accel_AppCBs->pfnAccelEnabler();  
  
  return ( status );
}
开发者ID:yang325,项目名称:CC2541_Peripheral,代码行数:70,代码来源:accelerometer.c


示例3: uartServ2WriteAttrCB

/**
 * @fn      uartServ2WriteAttrCB
 *
 * @brief   Validate attribute data prior to a write operation
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr - pointer to attribute
 * @param   pValue - pointer to data to be written
 * @param   len - length of data
 * @param   offset - offset of the first octet to be written
 *
 * @return  Success or Failure
 */
static bStatus_t uartServ2WriteAttrCB(uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 len, uint16 offset)
{
	bStatus_t	status = SUCCESS;
	uint16		uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);

	dmsg(("\033[40;31m0xFFE0 (Notify)\033[0m\n"));

	switch (uuid) {
	case GATT_CLIENT_CHAR_CFG_UUID:
		status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY);
		if (status == SUCCESS) {
			uint16	charCfg = BUILD_UINT16(pValue[0], pValue[1]);

			if (uartServ2_AppCBs) {
				(*uartServ2_AppCBs)((charCfg == GATT_CFG_NO_OPERATION) ? UARTSERV2_NOTI_DISABLED : UARTSERV2_NOTI_ENABLED);
			}
		}
		break;

	default:
		status = ATT_ERR_ATTR_NOT_FOUND;
		break;
	}

	return (status);
}
开发者ID:wythe-lin,项目名称:ZTKBLE,代码行数:39,代码来源:uartserv.c


示例4: battWriteAttrCB

/*********************************************************************
 * @fn      battWriteAttrCB
 *
 * @brief   Validate attribute data prior to a write operation
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr - pointer to attribute
 * @param   pValue - pointer to data to be written
 * @param   len - length of data
 * @param   offset - offset of the first octet to be written
 *
 * @return  Success or Failure
 */
static bStatus_t battWriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                  uint8 *pValue, uint8 len, uint16 offset )
{
  bStatus_t status = SUCCESS;

  uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
  switch ( uuid )
  {
    case GATT_CLIENT_CHAR_CFG_UUID:
      status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                               offset, GATT_CLIENT_CFG_NOTIFY );
      if ( status == SUCCESS )
      {
        uint16 charCfg = BUILD_UINT16( pValue[0], pValue[1] );

        if ( battServiceCB )
        {
          (*battServiceCB)( (charCfg == GATT_CFG_NO_OPERATION) ?
                            BATT_LEVEL_NOTI_DISABLED :
                            BATT_LEVEL_NOTI_ENABLED);
        }
      }
      break;

    default:
      status = ATT_ERR_ATTR_NOT_FOUND;
      break;
  }

  return ( status );
}
开发者ID:zhangjie201412,项目名称:Study,代码行数:44,代码来源:battservice.c


示例5: SK_writeAttrCB

/*********************************************************************
 * @fn      SK_writeAttrCB
 *
 * @brief   Validate attribute data prior to a write operation
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr      - pointer to attribute
 * @param   pValue     - pointer to data to be written
 * @param   len        - length of data
 * @param   offset     - offset of the first octet to be written
 * @param   method     - type of write message 
 *
 * @return  SUCCESS, blePending or Failure
 */
static bStatus_t SK_writeAttrCB(uint16_t connHandle, gattAttribute_t *pAttr,
                                uint8_t *pValue, uint16_t len, uint16_t offset,
                                uint8_t method)
{
  bStatus_t status = SUCCESS;

  if (pAttr->type.len == ATT_BT_UUID_SIZE)
  {
    // 16-bit UUID
    uint16 uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
    switch (uuid)
    {
      case GATT_CLIENT_CHAR_CFG_UUID:
        status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
                                                offset, GATT_CLIENT_CFG_NOTIFY);
        break;
       
      default:
        // Should never get here!
        status = ATT_ERR_ATTR_NOT_FOUND;
        break;
    }
  }
  else
  {
    // 128-bit UUID
    status = ATT_ERR_INVALID_HANDLE;
  }

  return (status);
}
开发者ID:ClarePhang,项目名称:BLE_cc2650,代码行数:45,代码来源:simplekeys.c


示例6: consoleProfile_WriteAttrCB

static bStatus_t consoleProfile_WriteAttrCB(uint16 connHandle, gattAttribute_t *pAttr, uint8 *pValue, uint8 len, uint16 offset)
{
  unsigned char i;
  bStatus_t status;

  if (pAttr->type.len == ATT_BT_UUID_SIZE && BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]) == GATT_CLIENT_CHAR_CFG_UUID)
  {
    status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY);
    // Setup console if we're connected, otherwise disable
    for (i = 0; i < GATT_MAX_NUM_CONN; i++)
    {
      if (consoleProfileCharCfg[i].value == 1)
      {
        io.writein = io.write;
        io.writeout = io.write;
        ble_console_enabled = 1;
        OS_timer_stop(DELAY_TIMER);
        interpreter_banner();
        goto done;
      }
    }
    ble_console_enabled = 0;
  done:
    return status;
  }
  for (i = 0; i < len; i++)
  {
    OS_type(pValue[i]);
  }
  return SUCCESS;
}
开发者ID:JBtje,项目名称:BlueBasic,代码行数:31,代码来源:BlueBasic.c


示例7: oadWriteAttrCB

/*********************************************************************
 * @fn      oadWriteAttrCB
 *
 * @brief   Validate and Write attribute data
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr      - pointer to attribute
 * @param   pValue     - pointer to data to be written
 * @param   len        - length of data
 * @param   offset     - offset of the first octet to be written
 * @param   method     - type of write message 
 *
 * @return  SUCCESS, blePending or Failure
 */
static bStatus_t oadWriteAttrCB(uint16_t connHandle, gattAttribute_t *pAttr,
                                uint8_t *pValue, uint16_t len, uint16_t offset,
                                uint8_t method)
{
  bStatus_t status = SUCCESS;

  if (pAttr->type.len == ATT_BT_UUID_SIZE)
  {
    // 16-bit UUID
    uint16_t uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
    if (uuid == GATT_CLIENT_CHAR_CFG_UUID)
    {
      // Process a CCC write request.
      status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
                                               offset, GATT_CLIENT_CFG_NOTIFY);
    }
    else
    {
      status = ATT_ERR_ATTR_NOT_FOUND; // Should never get here!
    }
  }
  else
  {
    // 128-bit UUID
    if (!memcmp(pAttr->type.uuid, oadCharUUID[OAD_CHAR_IMG_IDENTIFY], 
                ATT_UUID_SIZE))
    {
      /* OAD manager is identifying the new image.
       * The manager presents header information by which this device can
       * accept or reject an OAD of a new application image.
       */
      
      // Notify Application
      if (oadTargetWriteCB != NULL)
      {
        (*oadTargetWriteCB)(OAD_WRITE_IDENTIFY_REQ, connHandle, pValue);
      }
    }
    else if (!memcmp(pAttr->type.uuid, oadCharUUID[OAD_CHAR_IMG_BLOCK], 
                         ATT_UUID_SIZE))
    {
      /* The OAD manager has sent a block from the new image. */
      
      // Notify the application.
      if (oadTargetWriteCB != NULL)
      {
        (*oadTargetWriteCB)(OAD_WRITE_BLOCK_REQ, connHandle, pValue);
      }
    }
    else
    {
      status = ATT_ERR_ATTR_NOT_FOUND; // Should never get here!
    }    
  }

  return status;
}
开发者ID:ClarePhang,项目名称:ALL_SmartBatterySwitch_CC2640,代码行数:71,代码来源:oad_target.c


示例8: scanParamWriteAttrCB

/*********************************************************************
 * @fn      scanParamWriteAttrCB
 *
 * @brief   Validate attribute data prior to a write operation
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr - pointer to attribute
 * @param   pValue - pointer to data to be written
 * @param   len - length of data
 * @param   offset - offset of the first octet to be written
 * @param   complete - whether this is the last packet
 * @param   oper - whether to validate and/or write attribute value
 *
 * @return  Success or Failure
 */
static bStatus_t scanParamWriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                  uint8 *pValue, uint8 len, uint16 offset )
{
  bStatus_t status = SUCCESS;

  // Make sure it's not a blob operation (no attributes in the profile are long)
  if ( offset > 0 )
  {
    return ( ATT_ERR_ATTR_NOT_LONG );
  }

  uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);

  // Only one writeable attribute
  if ( uuid == SCAN_INTERVAL_WINDOW_UUID )
  {
    // require encryption
    if ( linkDB_Encrypted( connHandle ) == FALSE )
    {
      return ( ATT_ERR_INSUFFICIENT_ENCRYPT );
    }

    if ( len == SCAN_INTERVAL_WINDOW_CHAR_LEN )
    {
      uint16 interval = BUILD_UINT16( pValue[0], pValue[1] );
      uint16 window = BUILD_UINT16( pValue[0], pValue[1] );

      // Validate values
      if ( window <= interval )
      {
        osal_memcpy( pAttr->pValue, pValue, len );

        (*scanParamServiceCB)( SCAN_INTERVAL_WINDOW_SET );
      }
      else
      {
        status = ATT_ERR_INVALID_VALUE;
      }
    }
    else
    {
      status = ATT_ERR_INVALID_VALUE_SIZE;
    }
  }
  else if ( uuid == GATT_CLIENT_CHAR_CFG_UUID )
  {
    status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                             offset, GATT_CLIENT_CFG_NOTIFY );
  }
  else
  {
    status = ATT_ERR_ATTR_NOT_FOUND;
  }

  return ( status );
}
开发者ID:ClarePhang,项目名称:CC2540,代码行数:71,代码来源:scanparamservice.c


示例9: audioProfile_WriteAttrCB

/*********************************************************************
 * @fn      audioProfile_WriteAttrCB
 *
 * @brief   Validate attribute data prior to a write operation
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr - pointer to attribute
 * @param   pValue - pointer to data to be written
 * @param   len - length of data
 * @param   offset - offset of the first octet to be written
 * @param   method - type of read message
 *
 * @return  SUCCESS, ATT_ERR_INSUFFICIENT_AUTHOR,
 *          ATT_ERR_ATTR_NOT_LONG, or ATT_ERR_INVALID_HANDLE
 */
static bStatus_t audioProfile_WriteAttrCB(uint16 connHandle,
                                          gattAttribute_t *pAttr,
                                          uint8 *pValue,
                                          uint16 len,
                                          uint16 offset,
                                          uint8 method)
{
  bStatus_t status = SUCCESS;

  if (offset != 0)
  {
    return ATT_ERR_ATTR_NOT_LONG;
  }

  if (pAttr->type.len == ATT_BT_UUID_SIZE)
  {
    // 16-bit UUID
    uint16 uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
    switch (uuid)
    {
      case GATT_CLIENT_CHAR_CFG_UUID:
        status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
                                                offset, GATT_CLIENT_CFG_NOTIFY);
        break;

      default:
        // Should never get here!
        status = ATT_ERR_ATTR_NOT_FOUND;
        break;
    }
  }
  else if (pAttr->type.len == ATT_UUID_SIZE)
  {
    // 128-bit UUID
    uint16 uuid = BUILD_UINT16(pAttr->type.uuid[12], pAttr->type.uuid[13]);
    switch (uuid)
    {
      case AUDIOPROFILE_START_UUID:
      case AUDIOPROFILE_AUDIO_UUID:
        // Write not permitted
        status = ATT_ERR_WRITE_NOT_PERMITTED;
        break;

      default:
        // Should never get here!
        status = ATT_ERR_ATTR_NOT_FOUND;
        break;
    }
  }
  else
  {
    status = ATT_ERR_INVALID_HANDLE;
  }

  return status;
}
开发者ID:dgiovanelli,项目名称:climb.stfirmware_BLEstack2.2,代码行数:71,代码来源:audio_profile.c


示例10: heartRate_WriteAttrCB

/*********************************************************************
 * @fn      heartRate_WriteAttrCB
 *
 * @brief   Validate attribute data prior to a write operation
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr - pointer to attribute
 * @param   pValue - pointer to data to be written
 * @param   len - length of data
 * @param   offset - offset of the first octet to be written
 * @param   method - type of write message 
 *
 * @return  SUCCESS, blePending or Failure
 */
static bStatus_t heartRate_WriteAttrCB(uint16_t connHandle,
                                       gattAttribute_t *pAttr, uint8_t *pValue,
                                       uint16_t len, uint16_t offset,
                                       uint8_t method)
{
  bStatus_t status = SUCCESS;
 
  uint16 uuid = BUILD_UINT16(pAttr->type.uuid[0], pAttr->type.uuid[1]);
  switch (uuid)
  {
    case HEARTRATE_CTRL_PT_UUID:
      if (offset > 0)
      {
        status = ATT_ERR_ATTR_NOT_LONG;
      }
      else if (len != 1)
      {
        status = ATT_ERR_INVALID_VALUE_SIZE;
      }
      else if (*pValue != HEARTRATE_COMMAND_ENERGY_EXP)
      {
        status = HEARTRATE_ERR_NOT_SUP;
      }
      else
      {
        *(pAttr->pValue) = pValue[0];
        
        (*heartRateServiceCB)(HEARTRATE_COMMAND_SET);
        
      }
      break;

    case GATT_CLIENT_CHAR_CFG_UUID:
      status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
                                               offset, GATT_CLIENT_CFG_NOTIFY);
      if (status == SUCCESS)
      {
        uint16 charCfg = BUILD_UINT16(pValue[0], pValue[1]);

        (*heartRateServiceCB)((charCfg == GATT_CFG_NO_OPERATION) ?
                                HEARTRATE_MEAS_NOTI_DISABLED :
                                HEARTRATE_MEAS_NOTI_ENABLED);
      }
      break;       
 
    default:
      status = ATT_ERR_ATTR_NOT_FOUND;
      break;
  }

  return (status);
}
开发者ID:ClarePhang,项目名称:ALL_SmartBatterySwitch_CC2640,代码行数:66,代码来源:heartrateservice.c


示例11: sensor_WriteAttrCB

/*********************************************************************
* @fn      sensor_WriteAttrCB
*
* @brief   Validate attribute data prior to a write operation
*
* @param   connHandle - connection message was received on
* @param   pAttr - pointer to attribute
* @param   pValue - pointer to data to be written
* @param   len - length of data
* @param   offset - offset of the first octet to be written
*
* @return  Success or Failure
*/
static bStatus_t sensor_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                           uint8 *pValue, uint8 len, uint16 offset )
{
  bStatus_t status = SUCCESS;
  uint8 notifyApp = 0xFF;
  uint16 uuid;

  // If attribute permissions require authorization to write, return error
  if ( gattPermitAuthorWrite( pAttr->permissions ) )
  {
    // Insufficient authorization
    return ( ATT_ERR_INSUFFICIENT_AUTHOR );
  }

  if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
    // Invalid handle
    return ATT_ERR_INVALID_HANDLE;
  }

  switch ( uuid )
  {
    case SENSOR_DATA_UUID:
      // Should not get here
      break;

    case GATT_CLIENT_CHAR_CFG_UUID:
      status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                              offset, GATT_CLIENT_CFG_NOTIFY );
      break;

    default:
      // Should never get here!
      status = ATT_ERR_ATTR_NOT_FOUND;
      break;
  }

  // If a charactersitic value changed then callback function to notify application of change
  if ( (notifyApp != 0xFF ) && sensor_AppCBs && sensor_AppCBs->pfnSensorChange )
  {
    sensor_AppCBs->pfnSensorChange( notifyApp );
  }

  return ( status );
}
开发者ID:jackchased,项目名称:ble-firmware,代码行数:57,代码来源:pirservice.c


示例12: temp_WriteAttrCB

/*********************************************************************
 * @fn      temp_WriteAttrCB
 *
 * @brief   Validate attribute data prior to a write operation
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr - pointer to attribute
 * @param   pValue - pointer to data to be written
 * @param   len - length of data
 * @param   offset - offset of the first octet to be written
 * @param   complete - whether this is the last packet
 * @param   oper - whether to validate and/or write attribute value  
 *
 * @return  Success or Failure
 */
static bStatus_t temp_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
        uint8 *pValue, uint8 len, uint16 offset )
{
  bStatus_t status = ATT_ERR_ATTR_NOT_FOUND;

  if ( pAttr->type.len == ATT_BT_UUID_SIZE )
  {
    uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
    switch ( uuid )
    {
      case GATT_CLIENT_CHAR_CFG_UUID:
        status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                                 offset, GATT_CLIENT_CFG_NOTIFY );

        if (GATTServApp_ReadCharCfg(connHandle, valueConfigCoordinates) & GATT_CLIENT_CFG_NOTIFY) {
          iDoTurnOnTemp();
        } else {
          iDoTurnOffTemp();
        }
        break;
              
      case TEMP_UUID:
        if (len != sizeof(struct temp_ts)) {
          return ATT_ERR_INVALID_VALUE_SIZE;
        }
        recorder_set_read_base_ts((struct calendar *)(pValue + sizeof(struct temp)));
        status = SUCCESS;
        break;
        
      case TEMP_TIME_UUID:
        if (len != sizeof(struct calendar)) {
          return ATT_ERR_INVALID_VALUE_SIZE;
        }
        recorder_set_calendar_time((struct calendar *)pValue);
        status = SUCCESS;
        break;

      default:
        status = ATT_ERR_ATTR_NOT_FOUND;
    }
  }
  return ( status );
}
开发者ID:qodome,项目名称:Firmware,代码行数:58,代码来源:temperature.c


示例13: oadWriteAttrCB

/*********************************************************************
 * @fn      oadWriteAttrCB
 *
 * @brief   Validate and Write attribute data
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr - pointer to attribute
 * @param   pValue - pointer to data to be written
 * @param   len - length of data
 * @param   offset - offset of the first octet to be written
 * @param   method - type of write message 
 *
 * @return  SUCCESS, blePending or Failure
 */
static bStatus_t oadWriteAttrCB(uint16 connHandle, gattAttribute_t *pAttr,
                                uint8 *pValue, uint8 len, uint16 offset,
                                uint8 method)
{
  bStatus_t status = SUCCESS;

  if ( pAttr->type.len == ATT_BT_UUID_SIZE )
  {
    // 16-bit UUID
    uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
    if ( uuid == GATT_CLIENT_CHAR_CFG_UUID)
    {
      status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                               offset, GATT_CLIENT_CFG_NOTIFY );
    }
    else
    {
      status = ATT_ERR_ATTR_NOT_FOUND; // Should never get here!
    }
  }
  else
  {
    // 128-bit UUID
    if (osal_memcmp(pAttr->type.uuid, oadCharUUID[OAD_CHAR_IMG_IDENTIFY], ATT_UUID_SIZE))
    {
      status = oadImgIdentifyWrite( connHandle, pValue );
    }
    else if (osal_memcmp(pAttr->type.uuid, oadCharUUID[OAD_CHAR_IMG_BLOCK], ATT_UUID_SIZE))
    {
      status = oadImgBlockWrite( connHandle, pValue );
    }
    else
    {
      status = ATT_ERR_ATTR_NOT_FOUND; // Should never get here!
    }
  }

  return status;
}
开发者ID:DRuffer,项目名称:coinForth,代码行数:53,代码来源:oad_target.c


示例14: sensor_WriteAttrCB


//.........这里部分代码省略.........
  {
    // Insufficient authorization
    return ( ATT_ERR_INSUFFICIENT_AUTHOR );
  }

  if (utilExtractUuid16(pAttr,&uuid) == FAILURE) {
    // Invalid handle
    return ATT_ERR_INVALID_HANDLE;
  }

  switch ( uuid )
  {
    case SENSOR_DATA_UUID:
    case SENSOR_CALIBR_UUID:
      // Should not get here
      break;

    case SENSOR_CONFIG_UUID:
      // Validate the value
      // Make sure it's not a blob oper
      if ( offset == 0 )
      {
        if ( len != 1 )
        {
          status = ATT_ERR_INVALID_VALUE_SIZE;
        }
      }
      else
      {
        status = ATT_ERR_ATTR_NOT_LONG;
      }

      // Write the value
      if ( status == SUCCESS )
      {
        uint8 *pCurValue = (uint8 *)pAttr->pValue;

        *pCurValue = pValue[0];

        if( pAttr->pValue == &sensorCfg )
        {
          notifyApp = SENSOR_CONF;
        }
      }
      break;

    case SENSOR_PERIOD_UUID:
      // Validate the value
      // Make sure it's not a blob oper
      if ( offset == 0 )
      {
        if ( len != 1 )
        {
          status = ATT_ERR_INVALID_VALUE_SIZE;
        }
      }
      else
      {
        status = ATT_ERR_ATTR_NOT_LONG;
      }
      // Write the value
      if ( status == SUCCESS )
      {
        if (pValue[0]>=(SENSOR_MIN_UPDATE_PERIOD/SENSOR_PERIOD_RESOLUTION))
        {

          uint8 *pCurValue = (uint8 *)pAttr->pValue;
          *pCurValue = pValue[0];

          if( pAttr->pValue == &sensorPeriod )
          {
            notifyApp = SENSOR_PERI;
          }
        }
        else
        {
           status = ATT_ERR_INVALID_VALUE;
        }
      }
      break;

    case GATT_CLIENT_CHAR_CFG_UUID:
      status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                              offset, GATT_CLIENT_CFG_NOTIFY );
      break;

    default:
      // Should never get here!
      status = ATT_ERR_ATTR_NOT_FOUND;
      break;
  }

  // If a charactersitic value changed then callback function to notify application of change
  if ( (notifyApp != 0xFF ) && sensor_AppCBs && sensor_AppCBs->pfnSensorChange )
  {
    sensor_AppCBs->pfnSensorChange( notifyApp );
  }

  return ( status );
}
开发者ID:aidaima,项目名称:RemoteControl-Car,代码行数:101,代码来源:barometerservice.c


示例15: simpleProfile_WriteAttrCB

/*********************************************************************
 * @fn      simpleProfile_WriteAttrCB
 *
 * @brief   Validate attribute data prior to a write operation
 *
 * @param   connHandle - connection message was received on
 * @param   pAttr - pointer to attribute
 * @param   pValue - pointer to data to be written
 * @param   len - length of data
 * @param   offset - offset of the first octet to be written
 *
 * @return  Success or Failure
 */
static bStatus_t simpleProfile_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                 uint8 *pValue, uint8 len, uint16 offset )
{
  bStatus_t status = SUCCESS;
  uint8 notifyApp = 0xFF;
  
  // If attribute permissions require authorization to write, return error
  if ( gattPermitAuthorWrite( pAttr->permissions ) )
  {
    // Insufficient authorization
    return ( ATT_ERR_INSUFFICIENT_AUTHOR );
  }
  
  if ( pAttr->type.len == ATT_BT_UUID_SIZE )
  {
    // 16-bit UUID
    uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
    switch ( uuid )
    {
      case SIMPLEPROFILE_CHAR1_UUID:
      case SIMPLEPROFILE_CHAR3_UUID:

        //Validate the value
        // Make sure it's not a blob oper
        if ( offset == 0 )
        {
          if ( len != 1 )
          {
            status = ATT_ERR_INVALID_VALUE_SIZE;
          }
        }
        else
        {
          status = ATT_ERR_ATTR_NOT_LONG;
        }
        
        //Write the value
        if ( status == SUCCESS )
        {
          uint8 *pCurValue = (uint8 *)pAttr->pValue;        
          *pCurValue = pValue[0];

          if( pAttr->pValue == &simpleProfileChar1 )
          {
            notifyApp = SIMPLEPROFILE_CHAR1;        
          }
          else
          {
            notifyApp = SIMPLEPROFILE_CHAR3;           
          }
        }
             
        break;

      case GATT_CLIENT_CHAR_CFG_UUID:
        status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                                 offset, GATT_CLIENT_CFG_NOTIFY );
        break;
        
        
      case SIMPLEPROFILE_CHAR6_UUID:
          //Validate the value
        // Make sure it's not a blob oper
        if ( offset == 0 )
        {
          if ( len != SIMPLEPROFILE_CHAR6_LEN )
          {
            status = ATT_ERR_INVALID_VALUE_SIZE;
          }
        }
        else
        {
          status = ATT_ERR_ATTR_NOT_LONG;
        }
        
        //Write the value
        if ( status == SUCCESS )
        {
          VOID osal_memcpy(pAttr->pValue, pValue, len);
          notifyApp = SIMPLEPROFILE_CHAR6; 
        }
        
        break;
      default:
        // Should never get here! (characteristics 2 and 4 do not have write permissions)
        status = ATT_ERR_ATTR_NOT_FOUND;
        break;
//.........这里部分代码省略.........
开发者ID:jiangrunwu,项目名称:ble_stan,代码行数:101,代码来源:simpleGATTprofile.c


示例16: ccService_WriteAttrCB

/*********************************************************************
* @fn      ccService_WriteAttrCB
*
* @brief   Validate attribute data prior to a write operation
*
* @param   connHandle - connection message was received on
* @param   pAttr - pointer to attribute
* @param   pValue - pointer to data to be written
* @param   len - length of data
* @param   offset - offset of the first octet to be written
*
* @return  Success or Failure
*/
static bStatus_t ccService_WriteAttrCB( uint16 connHandle, gattAttribute_t *pAttr,
                                       uint8 *pValue, uint8 len, uint16 offset, uint8 method )
{
  uint16 uuid;
  bStatus_t status = SUCCESS;
  uint8 notifyApp = 0xFF;

  // If attribute permissions require authorization to write, return error
  if ( gattPermitAuthorWrite( pAttr->permissions ) )
  {
    // Insufficient authorization
    return ( ATT_ERR_INSUFFICIENT_AUTHOR );
  }

  if (utilExtractUuid16(pAttr,&uuid) == FAILURE)
  {
    // Invalid handle
    return ATT_ERR_INVALID_HANDLE;
  }

  switch ( uuid )
  {
  case CCSERVICE_CHAR2_UUID:

    // Validate the value
    // Make sure it's not a blob oper
    if ( offset == 0 )
    {
      if ( len != CCSERVICE_CHAR2_LEN )
      {
        status = ATT_ERR_INVALID_VALUE_SIZE;
      }
    }
    else
    {
      status = ATT_ERR_ATTR_NOT_LONG;
    }

    // Write the value
    if ( status == SUCCESS )
    {
      VOID osal_memcpy( ccServiceChar2, pValue, CCSERVICE_CHAR2_LEN );
      notifyApp = CCSERVICE_CHAR2;
    }

    break;
  case CCSERVICE_CHAR3_UUID:

    if ( offset == 0 )
    {
      if ( len != 1 )
      {
        status = ATT_ERR_INVALID_VALUE_SIZE;
      }
    }
    else
    {
      status = ATT_ERR_ATTR_NOT_LONG;
    }

    // Write the value
    if ( status == SUCCESS )
    {
      uint8 *pCurValue = (uint8 *)pAttr->pValue;
      *pCurValue = pValue[0];
      notifyApp = CCSERVICE_CHAR3;
    }

    break;

  case GATT_CLIENT_CHAR_CFG_UUID:
      status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                              offset, GATT_CLIENT_CFG_NOTIFY );
      break;

  default:
    status = ATT_ERR_ATTR_NOT_FOUND;
    break;
  }


  // If a charactersitic value changed then callback function to notify application of change
  if ( (notifyApp != 0xFF ) && ccService_AppCBs && ccService_AppCBs->pfnCcChange )
  {
    ccService_AppCBs->pfnCcChange( notifyApp );
  }

//.........这里部分代码省略.........
开发者ID:aidaima,项目名称:RemoteControl-Car,代码行数:101,代码来源:ccservice.c


示例17: lights_WriteAttrCB


//.........这里部分代码省略.........
    uint16 uuid = BUILD_UINT16( pAttr->type.uuid[0], pAttr->type.uuid[1]);
    switch ( uuid )
    {
      case LIGHTSPROFILE_RED_UUID:
      case LIGHTSPROFILE_GREEN_UUID:
      case LIGHTSPROFILE_BLUE_UUID:
      case LIGHTSPROFILE_WHITE_UUID:

        //Validate the value
        // Make sure it's not a blob oper
        if ( offset == 0 )
        {
          if ( len != 1 )
          {
            status = ATT_ERR_INVALID_VALUE_SIZE;
          }
        }
        else
        {
          status = ATT_ERR_ATTR_NOT_LONG;
        }
        
        // Write the value
        if ( status == SUCCESS )
        {
          uint8 *pCurValue = (uint8 *)pAttr->pValue;        
          *pCurValue = pValue[0];

          if( pAttr->pValue == &lightsProfileRGBW[0] )
          {
            notifyApp = LIGHTSPROFILE_RED;        
          }

          if( pAttr->pValue == &lightsProfileRGBW[1] )
          {
            notifyApp = LIGHTSPROFILE_GREEN;        
          }

          if( pAttr->pValue == &lightsProfileRGBW[2] )
          {
            notifyApp = LIGHTSPROFILE_BLUE;        
          }

          if( pAttr->pValue == &lightsProfileRGBW[3] )
          {
            notifyApp = LIGHTSPROFILE_WHITE;        
          }          
        }
             
        break;

    case LIGHTSPROFILE_RGBW_UUID:
      if ( offset == 0 )
      {
        if ( len != LIGHTSPROFILE_RGBW_LEN )
        {
          status = ATT_ERR_INVALID_VALUE_SIZE;
        }
      }
      else
      {
        status = ATT_ERR_ATTR_NOT_LONG;
      }
      if ( status == SUCCESS )
      {
        uint8 *pCurValue = (uint8 *)pAttr->pValue;        
        memcpy( pCurValue, pValue, LIGHTSPROFILE_RGBW_LEN );

        if( (int)pAttr->pValue == (int)&lightsProfileRGBW )
        {
          notifyApp = LIGHTSPROFILE_RGBW;
        }
      }
      break;
        
      case GATT_CLIENT_CHAR_CFG_UUID:
        status = GATTServApp_ProcessCCCWriteReq( connHandle, pAttr, pValue, len,
                                                 offset, GATT_CLIENT_CFG_NOTIFY );
        break;
        
      default:
        // Should never get here!
        status = ATT_ERR_ATTR_NOT_FOUND;
        break;
    }
  }
  else
  {
    // 128-bit UUID
    status = ATT_ERR_INVALID_HANDLE;
  }

  // If a characteristic value changed then callback function to notify application of change
  if ( (notifyApp != 0xFF ) && lights_AppCBs && lights_AppCBs->pfnLightsProfileChange )
  {
    lights_AppCBs->pfnLightsProfileChange( notifyApp );  
  }
  
  return ( status );
}
开发者ID:PolymorphicLabs,项目名称:PML-Firmware,代码行数:101,代码来源:lightservice.c


示例18: sensor_WriteAttrCB


//.........这里部分代码省略.........
    // Write the value
    if (status == SUCCESS)
    {
      memcpy(pAttr->pValue, pValue, len);
      sensor_writeRegister();
    }
    break;
    
  case REGISTER_ADDR_UUID:
    // Validate the value
    // Make sure it's not a blob oper
    if (offset == 0)
    {
      if (len > REGISTER_ADDRESS_LEN )
      {
        status = ATT_ERR_INVALID_VALUE_SIZE;
      }
    }
    else
    {
      status = ATT_ERR_ATTR_NOT_LONG;
    }
    
    // Write the value
    if (status == SUCCESS)
    {
      if (pValue[0] <= REGISTER_DATA_LEN )
      {
        memcpy(pAttr->pValue, pValue, len);
        // Address changed; read data
        sensor_readRegister();
        
        if (pAttr->pValue == (uint8_t*)&registerAddress )
        {
          notifyApp = REGISTER_ADDR;
        }
      }
      else
      {
        status = ATT_ERR_INVALID_VALUE;
      }
    }
    break;
    
  case REGISTER_DEV_UUID:
    // Validate the value
    // Make sure it's not a blob oper
    if (offset == 0)
    {
      if (len != REGISTER_DEVICE_LEN )
      {
        status = ATT_ERR_INVALID_VALUE_SIZE;
      }
    }
    else
    {
      status = ATT_ERR_ATTR_NOT_LONG;
    }
    // Write the value
    if (status == SUCCESS)
    {
      if (pValue[0] < REGISTER_INTERFACE_NUM )
      {
        memcpy(pAttr->pValue, pValue, REGISTER_DEVICE_LEN);
        
        if (pAttr->pValue == (uint8_t*)&registerDeviceID )
        {
          notifyApp = REGISTER_DEV;
          // bspI2cReset();
          
          sensor_initRegister(registerDeviceID[0], registerDeviceID[1]);
        }
      }
        else
        {
          status = ATT_ERR_INVALID_VALUE;
        }
      }
      break;
      
    case GATT_CLIENT_CHAR_CFG_UUID:
      status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len,
                                              offset, GATT_CLIENT_CFG_NOTIFY);
      break;
      
    default:
      // Should never get here!
      status = ATT_ERR_ATTR_NOT_FOUND;
      break;
    }
    
    // If a characteristic value changed then callback function 
    // to notify application of change
    if ((notifyApp != 0xFF ) && sensor_AppCBs && sensor_AppCBs->pfnSensorChange)
    {
      sensor_AppCBs->pfnSensorChange(notifyApp);
    }
    
    return (status);
  }
开发者ID:ClarePhang,项目名称:ALL_SmartBatterySwitch_CC2640,代码行数:101,代码来源:registerservice.c


示例19: buttonsProfile_WriteAttrCB


//.........这里部分代码省略.........
			case BLE_BUTTONS_A_CHAR_UUID:
				P1_7 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_B_CHAR_UUID:
				P1_1 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_X_CHAR_UUID:
				P0_6 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_Y_CHAR_UUID:
				P0_5 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_UP_CHAR_UUID:
				P2_0 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_DN_CHAR_UUID:
				if (getValue(pAttr, pValue, len, offset, &status) > 0)
				{
					I2CIO |= 0x02; // SCL
				}
				else
				{
					I2CIO &= ~0x02; // SCL
				}
				break;
			case BLE_BUTTONS_L_CHAR_UUID:
				P0_7 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_R_CHAR_UUID:
				P1_6 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_LB_CHAR_UUID:
				P0_2 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_RB_CHAR_UUID:
				if (getValue(pAttr, pValue, len, offset, &status) > 0)
				{
					I2CIO |= 0x01; // SDA
				}
				else
				{
					I2CIO &= ~0x01; // SDA
				}			
				break;
			case BLE_BUTTONS_START_CHAR_UUID:
				P0_1 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_BACK_CHAR_UUID:
				P0_0 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_GUIDE_CHAR_UUID:
				P1_0 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_LS_CHAR_UUID:
				P0_3 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_RS_CHAR_UUID:
				P0_4 = getValue(pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_LX_CHAR_UUID:
				setChannelValue(6 - 1, pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_LY_CHAR_UUID:
				setChannelValue(5 - 1, pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_RX_CHAR_UUID:
				setChannelValue(4 - 1, pAttr, pValue, len, offset, &status);
				break;
			case BLE_BUTTONS_RY_CHAR_UUID:
				setChannelValue(2 - 1, pAttr, pValue 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GATTServApp_RegisterService函数代码示例发布时间:2022-05-30
下一篇:
C++ GATTServApp_InitCharCfg函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap