请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:LPSTK-CC1352R 当传感器断开连接然后重新连接到 CC1352P1收集器 Launchpad 时、传感器地址会发生变化!
我希望传感器在每次连接到收集器后都保持相同的身份或地址、以便于进行监控和快速识别、因为我将温度和湿度存储在 values...in 数据库中、如果传感器地址发生变化、 使用
任何解决方案时、这些值都不可靠?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
当传感器断开连接然后重新连接到 CC1352P1收集器 Launchpad 时、传感器地址会发生变化!
我希望传感器在每次连接到收集器后都保持相同的身份或地址、以便于进行监控和快速识别、因为我将温度和湿度存储在 values...in 数据库中、如果传感器地址发生变化、 使用
任何解决方案时、这些值都不可靠?
目前我正在使用项目"collector_CC1352P1_LAUNCHXL_tirtos7_ccs"、该项目位于:(Resource Explorer>Examples->TI 15.4-stack->collector->CCS Compiler)。
csf_getDevice 函数用于通过增量分配地址(第一个传感器的地址为0x0001、 第二个具有0x0002...如果我对第一个进行了分解,并且第二次将其与同一个收集器关联,则它将在0x0001处获得不同的地址。
您将得到一个解决方案,即每个传感器都具有一个标识符或一个固定地址。 您好!
我认为我不完全理解您的设置。CSF_getDevice 不用于分配地址、它仅用于检索设备信息。
请查看以下修改 的 csf_deviceSensorDataUpdate()函数(可在 csf.c 中找到)。 此修改说明了如何检索扩展的64位地址。 请关注第24至35行。
/*!
The application calls this function to indicate that a device
has reported sensor data.
Public function defined in csf.h
*/
void Csf_deviceSensorDataUpdate(ApiMac_sAddr_t *pSrcAddr, int8_t rssi,
Smsgs_sensorMsg_t *pMsg)
{
#ifndef POWER_MEAS
LED_toggle(gGreenLedHandle);
#endif /* endif for POWER_MEAS */
#ifndef CUI_DISABLE
if(pMsg->frameControl & Smsgs_dataFields_bleSensor)
{
CUI_statusLinePrintf(csfCuiHndl, deviceStatusLine, "ADDR:%2x%2x%2x%2x%2x%2x, UUID:0x%04x, "
"ManFac:0x%04x, Length:%d, Data:0x%02x", pMsg->bleSensor.bleAddr[5],
pMsg->bleSensor.bleAddr[4], pMsg->bleSensor.bleAddr[3], pMsg->bleSensor.bleAddr[2],
pMsg->bleSensor.bleAddr[1], pMsg->bleSensor.bleAddr[0], pMsg->bleSensor.uuid,
pMsg->bleSensor.manFacID, pMsg->bleSensor.dataLength, pMsg->bleSensor.data[0]);
}
else
{
Llc_deviceListItem_t devItem;
Csf_getDevice(pSrcAddr, &devItem);
CUI_statusLinePrintf(csfCuiHndl, deviceStatusLine, "Sensor - Addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, Temp=%d, RSSI=%d",
devItem.devInfo.extAddress[7],
devItem.devInfo.extAddress[6],
devItem.devInfo.extAddress[5],
devItem.devInfo.extAddress[4],
devItem.devInfo.extAddress[3],
devItem.devInfo.extAddress[2],
devItem.devInfo.extAddress[1],
devItem.devInfo.extAddress[0],
pMsg->tempSensor.ambienceTemp, rssi);
#ifdef LPSTK
CUI_statusLinePrintf(csfCuiHndl, lpstkDataStatusLine, "Humid=%d, Light=%d, Accl=(%d, %d, %d, %d, %d), Hall=%d",
pMsg->humiditySensor.humidity, pMsg->lightSensor.rawData,
pMsg->accelerometerSensor.xAxis, pMsg->accelerometerSensor.yAxis,
pMsg->accelerometerSensor.zAxis, pMsg->accelerometerSensor.xTiltDet,
pMsg->accelerometerSensor.yTiltDet,
pMsg->hallEffectSensor.fluxLevel);
#endif
}
CUI_statusLinePrintf(csfCuiHndl, numJoinDevStatusLine, "%x", getNumActiveDevices());
#endif /* CUI_DISABLE */
#if defined(MT_CSF)
MTCSF_sensorUpdateIndCB(pSrcAddr, rssi, pMsg);
#endif /* endif for MT_CSF */
}
使用此代码以及默认收集器示例和默认传感器示例、我可以通过 UART 获得以下输出: 
请注意、传感器的地址是扩展(64位)地址"00:12:4b:00:1c:A1:B6:fa"。 该地址对于传感器而言是唯一且恒定的。
您可以使用与上述代码片段中第24-35行类似的代码来检索项目中的扩展地址。
此致、
尼古拉伊