How to send data from Coordinator to Sleeping End Device?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to send data from Coordinator to Sleeping End Device?

2,464 Views
dheerajsawant
Contributor V

Hello NXP Community, 

using JN-5168-001-M00 Module.

I am working with AN-1229 Application Note. 

"i want to send data from Coordinator to Sleeping End Device" .

does anyone know how to send data from Coordinator to Sleeping End Device?

Please reply as soon as possible.

Best Regards, 

Dheeraj

0 Kudos
7 Replies

1,796 Views
dheerajsawant
Contributor V

Hello Everyone, 

Does anybody know how to send data from coordinator to Sleeping End Device?

i didn't still looking for solution.

Thank you for your reply..

Dheeraj Sawant

0 Kudos

1,796 Views
dheerajsawant
Contributor V

Dear Community, 

I am still trying to finding solution for this question.

if anyone have demo code the please text here.

Thank you   

0 Kudos

1,796 Views
dheerajsawant
Contributor V

Hello Everyone, 

I am still looking for solution for this question.

please anyone know about this please reply.

Thank you, 

Dheeraj

0 Kudos

1,796 Views
dheerajsawant
Contributor V

Hello limcb‌, 

Need Your help. 

I am using An-1229 Application note. 

and i want to send data from coordinator to sleeping end device. 

Please do you know anything related to this question please reply as soon as possible.

Best Regards, 

Dheeraj

0 Kudos

1,796 Views
dheerajsawant
Contributor V

Anyone know about this data transfer from coordinator to sleeping end device?

i am stuck at this point. 

mario_castaneda‌, 

Mario do you know about this, if  you know then please provide sample code for this. 

it really help me a lot.

Thanks & Best Regards, 

Dheeraj

0 Kudos

1,796 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Dheeraj,

The Zigbee 3.0 Stack User Guide Describes the process transferring data.

5.5 Transferring Data

The data polling method is also described, which is used by an End Device to obtain data that arrives at its parent while the End Device is asleep.

https://www.nxp.com/docs/en/user-guide/JN-UG-3113.pdf?fsrch=1&sr=4&pageNum=1 

I am assuming that you will work on the Unicast way.Unicasts from Sleepy Nodes the source node must remain awake for a time equal to the timeout period.

The JN-AN-1229 has a sleep end device. As you can see, the app_sleeping_enddevice.c. The function PUBLIC void APP_vInitialiseSleepingEndDevice(void).

You can add the software modules that you are working on. 

        /* Start the poll/sleep cycle */
        ZPS_eAplZdoPoll();

        /* Re-start any other application software modules
         * HERE
         */

The subsequent arrival of data from the parent is indicated by a ZPS_EVENT_APS_DATA_INDICATION event. Any messages forwarded from the parent should then be collected using the function bZQueueReceive().

PUBLIC void APP_vtaskSleepingEndDevice (void)
{
    ZPS_tsAfEvent sStackEvent;

    sStackEvent.eType = ZPS_EVENT_NONE;
    if (ZQ_bQueueReceive (&APP_msgZpsEvents, &sStackEvent ) )
    {
        DBG_vPrintf(TRACE_APP, "APP: No event to process!\n");
    }
    else
    {
         DBG_vPrintf(TRACE_APP, "APP: Event to process!\n");
    }
    switch(sStackEvent.eType)
    {‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
        case ZPS_EVENT_APS_DATA_INDICATION:
        {
.
.
.  

8.2.3 ZDP Response Structures

 A received response is collected using the function bZQueueReceive(). As part of this function call, you must provide a pointer to a structure to store the message data. This structure must be of the appropriate type for the response, 

Hope it helps,

Regards,

Mario

0 Kudos

1,796 Views
dheerajsawant
Contributor V

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

0 Kudos