Zigbee Data Transmission

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

Zigbee Data Transmission

523 Views
tushar_verma
Contributor I

I have tried working upon sample code of zigbee 3.0 coordinator and router from SDK version 2.0 but couldn't rectify the code to generate any data/message for transmission from coordinator to router and vice versa. I am using MCUXpresso IDE, Please let me know which functions from which file can be used for data transmission and from where we can call them. as these examples are command based.

Labels (2)
0 Kudos
15 Replies

210 Views
tushar_verma
Contributor I

Yes now string data is transmitting normally, But there is problem with hex data, I am sending int data_packet[] = { 0x45,0x43,0x75,0x67}
by using this code i am putting data 

for (i = 0; i < result; i++) {
uint32 reversedByte = (uint32) data_packet[i];
u16Offset += PDUM_u16APduInstanceWriteNBO(hAPduInst,u16Offset ,"la\x04", reversedByte);
DBG_vPrintf(TRUE,"-------%d",u16Offset);
DBG_vPrintf(TRUE, "%02x ", reversedByte);
}

and retrieving data 
for (int i = 0; i < payloadSize; i++)
PDUM_u16APduInstanceReadNBO(hAPduInst, u16Offset + i * sizeof(int),"w", &received[i]);
from this code but data is coming in wrong format
please let me know where i am going wrong 

0 Kudos

203 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello,

 

I'm glad to know you are able to send data.

Please find the following community post, where is explained the parameters that are required in order to send the data in a proper way.

This include the szFormat string of the data:

  • b 8-bit byte
  • h 16-bit half-word (short integer)
  • w 32-bit word l 64-bit long-word (long integer)
  • a\xnn nn (hex) bytes of data (array)
  • p\xnnnn (hex) bytes of packing ... Variable list of data values described by the format string

Note that the compiler will not correctly interpret the format string “a\xnnb” for a data array followed by a single byte, e.g. “a\x0ab”. In this case, to ensure that the ‘b’ (for byte) is not interpreted as a hex value, use the format “a\xnn” “b”, e.g. “a\x0a” “b”.

 

Please let me know if there is anything else where I can help you.

0 Kudos

149 Views
tushar_verma
Contributor I

Sure Sir,

I want to know the maximum data packet we can send over zigbee from one node to another Node in Apdu Instance ?

0 Kudos

135 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello,

 

Sure, please find the following community post that can help you with this information.

Please let me know if there is anything else where I can help you.

0 Kudos

114 Views
tushar_verma
Contributor I

Please let me know if i want to send 1kb of file or buffer to any another node which function is suitable for that and do i have to change any flag for this as one maximum packet size is 100-127 byte for single transmission and how can i receive that 1kb of data.

0 Kudos

89 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello,

 

In this case if the APDU size is larger than the maximum packet size allowed on the network, in this case the APDU will be broken up into fragments (NPDUs) for transmission, for this is necessary to have enable fragmentation in the ZigBee Network by setting the parameter Maximum Number of Transmitted Simultaneous Fragmented Messages to a non-zero value.

You can find information about this, and how to implement this on the ZigBee 3.0 Stack User Guide (located on the KW41Z documentation).

Please let me know if there is anything else where I can help you.

0 Kudos

68 Views
tushar_verma
Contributor I

Hi Sir,

Thanks for the response, I have changed the parameter Maximum Number of Transmitted Simultaneous Fragmented Messages to a non-zero value on both the coordinator side and router side(Rx parameter), again tried to send larger data with the help of function 

void Send_Data(uint8_t *data, uint8_t len)
{
 
     int result = storeHexValuesInArray(data,data_packet,sizeof(data_packet) / sizeof(data_packet[0]));
     uint8 pSeqNum;
     PDUM_thAPduInstance hAPduInst = PDUM_hAPduAllocateAPduInstance(apduZDP);
     uint16 u16Offset = 0;
     uint16 i;
 
     PDUM_eAPduInstanceSetPayloadSize(hAPduInst, result*sizeof(int));
     DBG_vPrintf(TRUE, "Result %d \n", result);
     for (i = 0; i < result ; i++) {
        uint32 singleByte = (uint32)data_packet[i];
        PDUM_u16APduInstanceWriteNBO(hAPduInst, u16Offset + i * sizeof(int), "w",singleByte);
        DBG_vPrintf(TRUE, "%02x ", singleByte);
    }
 
    DBG_vPrintf(TRUE, "Size : %d\n Sending : \n",             PDUM_u16APduInstanceGetPayloadSize(hAPduInst));
 
 
    if (hAPduInst == PDUM_INVALID_HANDLE) {
        DBG_vPrintf(TRUE, "PDUM_INVALID_HANDLE\n");
        return;
    } else {
        ZPS_teStatus eStatus;
        ZPS_teAplAfSecurityMode eSecurityMode = (ZPS_E_APL_AF_SECURE_NWK);
 
        eStatus = ZPS_eAplAfUnicastAckDataReq(hAPduInst,
                                                                                  0x0013,
                                                                                            0,
                                                                                            0,
                                                                                  u16add,
                                                                      eSecurityMode,
                                                                                            0,
                                                                          &pSeqNum);
 
        if (eStatus != ZPS_E_SUCCESS)
            DBG_vPrintf(TRUE, "ZPS_E_state %x\n", eStatus);
        else if (eStatus == ZPS_E_SUCCESS)
            DBG_vPrintf(TRUE, "Send success\n");
 
        PDUM_eAPduFreeAPduInstance(hAPduInst);
       }
}
i am putting around 150 bytes of data into APDU but only receiving around 80 bytes, I am receiving data through this function 
void vDataReceive(PDUM_thAPduInstance hAPduInst) {
int add16 = ZPS_u16NwkNibGetNwkAddr(ZPS_pvAplZdoGetNwkHandle());
    uint16 u16Offset = 0;
    uint16 payloadSize = PDUM_u16APduInstanceGetPayloadSize(hAPduInst);
    DBG_vPrintf(TRUE, "Payloadsize = %d\n", payloadSize);
 
   for(int i = 0; i < payloadSize/4; i++)
         PDUM_u16APduInstanceReadNBO(hAPduInst, u16Offset + i * sizeof(int),"w", &received[i]);
 
   PDUM_eAPduFreeAPduInstance(hAPduInst);
 
    shell_write("Data Received for this Node\n");
    for(int i = 0; i<payloadSize/4; i++)
    DBG_vPrintf(TRUE, "%02x ",received[i]);
}

Please let me know where i am going wrong or what changes i can implement to send data about 1024 bytes.
0 Kudos

486 Views
tushar_verma
Contributor I

Hi Sir, 
We are using FRDM-KW41Z board and SDK version is latest only, though I had already downloaded SDK_2.2.0 for FRDM-KW41Z board, and already gone through that document (AN12061) but found nothing about data transmission
and also gone through many document but did find any help.

Please let me help regarding data transmission.  

0 Kudos

500 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello,

 

Thank you for contacting NXP support.

I have the following recommendations:

  1. Please use the latest version of the SDK and MCUXpresso.
  2. Also please download the SDK documentation (that is not included in the device package).

In the SDK documentation you will find the AN12061 that describe in a more detailed way how to use the examples of the Coordinator and Router. This documentation can be found on the following path sdk_documentation->docs->wireless->ZigBee->ApplicationNotes

Also can you please confirm that you are using the KW41Z-EVK board.

0 Kudos

463 Views
tushar_verma
Contributor I

Hi Sr,

I found these functions below which seems helpful for sending data but don't know how to use them and how to initiate the communication. 
ZPS_eAplAfApsdeDataReq
ZPS_eAplAfUnicastDataReq 
ZPS_eAplAfUnicastIeeeDataReq
ZPS_eAplAfUnicastAckDataReq 
ZPS_eAplAfUnicastIeeeAckDataReq 

Please let me know how to use them and from where to call them for data transmission.

warm regards 
Tushar

0 Kudos

451 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello,

You can find some documentation that have the description of this functions and also explains how this should be used and how they work.

This information is located inside  the SDK documentation inside the ZigBee 3.0 Stack User Guide. On the chapter 7.1.2 Data Transfer Functions you will find each function and how each one works.
Please let me know if there is anything else where I can help you.
 

0 Kudos

422 Views
tushar_verma
Contributor I

Hello,

Yes I found these functions in the documentation, but as we are running coordinator and router application they are command based only few commands are there regarding connection formation nothing about send data or receive data, please let me know how to implement data transmission.

0 Kudos

413 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello,

 

Please find the following community post that I think can help you out, with the data transmission on the ZigBee with the KW41Z.

Please let me know if you found useful this information.

0 Kudos

255 Views
tushar_verma
Contributor I

Hi Sir,

I have implemented data receive and data send function on both coordinator and router application 
void Send_Data(uint8* data,uint8 len){

         uint8 pSeqNum;
         uint8 value = 40;
         PDUM_thAPduInstance hAPduInst = PDUM_hAPduAllocateAPduInstance(apduZDP);
         uint16 u16Offset = 0;
         uint16 i;
 
         int PDUM_STATE = PDUM_eAPduInstanceSetPayloadSize(hAPduInst, len);
 
         if(PDUM_STATE == 0)
            DBG_vPrintf(TRUE, "PDUM_OK\n");
         else
            DBG_vPrintf(TRUE, "PDUM_STATE %d\n",PDUM_STATE);
 
         for (i = 0; i < len; i++) {
         u16Offset += PDUM_u16APduInstanceWriteNBO(hAPduInst, u16Offset,"a", *(data + i));
         DBG_vPrintf(TRUE, "%c", *(data + i));
         }
 
         DBG_vPrintf(TRUE, "Size : %d\n Sending : \n", PDUM_u16APduInstanceGetPayloadSize(hAPduInst));
 
         if (hAPduInst == PDUM_INVALID_HANDLE){
               DBG_vPrintf(TRUE, "PDUM_INVALID_HANDLE\n");
               return;
         }
         else {
        for(uint16_t pos = 0; pos < u16Offset; pos++) {
                    DBG_vPrintf(TRUE, "------%c", hAPduInst->au8Storage[pos]);
                }
           ZPS_teStatus eStatus;
           ZPS_teAplAfSecurityMode eSecurityMode = (ZPS_E_APL_AF_SECURE_NWK);
 
           eStatus = ZPS_eAplAfBroadcastDataReq(hAPduInst,
                                        0x0013,
                                                0x01,
                                                0x01,
                                                ZPS_E_BROADCAST_ZC_ZR,
                                                eSecurityMode,
                                                0,
                                                &pSeqNum
                                                );
 
           if(eStatus != ZPS_E_SUCCESS)
           DBG_vPrintf(TRUE, "ZPS_E_state %x\n",eStatus);
           else if(eStatus == ZPS_E_SUCCESS)
           DBG_vPrintf(TRUE, "Send success\n");
     PDUM_eAPduFreeAPduInstance(hAPduInst);
}
}

void vDataReceive(PDUM_thAPduInstance hAPduInst)
{
shell_write("In Received\n");
    uint16 u16Offset = 0;
    uint16 payloadSize = PDUM_u16APduInstanceGetPayloadSize(hAPduInst);
 
    DBG_vPrintf(TRUE,"Payloadsize = %d\n",payloadSize);
 
     uint8 value = 0;
   // char *receivedString = (char *)malloc(payloadSize + 1);
 
         PDUM_u16APduInstanceReadNBO(hAPduInst,u16Offset,"b",&value);
         //receivedString[payloadSize] = '\0';
 
    PDUM_eAPduFreeAPduInstance(hAPduInst);
    DBG_vPrintf(TRUE, "Received Data: data = %d\n", value);
   // free(receivedString);
}

I am calling data receive function in CASE ZPS_EVENT_APS_DATA_INDICATION: 
I want to send string data from coordinator to router and vice versa, while sending data it is showing 
ZCL_Task endpoint event:1
BDB: APP_vGenCallback [1 1]
In data Indication
Read: 1, Data:

But not receiving data please let me know where i am going wrong, is it there any problem in using specific cluster id or i am calling receive function at wrong place?

0 Kudos

224 Views
nxf77486
NXP TechSupport
NXP TechSupport

Hello,

 

There should not be any problem by using a custom cluster ID, but can you please try with a default cluster ID.

Also I recommend for debug proposes to use an sniffer, do you have a KW41 dongle?

And if you have one please share with me the captures from the sniffer.

0 Kudos