然后用Zigbee Sensor Monitor查看,只看到一个SINK RX的红点,router好像没有连接上来?
打开的宏如下:
BDB_REPORTING
SECURE=1
TC_LINKKEY_JOIN
NV_INIT
NV_RESTORE
ZTOOL_P1
MT_TASK
MT_APP_FUNC
MT_SYS_FUNC
MT_ZDO_FUNC
MT_APP_CNF_FUNC
xLCD_SUPPORTED=DEBUG
MULTICAST_ENABLED=FALSE
ZCL_READ
ZCL_WRITE
ZCL_BASIC
ZCL_IDENTIFY
ZCL_TEMPERATURE_MEASUREMENT
ZCL_GROUPS
Viki Shi:
在终端调用bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_STEERING)试试
zhou jiangtao:
回复 YiKai Chen:
我加上了,然后调用后,在router端得到的状态结果bdbCommissioningStatus 为 2 (BDB_COMMISSIONING_NO_NETWORK)
void UI_UpdateComissioningStatus(bdbCommissioningModeMsg_t *bdbCommissioningModeMsg)
{
case BDB_COMMISSIONING_NWK_STEERING:uiCommissioningStateStr = "NS";//uiCommissioningStateStr = "FORM";if ((bdbCommissioningModeMsg->bdbCommissioningStatus == 这儿返回两次,一次为1IN_PROGRESS,第二次进来为2,之后就不进来了加在这个函数里面:
void zclSampleTemperatureSensor_Init( byte task_id )
{zclSampleTemperatureSensor_TaskID = task_id;
// Register the Simple Descriptor for this applicationbdb_RegisterSimpleDescriptor( &zclSampleTemperatureSensor_SimpleDesc ); // Register the ZCL General Cluster Library callback functionszclGeneral_RegisterCmdCallbacks( SAMPLETEMPERATURESENSOR_ENDPOINT, &zclSampleTemperatureSensor_CmdCallbacks );
// Register the application's attribute listzclSampleTemperatureSensor_ResetAttributesToDefaultValues();zcl_registerAttrList( SAMPLETEMPERATURESENSOR_ENDPOINT, zclSampleTemperatureSensor_NumAttributes, zclSampleTemperatureSensor_Attrs );
// Register the Application to receive the unprocessed Foundation command/response messageszcl_registerForMsg( zclSampleTemperatureSensor_TaskID );
// Register for all key events – This app will handle all key eventsRegisterForKeys( zclSampleTemperatureSensor_TaskID );
bdb_RegisterCommissioningStatusCB( zclSampleTemperatureSensor_ProcessCommissioningStatus );#ifdef BDB_REPORTING//Adds the default configuration values for the temperature attribute of the ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT cluster, for endpoint SAMPLETEMPERATURESENSOR_ENDPOINT//Default maxReportingInterval value is 10 seconds//Default minReportingInterval value is 3 seconds//Default reportChange value is 300 (3 degrees)bdb_RepAddAttrCfgRecordDefaultToList(SAMPLETEMPERATURESENSOR_ENDPOINT, ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT, ATTRID_MS_TEMPERATURE_MEASURED_VALUE, 0, 1, reportableChange);
#endifzdpExternalStateTaskID = zclSampleTemperatureSensor_TaskID;
zdpExternalStateTaskID = zclSampleTemperatureSensor_TaskID;
#if ZG_BUILD_COORDINATOR_TYPE > 0bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_FORMATION);
#elsebdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_STEERING);
#endif//bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_FORMATION | BDB_COMMISSIONING_MODE_NWK_STEERING | BDB_COMMISSIONING_MODE_FINDING_BINDING | BDB_COMMISSIONING_MODE_INITIATOR_TL);//NLME_PermitJoiningRequest(0xFF);////UI_Init(zclSampleTemperatureSensor_TaskID, SAMPLEAPP_LCD_AUTO_UPDATE_EVT, SAMPLEAPP_KEY_AUTO_REPEAT_EVT, &zclSampleTemperatureSensor_IdentifyTime, APP_TITLE, zclSampleTemperatureSensor_uiAppUpdateLcd, zclSampleTemperatureSensor_uiAppStatesMain);
//UI_UpdateLcd();
}
YiKai Chen:
回复 zhou jiangtao:
你有先在 coordinator上面要調用bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_FORMATION)組網,然後在180秒內在 router上面調用 bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_STEERING) 來入網嗎?
zhou jiangtao:
回复 YiKai Chen:
有,你看代码 所放的位置,放这个函数可以吗?
#if ZG_BUILD_COORDINATOR_TYPE > 0bdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_FORMATION);
#elsebdb_StartCommissioning(BDB_COMMISSIONING_MODE_NWK_STEERING);
#endif
而且ZigbeeSensor Monittor 1.2.0有时找的到coordiantor,有时找不到,这论坛居然不能发图。。
zhou jiangtao:
回复 zhou jiangtao:
YiKai Chen,谢谢您的回答。
经过好几天的努力看代码,我终于拿一个低版本的zstack2.3跑起来了,例子是按键绑定,我撇开了UI的代码,把按键的代码挪到了初始化,于是一起动两个设备就绑定了,从设备可以给协调器上报温度数据,也从monitor看到了效果,那红圈黄圈,这monitor效果做的真不错。
bdb的代码看上去有点复杂,我实在是啃不动它。
但我希望所有连接的路由器和设备,都向协调器上报数据,该怎么修改呢? 因为我最终要把汇总的数据发到云服务器。