Hello mario_castaneda,
Thanks A lot for your reply.
" i can able to send and receive data one time only.
i don't understand that i am doing wrong on coordinator side or sleeping end device side."
1. yes, your correct that i am using UNICASTACK.
but i don't know from which function should i send data in coordinator file.
i would like to know Coordinator part first.
in Coordinator file i am trying to send data from coordinator.c file
please check below code of coordinator.c file.
"is this correct way to send data?"
by this way i can able to send data only ONE TIME. after that it's not sending data
please correct me if i am wrong..
uint8 buf[9] = "TRACER"; // define globally
PRIVATE void vHandleStackEvent(ZPS_tsAfEvent sStackEvent)
{
extern int flag;
//DBG_vPrintf(TRACE_APP, "HANDLE STACK EVENT\n");
if (ZPS_EVENT_NONE != sStackEvent.eType)
{
DBG_vPrintf(TRACE_APP, "ZPS EVENT NONE\n");
switch (sStackEvent.eType)
{
case ZPS_EVENT_APS_INTERPAN_DATA_INDICATION:
{
DBG_vPrintf(TRACE_APP, "APP: event ZPS_EVENT_APS_INTERPAN_DATA_INDICATION\n");
PDUM_eAPduFreeAPduInstance(sStackEvent.uEvent.sApsInterPanDataIndEvent.hAPduInst);
}
break;
case ZPS_EVENT_APS_ZGP_DATA_INDICATION:
{
DBG_vPrintf(TRACE_APP, "APP: event ZPS_EVENT_APS_ZGP_DATA_INDICATION\n");
if (sStackEvent.uEvent.sApsZgpDataIndEvent.hAPduInst)
{
DBG_vPrintf(TRACE_APP, "ZGP DATA INDIACATON \n");
PDUM_eAPduFreeAPduInstance(sStackEvent.uEvent.sApsZgpDataIndEvent.hAPduInst);
}
}
break;
case ZPS_EVENT_APS_DATA_INDICATION:
{
DBG_vPrintf(TRACE_APP, "APP: vCheckStackEvent: ZPS_EVENT_AF_DATA_INDICATION i am in coordinator\n");
/* Process incoming cluster messages ... */
DBG_vPrintf(TRACE_APP, " Profile :%x\r\n",sStackEvent.uEvent.sApsDataIndEvent.u16ProfileId);
DBG_vPrintf(TRACE_APP, " Cluster :%x\r\n",sStackEvent.uEvent.sApsDataIndEvent.u16ClusterId);
DBG_vPrintf(TRACE_APP, " EndPoint:%x\r\n",sStackEvent.uEvent.sApsDataIndEvent.u8DstEndpoint);
//DBG_vPrintf(TRACE_APP, "flag value in coordinatr %s\n",flag);
thisNib = ZPS_psNwkNibGetHandle(ZPS_pvAplZdoGetNwkHandle());
DBG_vPrintf(TRACE_APP, "\n thisNib Read : %x\n", thisNib) ;
//uint16 u16size = PDUM_u16SizeNBO(ZDP_MGMT_BIND_RSP_FMT);
PDUM_thAPduInstance hAPduInst;
hAPduInst = PDUM_hAPduAllocateAPduInstance(apduMyData);
DBG_vPrintf(TRUE, "Handle of apdu : %d\r\n",hAPduInst);
for (i = 0; i <6; i++)
{
u16Offset += PDUM_u16APduInstanceWriteNBO(hAPduInst, u16Offset,"b", *(buf+i));
DBG_vPrintf(TRACE_APP, "Buffer data : %c\r\n", *(buf+i));
}
PDUM_eAPduInstanceSetPayloadSize(hAPduInst, u16Offset);
DBG_vPrintf(TRUE, "GetPayloadSize : %d\n",PDUM_u16APduInstanceGetPayloadSize(hAPduInst));
if (hAPduInst == PDUM_INVALID_HANDLE)
DBG_vPrintf(TRUE, "PDUM_INVALID_HANDLE_1\n");
else
{
ZPS_teAplAfSecurityMode eSecurityMode = (ZPS_E_APL_AF_SECURE_NWK);
ZPS_eAplAfUnicastAckDataReq(hAPduInst, // This function submits a request to send data to a remote node with ACk
0x1337,
0x01,
0x01,
sStackEvent.uEvent.sNwkJoinIndicationEvent.u16NwkAddr, // only particular destination 158d00
eSecurityMode,
0,
&u8TransactionSequenceNumber);
// Dest: All Coordinator & Routers
DBG_vPrintf(TRUE, "eStatus Read : %x \n ", eStatus);
//s_eDeviceState.eNodeState = E_STARTUP;
}
ON receiving end or (Sleeping End Device)
In app_endpoint.c ,
trying to received data like this.
void APP_vtaskMyEndPoint (void)
{
ZPS_tsAfEvent sStackEvent;
sStackEvent.eType = ZPS_EVENT_NONE;
/* check if any messages to collect */
if ( ZQ_bQueueReceive (&APP_msgMyEndPointEvents, &sStackEvent) )
{
DBG_vPrintf(TRACE_APP, "APP: No event to process\n");
}
if (ZPS_EVENT_NONE != sStackEvent.eType)
{
switch (sStackEvent.eType)
{
case ZPS_EVENT_APS_INTERPAN_DATA_INDICATION:
{
DBG_vPrintf(TRACE_APP, "APP: event ZPS_EVENT_APS_INTERPAN_DATA_INDICATION\n");
PDUM_eAPduFreeAPduInstance(sStackEvent.uEvent.sApsInterPanDataIndEvent.hAPduInst);
}
break;
case ZPS_EVENT_APS_ZGP_DATA_INDICATION:
{
DBG_vPrintf(TRACE_APP, "APP: event ZPS_EVENT_APS_ZGP_DATA_INDICATION\n");
if (sStackEvent.uEvent.sApsZgpDataIndEvent.hAPduInst)
{
PDUM_eAPduFreeAPduInstance(sStackEvent.uEvent.sApsZgpDataIndEvent.hAPduInst);
}
}
break;
case ZPS_EVENT_APS_DATA_INDICATION:
{
DBG_vPrintf(TRACE_APP, "APP: APP_taskEndPoint: ZPS_EVENT_AF_DATA_INDICATION\n");
/* Process incoming cluster messages for this endpoint... */
DBG_vPrintf(TRACE_APP, " Data Indication:\r\n");
DBG_vPrintf(TRACE_APP, " Profile :%x\r\n",sStackEvent.uEvent.sApsDataIndEvent.u16ProfileId);
DBG_vPrintf(TRACE_APP, " Cluster :%x\r\n",sStackEvent.uEvent.sApsDataIndEvent.u16ClusterId);
DBG_vPrintf(TRACE_APP, " EndPoint:%x\r\n",sStackEvent.uEvent.sApsDataIndEvent.u8DstEndpoint);
///////////////////////////////////////data receive from Coordinator////////////////////////////////////////////////////////////////////
uint8 n=PDUM_u16APduInstanceGetPayloadSize(sStackEvent.uEvent.sApsDataIndEvent.hAPduInst);
DBG_vPrintf(TRACE_APP, "get payload size sleeping device: %d\r\n",n);
u16bytesread = PDUM_u16APduInstanceReadNBO (sStackEvent.uEvent.sApsDataIndEvent.hAPduInst, 0, "bbbbbb",u8TempPayload);
DBG_vPrintf(TRACE_APP, "Read: %d, Data: %s \r\n", u16bytesread,u8TempPayload);
////////////////////////////////////////////////////////END///////////////////////////////////////////////////////////////////////////////
/* free the application protocol data unit (APDU) once it has been dealt with */
PDUM_eAPduFreeAPduInstance(sStackEvent.uEvent.sApsDataIndEvent.hAPduInst);
}
break;
Thank You for your time.
please reply as soon as possible.
Best Regards,
Dheeraj Sawant