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 automatically data-change between the nodes on Z-stack mesh?

Other Parts Discussed in Thread: Z-STACK

I am using the GenericApp on Z-stack Mesh. On that code, it implements "press button" binding mechanism. 

In my application, nodes should start exchanging data when they are awake without end user interaction (no button), what function do I need to use and where in code do I need to add the function in order to receive without ZigBee troubling to discard it?

  • If you can try to use an example to show me that how the nodes in exchange data in your application, I might be able to give you suggestion.
  • Thank you Yikai Chen.

    My purpose is to send/receive some application specific data via unicast and broadcast.

    For example if a motion sensor detects a motion, then it should broadcast this information to the other nodes,  or when a node measures , say, temperature and desalinate to coordinator.

    I have user specific library to handle files, what I did is to add an extra function to receive the incoming data and defined a clusterID for my own application (I am not sure if this is the correct way to do it, or should I have done differently):

    static void GenericApp_MessageMSGCB( afIncomingMSGPacket_t *pkt )
    {
      switch ( pkt->clusterId )
      {
        case GENERICAPP_CLUSTERID:
          rxMsgCount += 1;  // Count this message
          HalLedSet ( HAL_LED_4, HAL_LED_MODE_BLINK );  // Blink an LED
    #if defined( LCD_SUPPORTED )
          HalLcdWriteString( (char*)pkt->cmd.Data, HAL_LCD_LINE_1 );
          HalLcdWriteStringValue( "Rcvd:", rxMsgCount, 10, HAL_LCD_LINE_2 );
    #elif defined( WIN32 )
          WPRINTSTR( pkt->cmd.Data );
    #endif
          break;
      case MY_APP_SYSTEM_MSG : //Cluster ID:3
          handleSysMsg(pkt);
    #if defined( LCD_SUPPORTED )
          HalLcdWriteString( (char*)pkt->cmd.Data, HAL_LCD_LINE_1 );
          HalLcdWriteStringValue( "Rcvd:", rxMsgCount, 10, HAL_LCD_LINE_2 );
    #elif defined( WIN32 )
          WPRINTSTR( pkt->cmd.Data );
    #endif
          break;
      case MY_EXTERNAL_MSG: // Cluster ID: 4
        handleExternalMsg(pkt);
        break;
        
      case MY_APP_QUERY_MSG: //Cluster ID: 5
        handleQueryMsg(pkt);
        break;
        
        
     // default:
      }
    }

    I send them via 

    void GenericApp_SendMessage( char *msg )
    {
      
      char *theMessageData = malloc( strlen(msg) + 1 );
      strncpy(theMessageData, msg, strlen(msg) + 1);
       
    
        
      if ( AF_DataRequest( &GenericApp_DstAddr, &GenericApp_epDesc,
                           My_APP_SYSTEM_MSG,
                           (byte)osal_strlen( theMessageData ) + 1,
                           (byte *)theMessageData,
                           &GenericApp_TransID,
                           AF_DISCV_ROUTE, AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
      {
        // Successfully requested to be sent.
      }
      else
      {
        // Error occurred in request to send.
      }
      free(theMessageData);
    
    }

    As an example, I want them to broadcast

    GenericApp_SendMessage("hello world 2"); by default when they are powered and join/form the network


  • Do you mean all of your nodes report data to coordinator?
  • not necessarily, they should be able to unicast to each others
  • If they can unicast to each other, it is difficult to find solution for your application. An alternative is to send bind request from coordinator if it know which nodes would talk to each other.
  • how would you implement if all needs to unicast to the coordinator and be able to send data to each others via broadcast? Is it possible to solve it with a simpler solution?
  • If your application is like that, you can set all of your nodes and coordinator to use 1 as endpoint. When a node uses unicast to coordinator, the short address is 0x0000(short address of coordinator is always 0x0000). When device does broadcast, the destination address is 0xFFFF. That's all.