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.

Data Receiving problem at ZED using Z-tool

Other Parts Discussed in Thread: Z-STACK, CC2530

Hi Yikai,

Ya i can implement uartRx callback function at end device end.

  • Hi Yikai,

    Here I have included sniffer log and data sending image file using z-tool. In sniffer log APS source end point is coming as 0x01 although i am using 0x02 for both source and destination as you can see in z-tool image file. 4885.1.psd

  • I see the end device responses APS ack which means your end device receives command from ZC. Why do you think your end device doesn't receive data.

  • Hi Yikai,
    I am not getting any response to the command sent("A" in my case) from coordinator. In sniffer log too there is no reply back from end device for the "A" command sent. As i had told you before i had checked using hyperterminal by sending "A" command to the same end device and end device was sending back temperature data when it received "A" command.
  • From sniffer log, I am pretty sure your end device receives message. Can you show me how you process receiving message and response temperature data on your end device?
  • My code may look eratic. Here i have included part of my temperature sensing code. When data is received at the end device then i am setting event for sensing temperature in void zb_ReceiveDataIndication( uint16 source, uint16 command, uint16 len, uint8 *pData  ) using osal_set_event ( sapi_TaskID, TEMPERATURE_SENSING_EVENT);   //event set for sensing temperature After the event is set, this event will be processed in 

    void zb_HandleOsalEvent( uint16 event ) function and temperature data will be sent to the coordinator using 

    zb_SendDataRequest( Dest_Addr, TEMPERATURE_SENSOR_CMD_ID, 8, pData, 0, AF_ACK_REQUEST, 0 ); //temperature sensor should send data like this;-@TEMx### where x denotes temperature value8713.temp.txt

  • Do you set a breakpoint in zb_ReceiveDataIndication() to check this issue?
  • Sorry, i didn't check by setting breakpoint before. Now I had set breakpoint at ZED receive data indication. ZED is receiving "A" data but its not setting temperature sensing event as its not entering in the match case osal_set_event ( sapi_TaskID, TEMPERATURE_SENSING_EVENT);
    After switch(pData[0]) control is directly going to pData[0] = 0; and hence event is not set for sensing temperature ind ZED is not replying back with temperature data. I think there is problem with switch case. Earlier also i have faced such type problem with switch case in which compiler doesn't matches with any of the case although there exists match case. what should i do for this?
  • How do you define TEMPERATURE_SENSING_EVENT?
  • You can find in earlier attached document also. #define TEMPERATURE_SENSING_EVENT 0X0010. How you are relating it with definition of TEMPERATURE_SENSING_EVENT?
  • I had placed breakpoint at switch(pData[0]). After that i pressed Step Into button of downloading file. Next statement it executed was pData[0] = 0; although pData[0] had 'A' value in switch(pData[0])

  • If you want to receive command in zb_ReceiveDataIndication(), I suppose you have to use zb_SendDataRequest to send command.
  • For my normal operation i use zb_SendDataRequest function only but now i am using z-tool to check if i can send data through it.
    Although i am not sure but i doubt(though i should not have doubt about compiler) there is problem in conversion of received data "A" by the compiler. I had made following changes in my code
    #define sense_temperature 0x0a
    switch(pData[0])
    {
    case sense_temperature:
    osal_set_event ( sapi_TaskID, TEMPERATURE_SENSING_EVENT);
    break;
    Now in sniffer log i can see that ZED in replying back with temperature data in response to the command("A") sent through z-tool
  • Yes, you can use ZB_SEND_DATA_REQUEST of MT_SAPI MT command and it will call zb_SendDataRequest.
  • 1)Is there any possibility for such problem in conversion by compiler?I am asking because for my normal operation i am reading data through uart. If "A" is received through uart then request will be sent from ZC to ZED for sensing temperature using zb_SendDataRequest function. For reading data through uart and sending data to different ZED(based on data received through uart) also i am using switch case there also i find same problem. This problem occurs quite often but not always.
    2)Does parameter CommandId in ZB_SEND_DATA_REQUEST MT command represent cluster id of ZED?
  • 1. No, I don't think it is related to compiler.
    2. No, it is not equal to cluster ID.
  • 1)What may be other reason for not setting event and not sending data?
    2)what does commandid represents then? what value i should use for this?
  • 1. I don't know the reason but it seems you mess up cluster ID with command ID. Another issue is that you should use ZB SAPI on both sender and receiver if you choose to use SAPI.
    2. Command ID is a private command enum that is used for SAPI demo. You can define it to anything you like.
  • I don't know difference between clusterid and commandid. I think clusterid denotes to a group of end devices belonging to same type like a group of temperature sensor forms temperature cluster or in other way temperature sensor will belong to temperature cluster. I had made changes in original simple app similar to what i need for my application. Are these declaration wrong?
    #define TEMPERATURE_SENSOR_CMD_ID 0x0402
    const cId_t zb_OutCmdList[NUM_OUT_CMD_SENSOR] =
    {
    TEMPERATURE_SENSOR_CMD_ID
    };
    This TEMPERATURE_SENSOR_CMD_ID i am thinking as cluster. I don't know use of commandid
  • From the source code, I would say they are similar but not the same. I think the problem is that you have to use ZB_SEND_DATA_REQUEST of MT_SAPI MT command to send command if you use zb_ReceiveDataIndication on your end device. Do you try this?
  • 1)Ya, I had tested using ZB_SEND_DATA_REQUEST. In sniffer log i can see that data is getting sent but again there is no reply as seen in sniffer log. I had definedMT_SAPI_FUNC and MT_SAPI_CB_FUNC in both ZC and ZED. I had tried to place breakpoint at switch statement in zb receive indication function but breakpoint is not getting placed. Then i had placed breakpoint in handle osal event function and checked if it temperature sensing event process is executed but control doesn't reaches there and there is no reply from ZED.
    2)I think command id is just as a reference which needs to be sent along with data in order to check whether data is received from correct source or not. device will be matching with command id whether received data came from intended device or not.
  • When you use ZB_SEND_DATA_REQUEST and set a breakpoint in zb_ReceiveDataIndication(), does it stop at the breakpoint which means end device receive command?
  • 1)As i had replied in my previous post that i am not able to place breakpoint inside zb_ReceiveDataIndication() so i can't confirm whether ZED receives command or not.
    2)As i had replied before that ZED is sending temperature data if i use
    #define sense_temperature 0x0a
    "case sense_temperature:"
    But this data is not displayed in the z-tool log. For ZC i am using HalUARTWrite(HAL_UART_PORT_0,pData,8); for sending received data through uart .
    Do i need to include any preprocessor for this?
  • 1. Try to change optimization in project option to low and see if you can set breakpoint in zb_ReceiveDataIndication.

    2. If you use HalUARTWrite, it will output to ZTOOL. it won't show on ZTOOL because it is not in MT command format.

  • 1)I can't get what do you mean to keep optimization to low? Do you mean to remove unwanted definitions from project option?
    2) What i should do so that i can see my received data in z-tool?
  • Sorry. Now I got optimization in project option. i had tested by keeping it low but then also i am not able to set breakpoint in zb receive function.
  • Try to set optimization to none and see if you can set breakpoint again. By the way, why don't you use different commands when you use zb_SendDataRequest to send command and use them to filter in zb_ReceiveDataIndication?

    On zb_SendDataRequest side:
    #define CMD_TEMPERATURE 0x0001
    #define CMD_DOORSENSOR 0x0002
    #define CMD_BEEPER 0x0003

    zb_SendDataRequest( &dstaddr, CMD_TEMPERATURE, 0, (uint8 *)NULL, 0, AF_ACK_REQUEST, 0 );

    On receiver side:
    void zb_ReceiveDataIndication( uint16 source, uint16 command, uint16 len, uint8 *pData )
    {
    if (command=CMD_TEMPERATURE)
    {
    //Do something here!
    }
    if (command= CMD_DOORSENSOR)
    {
    //Do something here!
    }
    if (command= CMD_BEEPER)
    {
    //Do something here!
    }
    }
    }
  • Thanks a lot for the line by line explanation. I am truly overwhelmed by the response i get from you.
    I had tried by using commandid as you had explained in your previous post at both ZC and ZED. Now ZED is sending data and ZC is receiving back temperature data also. The received temperature data is also getting displayed into z-tool log now.
    But what i found is using MT_SAPI_FUNC and MT_SAPI_CB_FUNC at end devices resulted in no data reception at ZED and no reply also but removing these resulted in data reception and transmission.
    I had tried by using optimization as none but then also i was not able to set breakpoint when using MT_SAPI_FUNC and MT_SAPI_CB_FUNC but after removing these i was not only able to set breakpoint but receive and transmit data also.
    Using commandid i can proceed for my another application also where i had asked to set about 30 events for controlling camera. I can use 30 different commandid in place of it.
    Thanks again for your kind support.
  • Here i have included the response in z-tool. I had left my ZC and ZED powered on and after about 10 min i had checked by sending data using z-tool then i got response as shown highlighted and no data was received. After that i resetted ZED and again sent data then ZED replied correctly. What may be reason for this?

  • Check if your end device stop polling after a while.
  • Hi Yikai,
    Is there any sample application implementing ZAP?
  • If you install Z-Stack Home 1.2.1, you can find ZAP examples under C:\Texas Instruments\Z-Stack Home 1.2.1\Projects\zstack\ZAP
  • Is there such linux based ZAP?
  • It is Zigbee Linux Gateway in e2e.ti.com/.../347669
  • Which MSP430 version is needed for opening ZAP of Z-Stack Home 1.2.1? I had installed MSP430 but its not opening Z-Stack Home 1.2.1 ZAP file.
  • You have to use IAR EW430 6.10.2 to build MSP430 ZAP project.
  • Hi Yikai,
    I am going to start writing program for creating z-tool like application most probably in linux(beginner to this platform).
    Different MT commands use different numbers of bytes of data. How application can know request/response came for which MT commands? Will it be identified using 3rd and 4th bytes i.e. Cmd0 and Cmd1 value?
    Can you please suggest any idea for this?
  • Yes, it can be identified using 3rd and 4th bytes.
  • Hi Yikai,
    For battery powered end devices what parameters is should set to optimize battery.
    1)Beside defining power saving and using -DPOLL_RATE=60000 for HA profile do i need to do any thing else so that battery ends long like oscillator configuration or different power modes in cc2530.
    2)Will power saving option put ZED to sleep mode?
  • 1. No need to change oscillator configuration and power mode.
    2. Yes.
  • 1)What's concept of using -DPOLL_RATE=60000 and POWER_SAVING? is it like this that ZED will be polling at ZC for any data(for that ZED) every 60 sec and process if any data arrives. after that ZED will go to sleep mode and wakes up after next 60 sec to poll again. This process continues. In the mean time if interrupt occurs then it will process interrupt and after that it will go to sleep mode and wake up after 60 sec to poll at ZC.
    2)If i am using router then how i can confirm that how data is flowing whether its ZED->ZR->ZC or ZED->ZC directly. I want to check whether my router is working or not.
  • 1. Your understanding is correct.
    2. After you make ZR and ZED join ZC, you can turn off ZC to force ZED joining ZR as its new parent. Then, you can turn on ZC and keep testing.
  • 1)Can you please suggest how i can set timer for setting an event for sending data to ZED every 10min? i know that osal_start_timerEx function is used for setting event but once timer is started it will expire in maximum 65535ms (65.535sec) and then set the event because it accepts timeout value as uint16 in ms. But i want event to be set every 10min.
    2)Which function should i call osal_start_timerEx function for device configured as ZC in simpleapp z-stack2.5.1a.
  • In latest Z-Stack, it already be changed to uint32 so I suggest you using latest stack.
  • I think you mean to use z-stack home automation 1.2.1 but i have written my whole application in 2.5.1a and it will take time to convert code from one version to the other. Is there any other way to do in 2.5.1a?
  • Will this approach work? I will use a global variable to increment it at every timeout(60000ms suppose) in handle osal event function. once count of this variable reaches to time equivalent of 10min(10 counts) i will reset this global variable and restart the timer
  • Yes, this is what I want to suggest you to do if you insist on using Z-Stack 2.5.1a.
  • I will be definitely using newer version of z-stack for my next project. Just now newer version has also been launched.1.2.2 and will be looking later. Now a days busy in learning linux and need to finish this project as soon as possible.
    By the way which function i need to call osal_start_timerEx function for ZC device? shall i call in sapi_init()?
  • Yes, sapi_init is a good choice.

  • Hi Yikai,
    When end device does device annce, then will short address,end point response,simple descriptor response be sent through serial port in ZC automatically or i need to send using haluartwrite function when response occurs? In z-tool i had seen that these data were displayed automatically when response had arrived. If it will be sent on its own then i will simply read these data and store to create database in the application.
  • If you enable MT command, they will be sent through UART automatically.