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

CC1310: 数据包传输时间过长

Part Number:CC1310

你好,

   我现在基于TI 15.4中的collector与sensor例程,想通过sensor向collector每一秒发送包含一百个ADC数据的数据包,但是我发现在实际传输过程中,数据包传输时长远远大于一秒钟,所以,我想询问一下有无对应的解决办法。

谢谢!

Alex Zhang:

您好,方便把发送数据包的代码发到这边吗?

,

SHAO MENG:

感谢您的回复!

我在Sensor 部分中我将原来发送温度数据部分替换成发送100个ADC数据,在代码中可以看到,下面是sensor向collector发送数据部分的代码,数据可以成功发送,但是就是两次发送的时间间隔太长了,完全无法满足项目需求。

static void processSensorMsgEvt(void){ Smsgs_sensorMsg_t sensor; uint32_t stat;

memset(&sensor, 0, sizeof(Smsgs_sensorMsg_t));

ApiMac_mlmeGetReqUint32(ApiMac_attribute_diagRxSecureFail, &stat); Sensor_msgStats.rxDecryptFailures = (uint16_t)stat;

ApiMac_mlmeGetReqUint32(ApiMac_attribute_diagTxSecureFail, &stat); Sensor_msgStats.txEncryptFailures = (uint16_t)stat;

ApiMac_mlmeGetReqArray(ApiMac_attribute_extendedAddress, sensor.extAddress);

/* fill in the message */ sensor.frameControl = configSettings.frameControl; if(sensor.frameControl & Smsgs_dataFields_tempSensor) {

memcpy(&sensor.tempSensor, &tempSensor, sizeof(Smsgs_tempSensorField_t)); } if(sensor.frameControl & Smsgs_dataFields_lightSensor) { memcpy(&sensor.lightSensor, &lightSensor, sizeof(Smsgs_lightSensorField_t)); } if(sensor.frameControl & Smsgs_dataFields_humiditySensor) { memcpy(&sensor.humiditySensor, &humiditySensor, sizeof(Smsgs_humiditySensorField_t)); } if(sensor.frameControl & Smsgs_dataFields_msgStats) { memcpy(&sensor.msgStats, &Sensor_msgStats, sizeof(Smsgs_msgStatsField_t)); } if(sensor.frameControl & Smsgs_dataFields_configSettings) { sensor.configSettings.pollingInterval = configSettings.pollingInterval; sensor.configSettings.reportingInterval = configSettings .reportingInterval; }

/* inform the user interface */ Ssf_sensorReadingUpdate(&sensor);

/* send the data to the collector */ sendSensorMessage(&collectorAddr, &sensor);}

static bool sendSensorMessage(ApiMac_sAddr_t *pDstAddr, Smsgs_sensorMsg_t *pMsg){ bool ret = false; uint8_t *pMsgBuf; uint16_t len = SMSGS_BASIC_SENSOR_LEN;

/* Figure out the length */ if(pMsg->frameControl & Smsgs_dataFields_tempSensor) { len += SMSGS_SENSOR_TEMP_LEN; } if(pMsg->frameControl & Smsgs_dataFields_lightSensor) { len += SMSGS_SENSOR_LIGHT_LEN; } if(pMsg->frameControl & Smsgs_dataFields_humiditySensor) { len += SMSGS_SENSOR_HUMIDITY_LEN; } if(pMsg->frameControl & Smsgs_dataFields_msgStats) { //len += SMSGS_SENSOR_MSG_STATS_LEN; len += sizeof(Smsgs_msgStatsField_t); } if(pMsg->frameControl & Smsgs_dataFields_configSettings) { len += SMSGS_SENSOR_CONFIG_SETTINGS_LEN; }

pMsgBuf = (uint8_t *)Ssf_malloc(len); if(pMsgBuf) { uint8_t *pBuf = pMsgBuf;

*pBuf++ = (uint8_t)Smsgs_cmdIds_sensorData;

memcpy(pBuf, pMsg->extAddress, SMGS_SENSOR_EXTADDR_LEN); pBuf += SMGS_SENSOR_EXTADDR_LEN;

pBuf = Util_bufferUint16(pBuf,pMsg->frameControl);

/* Buffer data in order of frameControl mask, starting with LSB */ if(pMsg->frameControl & Smsgs_dataFields_tempSensor) { for(int i=0;i<100;i++){ pBuf = Util_bufferUint16(pBuf, pMsg->tempSensor.ambienceTemp[i]); } //pBuf = Util_bufferUint16(pBuf, pMsg->tempSensor.ambienceTemp); //pBuf = Util_bufferUint16(pBuf, pMsg->tempSensor.objectTemp); } if(pMsg->frameControl & Smsgs_dataFields_lightSensor) { pBuf = Util_bufferUint16(pBuf, pMsg->lightSensor.rawData); } if(pMsg->frameControl & Smsgs_dataFields_humiditySensor) { pBuf = Util_bufferUint16(pBuf, pMsg->humiditySensor.temp); pBuf = Util_bufferUint16(pBuf, pMsg->humiditySensor.humidity); } if(pMsg->frameControl & Smsgs_dataFields_msgStats) { pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.joinAttempts); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.joinFails); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.msgsAttempted); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.msgsSent); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.trackingRequests); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.trackingResponseAttempts); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.trackingResponseSent); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.configRequests); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.configResponseAttempts); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.configResponseSent); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.channelAccessFailures); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.macAckFailures); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.otherDataRequestFailures); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.syncLossIndications); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.rxDecryptFailures); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.txEncryptFailures); pBuf = Util_bufferUint16(pBuf, Ssf_resetCount); pBuf = Util_bufferUint16(pBuf, Ssf_resetReseason); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.joinTime); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.interimDelay); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.numBroadcastMsgRcvd); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.numBroadcastMsglost); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.avgE2EDelay); pBuf = Util_bufferUint16(pBuf, pMsg->msgStats.worstCaseE2EDelay); } if(pMsg->frameControl & Smsgs_dataFields_configSettings) { pBuf = Util_bufferUint32(pBuf, pMsg->configSettings.reportingInterval); pBuf = Util_bufferUint32(pBuf, pMsg->configSettings.pollingInterval);

}

ret = Sensor_sendMsg(Smsgs_cmdIds_sensorData, pDstAddr, true, len, pMsgBuf); if(ret == true){ LCD_WRITE_STRING("Data Success Send", 2); } else{ LCD_WRITE_STRING("Data Success Failed", 2); }

Ssf_free(pMsgBuf); }

return (ret);}

Smsgs_tempSensorField_t修改后的结构

typedef struct _Smsgs_tempsensorfield_t{ /*! Ambience Chip Temperature – each value represents a 0.01 C degree, so a value of 2475 represents 24.75 C. */ uint16_t ambienceTemp[100]; /*! Object Temperature – each value represents a 0.01 C degree, so a value of 2475 represents 24.75 C. */ //int16_t objectTemp;} Smsgs_tempSensorField_t;

期待收到您的回复,非常感谢!

,

Alex Zhang:

好的,感谢您发过来的代码,我将需要一些时间来跟进您这边的问题。

,

Alex Zhang:

您是否调整了传感器的报告间隔?您的意思是,此消息本身的发送时间超过1秒吗?

,

SHAO MENG:

是的,我调整消息发送的时间间隔为一秒钟发送一次数据消息。具体代码如下所示:

sensor部分关于时间的配置

/*! Default Polling interval in milliseconds. It will get updated upon reception of a config request message */#define CONFIG_POLLING_INTERVAL 6000/*! PAN Advertisement Solicit trickle timer duration in milliseconds */#define CONFIG_PAN_ADVERT_SOLICIT_CLK_DURATION 6000/*! PAN Config Solicit trickle timer duration in milliseconds */#define CONFIG_PAN_CONFIG_SOLICIT_CLK_DURATION 6000/*! Default Reporting Interval – in milliseconds. It will get updated upon reception of a config request message */#define CONFIG_REPORTING_INTERVAL 1000#else/*! Default Polling interval in milliseconds. It will get updated upon reception of a config request message */#define CONFIG_POLLING_INTERVAL 60000/*! PAN Advertisement Solicit trickle timer duration in milliseconds */#define CONFIG_PAN_ADVERT_SOLICIT_CLK_DURATION 60000/*! PAN Config Solicit trickle timer duration in milliseconds */#define CONFIG_PAN_CONFIG_SOLICIT_CLK_DURATION 60000/*! Default Reporting Interval – in milliseconds. It will get updated upon reception of a config request message */#define CONFIG_REPORTING_INTERVAL 600000

collector关于时间的配置

/*! Reporting Interval – in milliseconds to be set on connected devices using configuration request messages */#define CONFIG_REPORTING_INTERVAL 90000/*! Polling interval in milliseconds to be set on connected devices using configuration request messages. Must be greater than or equal to default polling interval set on sensor devices */#define CONFIG_POLLING_INTERVAL 6000/*! Time interval in ms between tracking message intervals */#define TRACKING_DELAY_TIME 60000#else/*! Reporting Interval – in milliseconds to be set on connected devices using configuration request messages */#define CONFIG_REPORTING_INTERVAL 1000/*! Polling interval in milliseconds to be set on connected devices using configuration request messages. Must be greater than or equal to default polling interval set on sensor devices */#define CONFIG_POLLING_INTERVAL 60000/*! Time interval in ms between tracking message intervals */#define TRACKING_DELAY_TIME 300000

我通过Csf_deviceSensorDataUpdate(&pDataInd->srcAddr, pDataInd->rssi, &sensorData);函数将数据打印出来,我发现在两块开发板写入程序,第一次上电时,ADC的数据可以通过串口一秒钟打印一次,但是出现“Configrap:0x1"后,两块开发板之间数据包的发送时常便变得比较缓慢了。

,

Alex Zhang:

好的,感谢您的回复,我这边会继续跟进。

,

SHAO MENG:

collector关于时间的配置

/*!Reporting Interval – in milliseconds to be set on connected devices usingconfiguration request messages*/#define CONFIG_REPORTING_INTERVAL 90000

原来的时间配置错了,将这里的90000改成1000,现在可以实现一秒钟内完成数据的传输/*!Polling interval in milliseconds to be set on connected devices usingconfiguration request messages. Must be greater than or equal to defaultpolling interval set on sensor devices*/#define CONFIG_POLLING_INTERVAL 6000/*!Time interval in ms between tracking message intervals*/#define TRACKING_DELAY_TIME 60000#else/*!Reporting Interval – in milliseconds to be set on connected devices usingconfiguration request messages*/#define CONFIG_REPORTING_INTERVAL 1000/*!Polling interval in milliseconds to be set on connected devices usingconfiguration request messages. Must be greater than or equal to defaultpolling interval set on sensor devices*/#define CONFIG_POLLING_INTERVAL 60000/*!Time interval in ms between tracking message intervals*/#define TRACKING_DELAY_TIME 300000

,

Alex Zhang:

好的 我们这边也是考虑到这边的问题,很高兴能够帮助您解决问题,有问题欢迎来论坛交流学习,谢谢

,

SHAO MENG:

好的,非常感谢你们这段时间的持续关注。

非常感谢!!!

,

Alex Zhang:

不客气,有问题随时论坛交流。时间可能会慢一点,但是一定会帮助您去解决问题的

赞(0)
未经允许不得转载:TI中文支持网 » CC1310: 数据包传输时间过长
分享到: 更多 (0)