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.

Problem in Sending Command to End device

Other Parts Discussed in Thread: CC2531, Z-STACK

Hai, 

                   I have a problem in configuring the end device, my code is here 

uint16 zclSampleThermostat_event_loop( uint8 task_id, uint16 events )
{
        afIncomingMSGPacket_t *MSGpkt;


       (void)task_id; // Intentionally unreferenced parameter

       if ( events & SYS_EVENT_MSG )
      { 
                  while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( zclSampleThermostat_TaskID )) )
                  {
                          switch ( MSGpkt->hdr.event )
                          {

#ifdef ZCL_EZMODE

                                 case ZDO_CB_MSG:
                                          zclSampleThermostat_ProcessZDOMsgs( (zdoIncomingMsg_t *)MSGpkt );
                                  break;

 #endif

                              case SERIAL_RCV_TASK:
                            {
                                      // Packet Received from UART
                                     Serial_IncomingPacket( (stSerialInPkt *) MSGpkt);
                                      break;
                             }

                            case MT_SYS_APP_MSG:
                                           // Message received from MT
                                       zclSampleThermostat_ProcessAppMsg( ((mtSysAppMsg_t *)MSGpkt)->endpoint,
                                                             ((mtSysAppMsg_t *)MSGpkt)->appDataLen,
                                                             ((mtSysAppMsg_t *)MSGpkt)->appData );
                             break;

                          case ZCL_INCOMING_MSG:
                                    // Incoming ZCL Foundation command/response messages
                                   //zclSampleThermostat_ProcessIncomingMsg( (zclIncomingMsg_t *)MSGpkt );
                                        Send_configcomand_ZED( (zclIncomingMsg_t *)MSGpkt);
                             break;

                       case KEY_CHANGE:
                                    zclSampleThermostat_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
                                 break;

                      case ZDO_STATE_CHANGE:
                       zclSampleThermostat_NwkState = (devStates_t)(MSGpkt->hdr.status);

// now on the network
if ( ( zclSampleThermostat_NwkState == DEV_ZB_COORD ) ||
( zclSampleThermostat_NwkState == DEV_ROUTER ) ||
( zclSampleThermostat_NwkState == DEV_END_DEVICE ) )
{

#ifndef HOLD_AUTO_START
// display main mode
giThermostatScreenMode = THERMOSTAT_MAINMODE;
zclSampleThermostat_LcdDisplayUpdate();
#endif
#ifdef ZCL_EZMODE
zcl_EZModeAction( EZMODE_ACTION_NETWORK_STARTED, NULL );
#endif // ZCL_EZMODE

}

default:
{
}
break;
}

               // Release the memory
             osal_msg_deallocate( (uint8 *)MSGpkt );
           }

// return unprocessed events
return (events ^ SYS_EVENT_MSG);
}

void Send_configcomand_ZED(zclIncomingMsg_t *MSGpkt)
{
// Test for Unicast


zclCfgReportCmd_t stConfig;

uint16 u16ReportTimeIntMin;
uint16 u16ReportTimeIntMax;
uint16 u16ReportIntTimeout;

u16ReportTimeIntMin = 0;
u16ReportTimeIntMax = 0;
u16ReportIntTimeout = 0;

zclSampleThermostat_DstAddr.addr.shortAddr = MSGpkt->srcAddr.addr.shortAddr;
zclSampleThermostat_DstAddr.addrMode = (afAddrMode_t) Addr16Bit;
zclSampleThermostat_DstAddr.endPoint = MSGpkt->srcAddr.endPoint;
zclSampleThermostat_DstAddr.panId = MSGpkt->srcAddr.panId;

u16ReportTimeIntMin = 5120; /* configuring End Device Report Interval 20 Seconds */
u16ReportTimeIntMax = u16ReportTimeIntMin; /* Max Report Interval */

stConfig.numAttr = 1;
stConfig.attrList[0].attrID = ATTRID_MS_TEMPERATURE_MEASURED_VALUE;
stConfig.attrList[0].dataType = ZCL_DATATYPE_UINT8;
stConfig.attrList[0].direction = ZCL_SEND_ATTR_REPORTS;
stConfig.attrList[0].minReportInt = u16ReportTimeIntMin;
stConfig.attrList[0].maxReportInt = u16ReportTimeIntMax;
stConfig.attrList[0].timeoutPeriod = u16ReportIntTimeout;




zcl_SendConfigReportCmd( SAMPLETHERMOSTAT_ENDPOINT, &zclSampleThermostat_DstAddr,
ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,
&stConfig, ZCL_FRAME_CLIENT_SERVER_DIR, TRUE, zclSampleThermostatSeqNum++ );

}

As i receive Packet I store in the zclSampleThermostat_DstAddr Structure and i send to the same device . Is there any configurations need to be done

  • I see no problem to do so.
  • If i Disable zcl_SendConfigReportCmd with #if 0, I am continuously getting Data to the coordinator, If i enable zcl_SendConfigReportCmd , Calls this function ist time i get Data, and from next time i am not getting any messages, what would be the problem
  • There might be someone overwrite the destination address. I suggest you set breakpoint and debug it.
  • where to put a break point how to verify Sir
  • If you use zclSampleThermostat_DstAddr as destination address, search your project and find where might change value of &zclSampleThermostat_DstAddr to set breakpoints on those lines.
  • void Send_configcomand_ZED(zclIncomingMsg_t *MSGpkt)
    {
    // Test for Unicast


    zclCfgReportCmd_t stConfig;

    uint16 u16ReportTimeIntMin;
    uint16 u16ReportTimeIntMax;
    uint16 u16ReportIntTimeout;

    u16ReportTimeIntMin = 0;
    u16ReportTimeIntMax = 0;
    u16ReportIntTimeout = 0;

    gstEndDivAdr.addr.shortAddr = MSGpkt->srcAddr.addr.shortAddr;
    gstEndDivAdr.addrMode = MSGpkt->srcAddr.addrMode;
    gstEndDivAdr.endPoint = MSGpkt->srcAddr.endPoint;
    gstEndDivAdr.panId = MSGpkt->srcAddr.panId;

    u16ReportTimeIntMin = 5120; /* configuring End Device Report Interval 20 Seconds */
    u16ReportTimeIntMax = u16ReportTimeIntMin; /* Max Report Interval */

    stConfig.numAttr = 1;
    stConfig.attrList[0].attrID = ATTRID_MS_TEMPERATURE_MEASURED_VALUE;
    stConfig.attrList[0].dataType = ZCL_DATATYPE_UINT8;
    stConfig.attrList[0].direction = ZCL_SEND_ATTR_REPORTS;
    stConfig.attrList[0].minReportInt = u16ReportTimeIntMin;
    stConfig.attrList[0].maxReportInt = u16ReportTimeIntMax;
    stConfig.attrList[0].timeoutPeriod = u16ReportIntTimeout;




    zcl_SendConfigReportCmd( SAMPLETHERMOSTAT_ENDPOINT, &gstEndDivAdr,
    ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,
    &stConfig, ZCL_FRAME_CLIENT_SERVER_DIR, TRUE, zclSampleThermostatSeqNum++ );

    }

    If Some body is overwriting zclSampleThermostat_DstAddr, which is using by Zstack, I have Declared own variable of same type , So no others can access it, at least this should work rite. From past 3 days i am trying to find reason behind it , but no clue. Could you help me
  • Do you try to set a breakpoint at zcl_SendConfigReportCmd to check value of gstEndDivAdr when it cannot send out message?
  • Yes, I have put a break point and checked the address , the address , Pan ID and End point ID are correct .
  • I am using IAR EVALUATION Licence , Is there any compiler Dependency ..
  • So, the message doesn't sent out? If so, do you use Ubiqua Packet Analyzer to check it?
  • No, I don't think this is relevant to IAR EVALUATION version.
  • Hai,
    I Downloaded Ubiqua tool , as i am using custom boards, the devices are not detected .
  • You will need a CC2531 USB dongle to work with Ubiqua Packet Analyzer.
  • Sir,

    Where can i find the mac address of the Coordinator
    1) if End Device Sends data, will i get the mac address of the end device.
    2) if i get mac address of the End device(source) Can i send a unicast message to the End device by using Mac address instead of using short Network address.
  • when end device sends data to coordinator will i get mac address in the application layer
  • No, there is no MAC address in received message. In Zigbee communication, we usually use short address instead of MAC address.
  • if i want to use mac address how could i configure it, Is it possible.
  • IEEE address and mac Address is Same right
  • IEEE address and MAC address mean the same thing.  When a message is sent to the Z-Stack with AF_DataRequest() and the 'afAddrType_t *dstAddr' parameter setup as a 'afAddr64Bit', the Address Manager in the APS layer will attempt to find the 16-bit Nwk Addr that corresponds to that 64-bit address. In the small, simple, one-hop networks that we almost always are using for testing and proof-of-concept, the Address Manager down in the APS layer will almost always have it. But eventually, the Address Manager won't have it on a sufficiently complex or large network, in which case the call to send the message will return a fail value and you will have to invoke the ZDO layer to do a NWK Address lookup based on the known IEEE address - take a look at ZDP_NwkAddrReq().

  • Sir,

    above code works , I have a small issue , If i use zclSampleThermostat_DstAddr Structure variable, End device could Receive Incoming Packet, and configures the Report Time interval, But if i use below code

    void Send_configcomand_ZED(zclIncomingMsg_t *MSGpkt)
    {
    // Test for Unicast

    afAddrType_t My_DstAddr;
    #if 1
    zclCfgReportCmd_t stConfig;

    uint16 u16ReportTimeIntMin;
    uint16 u16ReportTimeIntMax;
    uint16 u16ReportIntTimeout;

    u16ReportTimeIntMin = 0;
    u16ReportTimeIntMax = 0;
    u16ReportIntTimeout = 0;

    My_DstAddr.addr.shortAddr = MSGpkt->srcAddr.addr.shortAddr;
    My_DstAddr.addrMode = (afAddrMode_t) Addr16Bit;
    My_DstAddr.endPoint = MSGpkt->srcAddr.endPoint;
    My_DstAddr.panId = MSGpkt->srcAddr.panId;

    u16ReportTimeIntMin = 5120; /* configuring End Device Report Interval 20 Seconds */
    u16ReportTimeIntMax = u16ReportTimeIntMin; /* Max Report Interval */

    stConfig.numAttr = 1;
    stConfig.attrList[0].attrID = ATTRID_MS_TEMPERATURE_MEASURED_VALUE;
    stConfig.attrList[0].dataType = ZCL_DATATYPE_UINT8;
    stConfig.attrList[0].direction = ZCL_SEND_ATTR_REPORTS;
    stConfig.attrList[0].minReportInt = u16ReportTimeIntMin;
    stConfig.attrList[0].maxReportInt = u16ReportTimeIntMax;
    stConfig.attrList[0].timeoutPeriod = u16ReportIntTimeout;

    #endif

    // Break point
    #if 1
    zcl_SendConfigReportCmd( SAMPLETHERMOSTAT_ENDPOINT, &My_DstAddr,
    ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,
    &stConfig, ZCL_FRAME_CLIENT_SERVER_DIR, TRUE, zclSampleThermostatSeqNum++ );
    #endif
    }
    if i send with My_DstAddr Destination address which i populated , End device could not get a packet and there is conflict in the panID , Each time when zcl_SendConfigReportCmd (); used to send packet over the air, There is change in pan id.
  • What Would be the reason for change in case ZDO_STATE_CHANGE: in zclSampleThermostat_event_loop( uint8 task_id, uint16 events ); API. if
    zcl_SendConfigReportCmd( SAMPLETHERMOSTAT_ENDPOINT, &My_DstAddr,
    ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,
    &stConfig, ZCL_FRAME_CLIENT_SERVER_DIR, TRUE, zclSampleThermostatSeqNum++ );

    is disabled , there is no change in the panid, If i send a command Over the air to configure the end device . Conflict of Pan id is occuring
  • Try to remove the following two lines in your code.

    My_DstAddr.endPoint = MSGpkt->srcAddr.endPoint;
    My_DstAddr.panId = MSGpkt->srcAddr.panId;
  • Statement to remove Pan Id Is fine because Internally Panid will be Used but how about Application End Point Details,
  • As I know, Application End Point won't be used.
  • void Send_configcomand_ZED(zclIncomingMsg_t *MSGpkt)
    {
    // Test for Unicast

    afAddrType_t My_DstAddr;
    #if 1
    zclCfgReportCmd_t stConfig;

    uint16 u16ReportTimeIntMin;
    uint16 u16ReportTimeIntMax;
    uint16 u16ReportIntTimeout;

    uint16 DstShrtAddr;


    u16ReportTimeIntMin = 0;
    u16ReportTimeIntMax = 0;
    u16ReportIntTimeout = 0;
    DstShrtAddr = 0;

    memset ( My_DstAddr, 0 , sizeof(My_DstAddr));

    DstShrtAddr = MSGpkt->srcAddr.addr.shortAddr;

    My_DstAddr.addr.shortAddr = DstShrtAddr;
    My_DstAddr.addrMode = (afAddrMode_t) Addr16Bit;

    u16ReportTimeIntMin = 5120; /* configuring End Device Report Interval 20 Seconds */
    u16ReportTimeIntMax = u16ReportTimeIntMin; /* Max Report Interval */

    stConfig.numAttr = 1;
    stConfig.attrList[0].attrID = ATTRID_MS_TEMPERATURE_MEASURED_VALUE;
    stConfig.attrList[0].dataType = ZCL_DATATYPE_UINT8;
    stConfig.attrList[0].direction = ZCL_SEND_ATTR_REPORTS;
    stConfig.attrList[0].minReportInt = u16ReportTimeIntMin;
    stConfig.attrList[0].maxReportInt = u16ReportTimeIntMax;
    stConfig.attrList[0].timeoutPeriod = u16ReportIntTimeout;

    #endif

    // Break point
    #if 1
    zcl_SendConfigReportCmd( SAMPLETHERMOSTAT_ENDPOINT, &My_DstAddr,
    ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,
    &stConfig, ZCL_FRAME_CLIENT_SERVER_DIR, TRUE, zclSampleThermostatSeqNum++ );
    #endif
    }

    I tried this, But no result Sir, Sir i have a doubt As Short address and Extended Address is union Right, so as rest of six bits in union are set to 0 Zero, and only last 16bits will be fill with short address. will it make any conflict
  • Why do you want to do DstShrtAddr = MSGpkt->srcAddr.addr.shortAddr every time you receive a message?
  • Yes, I need to Store Short Address of the end device . and send command to the end device as per need , can i do it in this way.
  • It's OK to do so. Can you tell what conditions Send_configcomand_ZED would be called?
  • As, i get Incoming Packet from end device, i have a count value , if any end device sends value for 5 times , in response coordinator will Send a report time interval to the end device. So for that i maintain a table. Monitor end devices .Accordingly i need to send Report interval to the Device.
    So, now i am storing the short Address of the ZED in a table, as count increases to 5 times , i would need to collect a short address from table and assign the 16bit address to the structure .
  • I find I might be wrong on endpoint in your My_DstAddr. You should try to assign it with correct destination active endpoint.
  • Thank Sir, what could be reasons for conflict in PanID, and How could i address End Device
  • I don't understand your latest questions. Can you elaborate?
  • Sir, As i posted before, I am storing short address of the end device in a 16bit variable, as per condition i need to assign 16 bit stored address to the afAddrType_t structure ,

    u16EndDivAddr = MSGpkt->srcAddr.addr.shortAddr;
    u16EndDivEP = MSGpkt->srcAddr.endPoint;

    My_destAddr.addr.shortAddr = u16EndDivAddr ;
    my_destAddr.endPoint = u16EndDivEP ;

    i do it in dis way , to send a command to end device, if I send a command using
    zcl_SendConfigReportCmd( SAMPLETHERMOSTAT_ENDPOINT, &My_destAddr,
    ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,
    &stConfig, ZCL_FRAME_CLIENT_SERVER_DIR, TRUE, zclSampleThermostatSeqNum++ );

    There is conflict in PANID, Could i know the reason why it happens, and the command is not reaching to end device.
  • What do you mean "There is conflict in PANID?"
  • Sir, If i send command to end device with above configurations ,

    1) The command is not sent to end device.
    2) i have enabled break point while it receives Incoming Packet , each i see that change in pan ID, If i send Command to end device. if i dont Send any command , Pan id is same.
  • Try to set My_DstAddr.panId=_NIB.nwkPanId and test again.
  • Thanks for your reply Sir, Could i the reason at which consequences Network would be changed.

    As per my Understanding

    1) As coordinator is initiated , It will create a network With Specific Panid
    2) End device scans for a particular channel and PAN ID and binding happens.
    3) Once PAN ID is Initialised or Created , Pan ID of a coordinator will not be changed Unless Some other coordinator would contain the same ID .

    So , is there any another chances , where PAN id would be changed
  • In my experience, I never see PANID is changed after network is formed.
  • Hai YK, 

                         I don't How would it happen, Please check the attached file , can see how the pan id is changing .Could you please tell why would it happen.

    0167.New Microsoft Office Word Document.docx

  • I verify this again with my CC2530DK and I doesn't see this problem. I think you might revise something and introduce this problem. I suggest you to reinstall a fresh new Z-Stack and test the original examples to see if you still see PANID changes.
  • Hai Yk,

                           Thanks for Reply, As suggested i have freshly installed the z stack home automation , I tried the code but here i face the same issue, I have attached the code here with the changes. I haven't make much changes ,Sir Please check if i have made any wrong steps. 

    1) Thermostat Application Coordinator. Please check    zclSampleThermostat_ProcessInReportCmd(); API.

    2) temperature Application End Device please chech   zclSampleTemperatureSensor_ProcessInConfigReportCmd(); API.ZC_ZED.zip

  • Please don't change anything to original and test first. Set a breakpoint in zclSampleThermostat_ProcessInReportCmd and check _NIB.nwkPanId when it hits.
  • Yes, Every time it hits the break point. for every 10 sec i get an incoming packet, after receiving the incoming if i send configcmd report, device is getting restat
  • with out any changes in the original code , it works perfect. no issues, but after implementing my own , some times it automatically restarts, PAN id changes. all this issues
  • I suspect restart causes PANID changes. You should find out why it restarts.
  • Yes, Pan ID keep changes as Coordinator sends a command to the end device, Actually to send a unicast we just need to have a structure right, Is there any compiler flag settings need to be done. how could i over come this issue.
    is there any other approach to make it work
  • Yes, you only have to fill correct parameters for unicast. However, the problem is that your system keep restarting and changes PANID. So, you have to find out why it keeps restarting.