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_Datarequest

Other Parts Discussed in Thread: Z-STACK

Hi all,

I am using AF_Datarequest() for sending data from transmitter to receiver. How shall i receive this data in receiver .Do i have to implement a callback for it.

Thanks

Amit 

  • Can you specify what your receiver side is? ZC, ZR, or ZED? And which example do you use to recevie AF_DataRequest message?
  • Hi Y.Chen

    My receiving device is ZED

    I am using sample doorlock example to receive AF_DataRequest message

    and i was trying to send cluster data's using AF_DataRequest instead of zclClosures_SendDoorLockLockDoor( ) functions

    But i dont where to get the received messages I gone through pdf's but there i didn't get any clear picture of how to receive the message every pdf is explaining how to send the message.

    please suggest me some solution

    thanks in advance
    Amit
  • You have to add the line "osal_msg_send( zclYourApplicaiton_TaskID, msgPtr );

    " in zcl_event_loop() to receive AF_INCOMING_MSG_CMD.

    if ( *msgPtr == AF_INCOMING_MSG_CMD )

    {

    zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr );

    osal_msg_send( zclYourApplicaiton_TaskID, msgPtr );

    }

    Check if you receive AF_INCOMING_MSG_CMD in your zclYourApplication_event_loop() first.

  • Hi Y.Chen,
    When ever i am sending data using AFDatarequest()
    I am not getting the AF_INCOMING_MSG_CMD from zcl to user event loop.

    My user event loop code is like..

    user eventloop()
    {
    if ( events & SYS_EVENT_MSG )
    {
    while ( (MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( zclSampleDoorLockController_TaskID )) )
    {
    switch ( MSGpkt->hdr.event )
    {
    case AF_INCOMING_MSG_CMD :
    PROCESSDATA((afIncomingMSGPacket_t *)MSGpkt );

    }



    }

    Please suggest.
  • Try to add the following red line in zcl_event_loop().

          if ( *msgPtr == AF_INCOMING_MSG_CMD )
          {
            zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr );

            osal_msg_send( zclYourApplicaiton_TaskID, msgPtr );
          }

    And you should receive AF_INCOMING_MSG_CMD.

  • Hi Y.Chen,

    I am sending data to end device using AF_DataRequest().So is it necessary that the receiver of the end device should be always on then only it could get the incoming over the air message.

    Thanks
    Amit
  • If you use unicast, a polling ZED would receive message from its parent node.
  • Hi Y.Chen,

    I added the following code in zcl_event_loop.But still i am not getting the AF_INCOMING_MSG_CMD to my application_eventloop.
    On the transmitter side the AFDataRequest is returning success(0).

    if ( *msgPtr == AF_INCOMING_MSG_CMD )
    {
    zcl_ProcessMessageMSG( (afIncomingMSGPacket_t *)msgPtr );

    osal_msg_send( zclYourApplicaiton_TaskID, msgPtr );
    }
  • Set a breakpoint in zcl_event_loop and see if it is hit first.
  • No sir, it is not hitting the zcl_event_loop when i am sending data from other end.
    Any suggestions to rectify this further.

    Also when i am invoking EZmode with setting a break point in zcl_event_loop.My control is coming to afIncomingMsg().

    Thanks
  • What do you send by AF_DataRequest? I suggest you to set a breakpoint in afBuildMSGIncoming() and see if it is hit when you send message by AF_DataRequest.

  • In the AF DataRequest i am just sending a character (say 'a').
    Ok i will check with afBuildMSGIncoming()
  • I set a breakpoint in afincomingmsg () and afbuildincomingmsg() .But when i send data through afdatarequest() control is not coming to afincomingmsg().
    I am sending the data from coordinator(using AFDataRequest()) to my end device (sampledoorlock)
    My code is given below.. for coordinator

    #define cluster id TUNNELING_CLUSTER
    #define datasize 2
    #define data 0x45
    #define transactionid 0
    // Set destination address to indirect
    zclSampleDoorLockController_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
    zclSampleDoorLockController_DstAddr.endPoint = 0;
    zclSampleDoorLockController_DstAddr.addr.shortAddr = 0;

    //Configuring the end point descriptor
    testendpoint->endpoint= 20, // Test endpoint
    testendpoint->teskid=&zclSampleDoorLock_TaskID,
    (SimpleDescriptionFormat_t *)NULL, // No Simple description for this test endpoint
    (afNetworkLatencyReq_t)0

    AFDataRequest(&zclSampleDoorLockController_DstAddr,&testendpoint,cluster id,data size,data,transaction id,AF_ACK_REQUEST,AF_DEFAULT_RADIUS );


    /******On receiving side.....End device(sapmple door lock)**********/

    zcl_event_loop()
    {
    if(*msgptr==AF_INCOMING_MSG_CMD)
    {
    zcl_ProcessMsg();
    osal_msg_send(sampledoorlock_taskid , msgptr);
    }

    }
    sampledoorlock_eventloop()
    {
    if(events & SYS_EVENT_MSG)
    {
    case AF_INCOMING_MSG_CMD:
    ProcessData((afIncomingMsg_t*)MSGpkt);


    }


    }

    I have set a breakpoint at afincomingmsg();.but i am not getting the control on it when i am sending data through afdatarequest()
  • Do you do binding before you use "zclSampleDoorLockController_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;"?
  • Thanks Sir,

    It is working now.There was a minor bug in my code which i was missing.
  • You are welcome and it is good to know it works now.
  • do U kown how the Z-stack/OSAL working?

    U will build user task,and user task can process some message.

    the message AF_INCOMING_MSG_CMD is to read the receiving data for receiver,and AF_DATA_CONFIRM_CMD is to confirm sending by sender.