How to send messages between nodes in zigbee mesh?

Hello

I am using 5 nrf52833 dev kits and the ble_zigbee_dynamic_light_bulb_eddystone example from nRF5_SDK_for_Thread_and_Zigbee_v4.1.0

I have modified the following: 

* Enabled distributed network with a shared key. 

* Replaced BLE beacon code with BLE - UART code.

My goal is to make a decentralised zigbee mesh network where all nodes have BLE capabilities. Making it easy for me to connect my phone via BLE to any node to get information about all nodes via that specific node that I am connected to.

My question is, is there a way to send custom messages between nodes using the cluster provided by ble_zigbee_dynamic_light_bulb_eddystone example?

I have tried to broadcast using this code:

zb_void_t broadcast_msg(zb_uint8_t param, zb_uint16_t dataframe) {
  zb_bufid_t *p_buf ZB_BUF_FROM_REF(param);
  zb_uint8_t receiver_addr = 0xFFFF;

  zb_uint8_t *_ptr = zb_zcl_start_command_header( . . .);

  ZB_ZCL_PACKET_PUT_DATA32(_ptr, &dataframe);
  zb_ret_t zb_ret = zb_zcl_finish_and_send_packet( . . .);
}

But I haven't got the chance to see if this works because SEGGER complains that ZB_BUF_FROM_REF is undefined.

I have even looked at the massaging cluster but didn't know how to use it since it doesn't have attributes to declare. 

So, I am kinda lost on how to send messages (data) between nodes. Any help would be appreciated!

BR 

//Garo

  • Hi Garo,

    But I haven't got the chance to see if this works because SEGGER complains that ZB_BUF_FROM_REF is undefined.

    This is because ZB_BUF_FROM_REF has been removed from the ZBOSS API in nRF5 SDK for Thread and Zigbee v4. See Zigbee stack migration guide: v3.2.0 to v4.0.0 for more information.

    You can use zb_buf_get_out() to allocate an out buffer of the default size, or you can use zb_buf_get_out_delayed_ext() to allocate an out buffer and then call a callback when the buffer is available. I would recommend using the latter, and then call broadcast_msg() as callback:

    zb_err_code = zb_buf_get_out_delayed_ext(broadcast_msg, dataframe, 0);

    With broadcast_msg() something like this:

    zb_void_t broadcast_msg(zb_bufid_t bufid, zb_uint16_t dataframe) {
        zb_uint8_t receiver_addr = 0xFFFF;
    
        zb_uint8_t* ptr = zb_zcl_start_command_header(bufid,
                                                      ...);
                                                      
        ZB_ZCL_PACKET_PUT_DATA32(ptr, &dataframe);
        zb_ret_t zb_ret = zb_zcl_finish_and_send_packet(bufid,
                                                        ptr,
                                                        receiver_addr,
                                                        ...);
    }

    Best regards,

    Marte

  • Hi Marte and thank you for your answer. 

    I have now tried the following:

    static zb_void_t broadcast_msg(zb_bufid_t bufid, zb_uint16_t dataframe)
    {
      zb_uint16_t receiver_addr = 0xFFFF;
      zb_uint8_t *_ptr = zb_zcl_start_command_header(
      bufid,
      ZB_ZCL_CONSTRUCT_FRAME_CONTROL(
          ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC,
          ZB_ZCL_NOT_MANUFACTURER_SPECIFIC,
          ZB_ZCL_FRAME_DIRECTION_TO_SRV,
          ZB_ZCL_ENABLE_DEFAULT_RESPONSE),
      0,
      NULL,
      NULL);

    ZB_ZCL_PACKET_PUT_DATA32(_ptr, &dataframe);

    zb_ret_t zb_ret = zb_zcl_finish_and_send_packet(
      bufid,
      _ptr,
      receiver_addr,
      ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
      m_dev_ctx.level_control_attr.current_level,
      HA_DIMMABLE_LIGHT_ENDPOINT,
      ZB_AF_HA_PROFILE_ID,
      ZB_ZCL_CLUSTER_ID_ON_OFF,
      NULL);
    }
    zb_ret_t zb_err_code = zb_buf_get_out_delayed_ext(broadcast_msg, 1, 0);
    and on the receiving end I haven't changed anything, so I'm using:
    ZB_ZCL_REGISTER_DEVICE_CB(zcl_device_cb);

    Then I have some printfs in zcl_device_cb() to see if it fires, but my log prints doesn't print. 

    What could it be that I'm doing wrong? tell me if you need more information about my code. 
    BR
    Garo
  • Hi Garo,

    A callback registered with ZB_ZCL_REGISTER_DEVICE_CB will not be called when you send a packet. The best way to see if you are sending the packet would be to get a sniffer log of the network traffic. If you have an additional nRF52840 DK or Dongle, you can use nRF Sniffer for 802.15.4.

    Best regards,

    Marte

Related