Other Parts Discussed in Thread: Z-STACK
Dear Ti,
We are using Z-Stack 2.5.1 and in our setup there is a coordiantor and a router. We are trying to implement a Inter PAN communication for the scenario where the router hasn't joined the coordinator due to a different Pan ID of the coordinator.
We have been able to sucessfully send the message from Router to the Coordinator and have been able to receive the InterPan message on the coordinator as well. We however want to send a message back from coordinator to the router informing about the Pan ID that needs to be used for communication. Unfortunately we are able to see this message on the Packet sniffer going from the coordinator, however it's not geting detected on StubAPS_ProcessEvent(): MAC_MCPS_DATA_IND on router side.
Please help us resolve this issue.
Code on Coordinator Side
--------------------------------
void INTERP_DataIndication( macMcpsDataInd_t *dataInd )
{
NLDE_FrameFormat_t snff;
aps_FrameFormat_t saff;
zAddrType_t srcAddr;
NLDE_Signal_t sig;
uint16 logicalType =0;
uint8 transId =1;
afAddrType_t GenericApp_DstAddr;
char buf[6];
//char theMessageData[] = "666666";
//APSDE_DataReq_t
// parse the Stub NWK header
StubNWK_ParseMsg( dataInd->msdu.p, dataInd->msdu.len, &snff );
// Fill in MAC destination address
snff.macDstAddr = dataInd->mac.dstAddr.addr.shortAddr;
osal_nv_read(ZCD_NV_LOGICAL_TYPE,0, sizeof(uint16), &logicalType);
logicalType&=0xFF;
if(logicalType == ZG_DEVICETYPE_COORDINATOR)
{
(void)osal_memcpy(GenericApp_DstAddr.addr.extAddr, dataInd->mac.srcAddr.addr.extAddr, Z_EXTADDR_LEN);
GenericApp_DstAddr.addrMode = (afAddrMode_t)Addr64Bit;
GenericApp_DstAddr.endPoint = STUBAPS_INTER_PAN_EP;
GenericApp_DstAddr.panId = 0x1008;//0xFFFF;//_NIB.nwkPanId;
buf[0] =(byte)_NIB.nwkPanId; // lo byte
buf[1] =(byte)(_NIB.nwkPanId>>8); // then hi byte
buf[2]= (byte)'8';buf[3]= (byte)'8';
if(AF_DataRequest(&GenericApp_DstAddr,&sapi_epDesc,
2,
4+1,
(uint8 *)buf,
&transId,
AF_TX_OPTIONS_NONE, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
{
// Successfully requested to be sent.
// HalLcdWriteStringValue( "Pongs ENV", valorEnv, 10, HAL_LCD_LINE_1 );
}
else
{
// Error occurred in request to send.
StubAPS_SetIntraPanChannel();
}
}
else{
// other than coordinator device than this is comman
if(logicalType != ZG_DEVICETYPE_COORDINATOR)
{
//_NIB.nwkPanId=;
// _NIB.nwkPanId= buf[1]; // lo byte
// _NIB.nwkPanId<<=8;
// _NIB.nwkPanId |=buf[0]; // then hi byte
// NLME_UpdateNV(NWK_NV_NIB_ENABLE);
if((buf[2]==buf[3])&&(buf[3]=='8'))
{
}
}
}
// fill in MAC source address (Stub NWK frame doesn't have address fields)
osal_copyAddress( &srcAddr, (zAddrType_t *)&(dataInd->mac.srcAddr) );
// check if incoming frame is of the right type
if ( snff.frameType != STUB_NWK_FRAME_TYPE )
return;
// check if incoming frame is of the right version
if ( snff.protocolVersion != NLME_GetProtocolVersion() )
return;
// check if the remaining sun-fields are zero
if ( ( snff.discoverRoute != 0 ) || ( snff.multicast != 0 ) ||
( snff.secure != 0 ) || ( snff.srcRouteSet != 0 ) ||
( snff.dstExtAddrSet != 0 ) || ( snff.srcExtAddrSet != 0 ) )
{
return;
}
// parse the Stub APS header
StubAPS_ParseMsg( &snff, &saff );
// check if incoming frame is of the right type
if ( ( saff.FrmCtrl & APS_FRAME_TYPE_MASK ) != STUB_APS_FRAME )
return;
// check if delivery mode is of the right type
if ( ( saff.FrmCtrl & APS_DELIVERYMODE_MASK ) == APS_FC_DM_INDIRECT )
return;
// check if incoming frame is unsecured
if ( saff.FrmCtrl & APS_FC_SECURITY )
return;
// check if there's no extended header
if ( saff.FrmCtrl & APS_FC_EXTENDED )
return;
// Set the endpoints
saff.DstEndPoint = appEndPoint;
saff.SrcEndPoint = STUBAPS_INTER_PAN_EP;
// Set the signal strength information
sig.LinkQuality = dataInd->mac.mpduLinkQuality;
sig.correlation = dataInd->mac.correlation;
sig.rssi = dataInd->mac.rssi;
APSDE_DataIndication( &saff, &srcAddr, dataInd->mac.srcPanId,
&sig, snff.broadcastId, FALSE, dataInd->mac.timestamp );
}
---------------------------------
Code from Router Side
__________________
The below functionality is called ever 2 sec
dataReq_t.dstAddr.addrMode = (afAddrMode_t)AddrBroadcast;
dataReq_t.dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
dataReq_t.dstEP = 0xfe;
dataReq_t.dstPanId = 0x1008;
INTERP_DataReq(&dataReq_t);
_____________________
Thanks
Anubhav