TI中文支持网
TI专业的中文技术问题搜集分享网站

数据分包发送

嗨,亲们:

    我将cc2541当做从机,向手机App发送数据(28Bytes),用的是GATTServApp_ProcessCharCfg()方法。由于数据>20Bytes,所以我分成两个14字节的字符串分开发送。

下面是我的周期函数:

        stat = SimpleProfile_GetParameter( SIMPLEPROFILE_CHAR3, &valueToCopy); 
        if( stat == SUCCESS )
        {
            SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof(uint8), &valueToCopy);
         }

        sprintf((char *)pBuffer, "%04d",2016);      //year(+4)       
        ……
        sprintf((char *)pBuffer + 24, "%02d",99); //一直往pBuffer中拷贝数据,共28个字节
        numBytes = osal_strlen(pBuffer);
        SK_SetParameter( SK_UART_ATTR, numBytes, pBuffer );  //发送函数

接着是我的发送函数:

bStatus_t SK_SetParameter( uint8 param, uint8 len, void *pValue )
{
  bStatus_t ret = SUCCESS;
  switch ( param )
  {
    case SK_UART_ATTR:
      if ( len > 0)      {             #ifdef HAL_UART_TRANS
       
        //发送第一段字符串(前14Bytes)
        char *p = pValue;
        osal_memcpy(skKeyPressed, p, len – 14);
        skKeyPressed_len = len – 14;
        GATTServApp_ProcessCharCfg( skConfig, skKeyPressed, FALSE,                                    simplekeysAttrTbl, GATT_NUM_ATTRS( simplekeysAttrTbl ),
                                    INVALID_TASK_ID );        
       
        //发送第二段字符串(后14Bytes)
        for(int i=0;i<len-14;i++)
        {
          skKeyPressed[i] = 0;
        }          p = p + 14;
        osal_memcpy(skKeyPressed, p, 14);
        skKeyPressed_len = 14;
        GATTServApp_ProcessCharCfg( skConfig, skKeyPressed, FALSE,                                    simplekeysAttrTbl, GATT_NUM_ATTRS( simplekeysAttrTbl ),
                                    INVALID_TASK_ID );
}
    可是这样干就是不行,调试结果:有几组是正确的(string1+string2),但是发着发着就错了(string2+string2……),就是第二段会连着发……why??
FST Zhang:

然而已经过去一天了,Ti的大牛们呢?请问是什么问题……探讨探讨~~

赞(0)
未经允许不得转载:TI中文支持网 » 数据分包发送
分享到: 更多 (0)