微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI蓝牙设计交流 > osal_memcpy( simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN ); 函数如何发送数据的

osal_memcpy( simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN ); 函数如何发送数据的

时间:10-02 整理:3721RD 点击:

bStatus_t SimpleProfile_SetParameter( uint8 param, uint8 len, void *value )
{
    bStatus_t ret = SUCCESS;
    switch ( param )
    {

      case SIMPLEPROFILE_CHAR1:

      ...

    case SIMPLEPROFILE_CHAR2:

    ...

    case SIMPLEPROFILE_CHAR3:

    ...

    case SIMPLEPROFILE_CHAR4:

    ...

    case SIMPLEPROFILE_CHAR5:  
        if ( len == SIMPLEPROFILE_CHAR5_LEN )
        {
             VOID osal_memcpy( simpleProfileChar5, value, SIMPLEPROFILE_CHAR5_LEN );
        }
        else
        {
           ret = bleInvalidRange;
        }
        break;

        default:
            ret = INVALIDPARAMETER;
        break;
      }

    return ( ret );
}

由主机主动读取吗,没有见到GATT_Notification();

该函数主要功能是Generic memory copy 复制内存,将源地址的内容拷贝到目的地址

void *osal_memcpy( void *dst, const void GENERIC *src, unsigned int len ) 的参数说明

           dst - destination address 目的地址

           src - source address     源地址

           len - number of bytes to copy  拷贝长度

case SIMPLEPROFILE_CHAR4: if ( len == sizeof ( uint8 ) ) { simpleProfileChar4 = *((uint8*)value); // See if Notification has been enabled GATTServApp_ProcessCharCfg( simpleProfileChar4Config, &simpleProfileChar4, FALSE, simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ), INVALID_TASK_ID, simpleProfile_ReadAttrCB ); } else { ret = bleInvalidRange; }

/*********************************************************************
 * @fn      GATTServApp_ProcessCharCfg
 *
 * @brief   Process Client Characteristic Configuration change.
 *
 * @param   charCfgTbl - characteristic configuration table.
 * @param   pValue - pointer to attribute value.
 * @param   authenticated - whether an authenticated link is required.
 * @param   attrTbl - attribute table.
 * @param   numAttrs - number of attributes in attribute table.
 * @param   taskId - task to be notified of confirmation.
 * @param   pfnReadAttrCB - read callback function pointer.
 *
 * @return  Success or Failure
 */
bStatus_t GATTServApp_ProcessCharCfg( gattCharCfg_t *charCfgTbl, uint8 *pValue,
                                      uint8 authenticated, gattAttribute_t *attrTbl,
                                      uint16 numAttrs, uint8 taskId,
                                      pfnGATTReadAttrCB_t pfnReadAttrCB )
{
  uint8 i;
  bStatus_t status = SUCCESS;

  // Verify input parameters
  if ( ( charCfgTbl == NULL ) || ( pValue == NULL ) ||
       ( attrTbl == NULL )    || ( pfnReadAttrCB == NULL ) )
  {
    return ( INVALIDPARAMETER );
  }

  for ( i = 0; i < linkDBNumConns; i++ )
  {
    gattCharCfg_t *pItem = &(charCfgTbl[i]);

    if ( ( pItem->connHandle != INVALID_CONNHANDLE ) &&
         ( pItem->value != GATT_CFG_NO_OPERATION ) )
    {
      gattAttribute_t *pAttr;

      // Find the characteristic value attribute
      pAttr = GATTServApp_FindAttr( attrTbl, numAttrs, pValue );
      if ( pAttr != NULL )
      {
        if ( pItem->value & GATT_CLIENT_CFG_NOTIFY )
        {
           status |= gattServApp_SendNotiInd( pItem->connHandle, GATT_CLIENT_CFG_NOTIFY,
                                              authenticated, pAttr, taskId, pfnReadAttrCB );
        }

        if ( pItem->value & GATT_CLIENT_CFG_INDICATE )
        {
           status |= gattServApp_SendNotiInd( pItem->connHandle, GATT_CLIENT_CFG_INDICATE,
                                              authenticated, pAttr, taskId, pfnReadAttrCB );
        }
      }
    }
  } // for

  return ( status );
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top