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.

AF_INCOMING_MSG MT command reception problem

Other Parts Discussed in Thread: Z-STACK, CC2650

Hi All,

          I want to implement MT command responses to be received through uart in hyper terminal. Can anyone please help me solve problem in receiving AF_INCOMING_MSG MT command response in hyper terminal? My zed(temperature sensor) is sending data every 10 secs as i can see in sniffer log and also it hits breakpoint when ZC(thermostat) receives data but i am not able to receive AF_INCOMING_MSG MT command response in hyper terminal or z-tool.

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

Thanks

  • I had told you to add the red line in the following code.

    if ( *msgPtr == AF_INCOMING_MSG_CMD )

    {

    zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr );

    osal_msg_send( zclYourApplicaiton_TaskID, msgPtr );

    }

    Try to change zclYourApplicaiton_TaskID to MT_TaskID

    if ( *msgPtr == AF_INCOMING_MSG_CMD )

    {

    zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr );

    osal_msg_send( MT_TaskID, msgPtr );

    }

  • Revising code as osal_msg_send( MT_TaskID, msgPtr ); results in reception of AF_INCOMING_MSG but ZDO responses like device annce are not received. short address, EP of zed are received correctly.
  • OK, let's send msg to both zclYourApplicaiton_TaskID and MT_TaskID

    if ( *msgPtr == AF_INCOMING_MSG_CMD )

    {

    zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr );

    osal_msg_send( MT_TaskID, msgPtr );

    osal_msg_send( zclYourApplicaiton_TaskID, msgPtr );

    }

  • I am sorry revising code to only osal_msg_send( MT_TaskID, msgPtr ); resulted in ZDO command reception but AF_INCOMING_MSG not received. Actually i had forgot to comment epDesc->task_id=&MT_TaskID; in AF.c and so only was getting AF_INCOMING_MSG response and not ZDO response.

    revising code as follows resulted in same as above(only ZDO response received and not AF response)
    osal_msg_send( MT_TaskID, msgPtr );
    osal_msg_send( zclSampleThermostat_TaskID_TaskID, msgPtr );

    You can trace afIncomingData() in AF.c where epDesc is not assigned any taskid.
    1)when afIncomingData() calls afBuildMSGIncoming() then epDesc-> taskid contains garbage value.
    2)afBuildMSGIncoming() calls AFCB_CHECK(CB_ID_AF_DATA_IND, *(epDesc->task_id) as follows
    #if defined ( MT_AF_CB_FUNC )
    // If ZDO or SAPI have registered for this endpoint, dont intercept it here
    if (AFCB_CHECK(CB_ID_AF_DATA_IND, *(epDesc->task_id)))
    {
    MT_AfIncomingMsg( (void *)MSGpkt );
    // Release the memory.
    osal_msg_deallocate( (void *)MSGpkt );
    }
    else
    #endif

    3)you can see definition #define AFCB_CHECK(cbi,task) ((1) && (task == MT_TaskID)) which returns null value and that's why both ZDO and AF responses are not received simultaneously. It will only return 1 when taskid is MT_TaskID.
    As far as i think there is problem in handling this taskid.
    Will continue tomorrow. Thanks
  • I do the following steps and there is no problem to receive AF_INCOMING_MSG and other ZDO related message.

    1. defined MT_ZDO_CB_FUNC,MT_AF_FUNC,MT_AF_CB_FUNC,MT_NWK_FUNC,MT_NWK_CB_FUNC
    MT_ZDO_MGMT in SampleThermostat example which acts as ZC.

    2. Add #include "MT_AF.h" in zcl.c and add the red line in zcl_event_loop()

          if ( *msgPtr == AF_INCOMING_MSG_CMD )
          {
            zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr );
            MT_AfIncomingMsg( (void *)msgPtr );
          }

    ZTool output:

  • Hi Yikai,

    Thanks a lot helping me solve this problem.  Now i am able to get both ZDO and AF responses.

    But if i request Active EP request i get two EPs. Why? if i request simple desc  then response is received for EP 0x08 but not for EP 0x14. I am using original z-stack and didn't add extra EP.

  • What example is your ZED based on? Is it still SampleTemeratureSensor?

  • There is a test endpoint sampleTemperatureSensor_TestEp in sampleTemperatureSensor.

    // Test Endpoint to allow SYS_APP_MSGs
    static endPointDesc_t sampleTemperatureSensor_TestEp =
    {
    20, // Test endpoint
    &zclSampleTemperatureSensor_TaskID,
    (SimpleDescriptionFormat_t *)NULL, // No Simple description for this test endpoint
    (afNetworkLatencyReq_t)0 // No Network Latency req
    };

    It is register by "afRegister( &sampleTemperatureSensor_TestEp )" in zclSampleTemperatureSensor_Init(). You can disable it.
  • Ya. Now i am getting single EP 0x08. Thanks.
  • You are welcome.
  • Hi Yikai,
    As you had told to request EP when device annce occurs and use short address and EP to communicate with ZED. With this ZC can send data using those parameters evenif ZC and ZED use different EPs. But how can ZED send data to ZC if ZED and ZC use different EPs? How this ZED data will be received at ZC which uses different EP?
  • Usually, we use indirect addressing (binding) to send message. After binding successfully, ZED knows ZC's endpoint.
  • I have not used binding concept till now.
    1)Do you mean to retrieve EP from binding table, store ZC EP and then use unicast message transmission there after?
    2)Problem with indirect addressing is that it will send data to all devices present in binding table. If zc is associated with 10 zeds then there will be 10 binding tables(seperate for each zed) or just one? If each will have seperate binding table then its ok or else it will lead to sending data to all unwanted devices. if temperature sensor wants to send data to zc then this data will be sent to all the other 9 zeds also which it should not.
  • 1. No. If you enable binding, you can use indirect address without assigning endpoint. Z-Stack would get endpoint for you from binding table.
    2. If you don't use binding, you can use ZDP_ActiveEPIFReq to request ZC's active endpoint.
  • I may use indirect addressing or use ZDP_ActiveEPIFReq to request ZC's EP and proceed using unicast addressing.
    As you said we usually use indirect addressing, consider a case where i have 3 switches(SW1,SW2,SW3) and 3 lamps(lamp1,lamp2,lamp3), seperate lamp for seperate switch. if all these devices are in network and (may be associated to some other zc or any of them may be zc). If these devices use indirect addressing and if SW1 is pressed for switching lamp1 ON then will other lamps(lamp2 and lamp3) will also get ON?
  • If SW1 is binding to Lamp1 only, it will only send command to LAMP1.
  • "If SW1 is binding to Lamp1 only, it will only send command to LAMP1." By this do you mean to say there will be 3zcs and 3 seperate nwk each for switch-lamp pair?
    I had asked 3 switches and 3 lamps are in one network and all devices use indirect addressing.
    Still i couldn't get clear idea about using indirect addressing(binding). I wanted to know whether binding will be one to one(seperate binding table for each device) or just one only. whether sw1 and lamp1 will have seperate binding table,sw2 and lamp2 have seperate binding table and sw3 and lamp3 will have seperate binding table? If binding table is different for different switch-lamp combination then there will be no problem in controlling the lamps and seperate switch will control seperate lamp. if there is one binding table then any switch will control any of the lamps.
  • I mean 3 sw and 3 lights in one network. If you do binding to SW1 and LIGHT1, indirect address is stored in binding table of SW1. When SW2 is binding to LIGHT2, indirect address is stored in binding table of SW2. SW3 to LIGHT2 is the same. So, it won't get confused when SW1 wants to send ON/OFF commands. It will use indirect address in its own binding table.
  • Ya, this only i wanted to know that different devices will have different binding tables and hence message will be transmitted to intended device only.
    I want to initiate binding in previous setup.For enabling binding or EZ_MODE, SW2 in sample apps fw need to be pressed. if suppose there is seperate zc which is parent of all Switches and lamps. So how can i initiate binding sw1-lamp1,sw2-lamp2 and sw3-lamp3? Is it like first all switches and lamps will form nwk with zc and then i will need to start binding for SW1-lamp1 (by processing SW2 of sample app). similar for sw2-lamp2 and sw3-lamp3?
  • In this case, I would suggest you not to use EZ-mode. You should use another key event such as press left to joy stick to trigger end device binding. In this way, you can press left to joy stick on both SW1 and LIGHT1 to send end device binding and make them binding together. Do the same process to SW2/LIGHT2 and SW3/LIGHT3.
  • so i should not define EZ_MODE for my case. which document describes more about EZ_MODE? You said not to use it for the case described earlier. In fw i see EZ_MODE being used for several processes.
  • You still can define and use EZ-mode. I just suggest you create another key event to implement end device binding. You can find EZ-mode in Z-Stack Home Developer's Guide.pdf
  • 1)I will start to work with zigbee sensor tag. As this device can work on both zigbee and bluetooth, so if i modify sensor tag fw and download it with z-stack code then will BLE code get deleted from flash?
    2)Is the sample fw provided for sensor tag original? If i modify fw and then download in it, whether it will work as like original code loaded in it?
    3)You had told earlier that there is no factory reset switch in it then how can it get certified because factory reset is important event in working with zigbee? Is erasing & flashing only solution for factory reset?
  • 1. Yes, BLE code will be erased.
    2. Do you mean you want a prebuilt Zigbee FW for sensor tag? If so, the answer is no.
    3. You can implement factory reset by yourself.
  • i am using new thread titled "zigbee based cc2650 sensor tag"
  • I have answered you on that thread.
  • hello
    I requested a 0x08 endpoint bind_req in z-tool.but the respone from the sensortag getting from 0x0a and 0x09 endpoint.I want respone from 0x08 endpoint.
  • Hi sriram,
    I try to help you in your another post.