ZIGBEE网间通信 inter_pan
目标:两个协调器之间通信。
使用的模版是simpleapp,希望实现的是灯开关的功能。
协调器1 协调器2
信道:0x1B 信道:0x19
panid:0x0001 panid:0x0002
我的改动的地方:
1:要修改工程里的编译选项。project -> option ->c/c++ compiler ->preprocessor ->Defined symbols 添加:INTER_PAN
2:在nwk文件夹里加入stub_aps.h和stub_aps.c
3:我用的是SimpleApp的模板,所以在sapi.c 里加入#include "stub_aps.h"
4:在tasksArr[]里加上StubAPS_ProcessEvent
5:在osal_InitTasks()里加上StubAPS_Init( taskID++ )
6:将端点描述符的输出命令列表由原来的空改为
1, // Number of Output Commands
(cId_t *) zb_InCmdList // Output Command List
7:在simplecontrol.c加入下面函数,函数在摁键时触发,以协调器2为例:
void GenericApp_INTERPAN( void )
{
afAddrType_t dstAddr;
static uint8 setstatus;
setstatus = StubAPS_SetInterPanChannel( 0x0B );
dstAddr.addrMode = afAddrBroadcast;
dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR_DEVALL;
//dstAddr.addrMode = afAddr16Bit;
dstAddr.endPoint = STUBAPS_INTER_PAN_EP;
dstAddr.panId = 0x0001;
counter++;
if ( AF_DataRequest( &dstAddr, &sapi_epDesc,
TOGGLE_LIGHT_CMD_ID,
//(byte)osal_strlen( theMessageData ) + 1,
0,
//(byte *)&theMessageData,
(byte *)NULL,
&myAppSeqNumber,
AF_DISCV_ROUTE, 0 ) == afStatus_SUCCESS )
{
/* 显示发送状态*/
if (StubAPS_InterPan(0x0001, STUBAPS_INTER_PAN_EP))
{
HalLcdWriteStringValue( "InterPan Env", counter, 10, HAL_LCD_LINE_3 );
}
}
else
{
}
/*改回网内通信信道 */
StubAPS_SetIntraPanChannel();
}
按照以上步骤弄完还是出不来,求教大侠们小弟有什么地方弄错了吗?应该怎么弄呢
Coordinator1 channels 是0x0B吧? 2.4GHz信道最大值才是26, 0x1A。
还有,您好像没有调用函数StubAPS_RegisterApp注册appEndPoint and appTaskID.
想请教您一个问题哈:
我对于StubAPS_InterPan()函数不太理解,在Coordinator2中调用StubAPS_InterPan(0x0001,STUBAPS_INTER_PAN_EP)有何作用?//0x0001是coordinator1 的panid.
初学者不明白,请指教。。
