This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to send int array from zstack HA1.20

Hello all,

Greeting for the day,

i am using zstack HA 1.20 sample temp sensor and sample thermostat project for testing.

1) my aim is to transfer array data from temp sensor to thermostat side(array has say 5 element).

i am successfully able to transfer char string from temp to thermostat but i am not able to transfer array data from one end to other end over zigbee. below is my code which i used for sending and receiving array.... anyone plz tell me how can i achieve my task...

MY CODE :-

Temp side =>

int i = 0;   // local variable for loop
int8 newarr[] = {1,2,3,4,5,6,7} ;  //my array 


if(pReportCmd != NULL)
{
pReportCmd->numAttr = 1;
pReportCmd->attrList[0].attrID = ATTRID_MS_TEMPERATURE_ARRAY_VALUE;
pReportCmd->attrList[0].dataType = ZCL_DATATYPE_ARRAY;

for( i = 0; i< 7; i++)    // for loop for sending each array element sequentially
{
pReportCmd->attrList[0].attrData = (void *)(&newarr [i]); 

zcl_SendReportCmd( SAMPLETEMPERATURESENSOR_ENDPOINT, &zclSampleTemperatureSensor_DstAddr,
ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,
pReportCmd, ZCL_FRAME_SERVER_CLIENT_DIR, TRUE, zclSampleTemperatureSensorSeqNum++ );

 }
}

Note -> i tried same code with and without for loop and with some minor change like -> instead of (void *)(&newarr[i]) i used (void *)(&newarr)

  

Thermostat Side =>

if ( pInTempSensorReport->attrList[0].attrID == ATTRID_MS_TEMPERATURE_ARRAY_VALUE )
{
     if (pInTempSensorReport->attrList[0].dataType==ZCL_DATATYPE_ARRAY)

     {
          for(i = 0; i<7; i++)
          {
             UARTprintf("received Data is %d\n", (pInTempSensorReport->attrList[0].attrData[i]));

          }
     }
}

in thermostat side i am just trying to print array data but i am getting garbage value only....

i am not able to receive data which i am sending from temp side...

i am able to transmit and receive char string properly but i dont know why array is not working.....

 

anyone plz check my above code and suggest me what i am doing wrong or what changes i need to do to  transmit and receive array data properly.

 

anyone plz help me to solve my above issue.....

Thanks & Regards,

Maneesh singh

  • below is code through which i am able to send char string properly --->

    Temp Side =>

    char *pCharStr = "Hello World Maneesh";

    if ( pReportCmd != NULL )
    {
    pReportCmd->numAttr = 1;
    pReportCmd->attrList[0].attrID = ATTRID_MS_TEMPERATURE_CHAR_STR_VALUE;
    pReportCmd->attrList[0].dataType = ZCL_DATATYPE_CHAR_STR;
    pReportCmd->attrList[0].attrData = (void *)(pCharStr);

    zcl_SendReportCmd( SAMPLETEMPERATURESENSOR_ENDPOINT, &zclSampleTemperatureSensor_DstAddr,
    ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,
    pReportCmd, ZCL_FRAME_SERVER_CLIENT_DIR, TRUE, zclSampleTemperatureSensorSeqNum++ );
    }

    Thermostat Side =>

    if ( pInTempSensorReport->attrList[0].attrID == ATTRID_MS_TEMPERATURE_CHAR_STR_VALUE )
    {
        if (pInTempSensorReport->attrList[0].dataType==ZCL_DATATYPE_CHAR_STR)

       {
            UARTprintf("received string is %s\n", (pInTempSensorReport->attrList[0].attrData));
        }

    }

    But when i did changes for sending array data i am not able to transmit and receive array data properly... i am getting garbage value only.....

    anyone plz tell me how can i transfer array data over zigbee.... what changes i need to do

     

    Thanks & Regards,

    Maneesh

  • Anyone plz reply to my above question....

    YiKai Chen sir or any TI employee plz reply sir....

  • Anyone plz reply to my above question....

    YiKai Chen sir or any TI employee plz reply sir....

  • Hello all,

    i modified my code i did like this ->

    Temp side =>

    char pCharStr[]= {1,2,0,0,7,5,9,3,0,6};

    if ( pReportCmd != NULL )
    {
    pReportCmd->numAttr = 1;
    pReportCmd->attrList[0].attrID = ATTRID_MS_TEMPERATURE_CHAR_STR_VALUE;
    pReportCmd->attrList[0].dataType = ZCL_DATATYPE_CHAR_STR;
    pReportCmd->attrList[0].attrData = (void *)(pCharStr);

    zcl_SendReportCmd( SAMPLETEMPERATURESENSOR_ENDPOINT, &zclSampleTemperatureSensor_DstAddr,
    ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,
    pReportCmd, ZCL_FRAME_SERVER_CLIENT_DIR, TRUE, zclSampleTemperatureSensorSeqNum++ );
    }

    and Thermostat Side =>

    if ( pInTempSensorReport->attrList[0].attrID == ATTRID_MS_TEMPERATURE_CHAR_STR_VALUE )
    {
        if (pInTempSensorReport->attrList[0].dataType==ZCL_DATATYPE_CHAR_STR)

    {

    UARTprintf("received string is %d\n", (pInTempSensorReport->attrList[0].attrData[0]));
    UARTprintf("received string is %d\n", (pInTempSensorReport->attrList[0].attrData[1]));
    UARTprintf("received string is %d\n", (pInTempSensorReport->attrList[0].attrData[2]));
    UARTprintf("received string is %d\n", (pInTempSensorReport->attrList[0].attrData[3]));
    UARTprintf("received string is %d\n", (pInTempSensorReport->attrList[0].attrData[4]));
    UARTprintf("received string is %d\n", (pInTempSensorReport->attrList[0].attrData[5]));
    UARTprintf("received string is %d\n", (pInTempSensorReport->attrList[0].attrData[6]));
    UARTprintf("received string is %d\n", (pInTempSensorReport->attrList[0].attrData[7]));
    UARTprintf("received string is %d\n", (pInTempSensorReport->attrList[0].attrData[8]));
    UARTprintf("received string is %d\n", (pInTempSensorReport->attrList[0].attrData[9]));
    }

    }

    And i am getting proper output... but same thing when i am trying to transfer int array then it is not working i did following changes for sending int array -> (i did changes at highlighted in yellow color)

    1) using attrID = ATTRID_MS_TEMPERATURE_ARRAY_VALUE;

    2) dataType = ZCL_DATATYPE_ARRAY

    3) int newarr[] = {1,2,3,4,5,6,7} ;

    but i am not able to transfer int array data....

     

    Anyone plz help me to solve this problem.... 

    how can i do it ? what are the changes i need to do ?

    plz help me......

     

    Thanks & Regards,

    Maneesh singh

  • Hi singh

    do you find that zcl have not process array type in zclGetDataTypeLength()?
  • I have tried to help you in your another similar post at e2e.ti.com/.../563663