Broadcast to Zigbee Messaging Cluster

Hello.
Using the Zigbee messaging cluster, we are writing code for data exchange between ZR and ZED.
(Based on the Zigbee example light_bulb/light_switch/light_coordinator)

I want to send data to all devices within the same network that share the same PAN ID. (broadcast)
Therefore, I applied dst_addr.addr_short = 0xFFFF; in my code, but when I checked with a sniffer, no data was being sent.
(If you enter the device address in dst_addr.addr_short, it will be sent normally.)

Here's my code

< light_bulb code>

static void send_display_msg(zb_bufid_t bufid, zb_uint16_t cmd_id)
{
	LOG_INF("send_display_msg");
	zb_uint8_t messages[] = "SEND MESSAGE";
	test_disp.extended_message_control = 0x00;
	test_disp.message_len = sizeof(messages) -1 ;
	test_disp.message = messages;

	zb_addr_u dst_addr;	
	dst_addr.addr_short = 0xFFFF;

	ZB_ZCL_MESSAGING_SEND_DISPLAY_MSG(bufid, &dst_addr , ZB_APS_ADDR_MODE_16_ENDP_PRESENT, 
									ZB_ZCL_BROADCAST_ENDPOINT, DIMMABLE_LIGHT_ENDPOINT, &test_disp);
}

...

static void zcl_device_cb(zb_bufid_t bufid)
{
...
	case ZB_ZCL_MESSAGING_GET_LAST_MSG_CB_ID:
		LOG_INF("ZB_ZCL_MESSAGING_GET_LAST_MSG_CB_ID");
		zb_uint16_t cmd_id = ZB_ZCL_MESSAGING_SRV_CMD_DISPLAY_MESSAGE;
		zb_ret_t zb_err_code = zb_buf_get_out_delayed_ext(
			send_display_msg, cmd_id, 0);
		ZB_ERROR_CHECK(zb_err_code);

		break;
...
}

<light_switch code>

static void send_get_last_msg(zb_bufid_t bufid, zb_uint16_t cmd_id)
{
	LOG_INF("command: %d", cmd_id);
	zb_addr_u dst_addr;	
	dst_addr.addr_short = bulb_ctx.short_addr;
	// zb_uint16_t ZC_addr = 0xFFFF;

	ZB_ZCL_MESSAGING_SEND_GET_LAST_MSG(bufid, &dst_addr ,ZB_APS_ADDR_MODE_16_ENDP_PRESENT, bulb_ctx.endpoint, LIGHT_SWITCH_ENDPOINT);

}

...

static void button_handler(uint32_t button_state, uint32_t has_changed)
{
	zb_uint16_t cmd_id;
	zb_ret_t zb_err_code;

	/* Inform default signal handler about user input at the device. */
	user_input_indicate();

	check_factory_reset_button(button_state, has_changed);

	if (bulb_ctx.short_addr == 0xFFFF) {
		LOG_DBG("No bulb found yet.");
		return;
	}

	switch (has_changed) {
	case BUTTON_ON:
		LOG_DBG("ON - button changed");
		cmd_id = ZB_ZCL_CMD_ON_OFF_ON_ID;
		break;
	case BUTTON_OFF:
		LOG_DBG("OFF - button changed");
		cmd_id = ZB_ZCL_CMD_ON_OFF_OFF_ID;
		break;
	case BUTTON_SLEEPY:
		cmd_id = ZB_ZCL_MESSAGING_CLI_CMD_GET_LAST_MESSAGE;
		break;
	case IDENTIFY_MODE_BUTTON:
		if (IDENTIFY_MODE_BUTTON & button_state) {
			/* Button changed its state to pressed */
		} else {
			/* Button changed its state to released */
			if (was_factory_reset_done()) {
				/* The long press was for Factory Reset */
				LOG_DBG("After Factory Reset - ignore button release");
			} else   {
				/* Button released before Factory Reset */

				/* Start identification mode */
				ZB_SCHEDULE_APP_CALLBACK(start_identifying, 0);
			}
		}
		return;
	default:
		LOG_DBG("Unhandled button");
		return;
	}

	switch (button_state) {
	case BUTTON_ON:
	case BUTTON_OFF:
		LOG_DBG("Button pressed");
		buttons_ctx.state = button_state;

		/* Alarm can be scheduled only once. Next alarm only resets
		 * counting.
		 */
		k_timer_start(&buttons_ctx.alarm, BUTTON_LONG_POLL_TMO,
			      K_NO_WAIT);
		break;
	case 0:
		LOG_DBG("Button released");

		k_timer_stop(&buttons_ctx.alarm);

		if (atomic_set(&buttons_ctx.long_poll, ZB_FALSE) == ZB_FALSE) {
			/* Allocate output buffer and send on/off command. */
			if(has_changed!=BUTTON_SLEEPY)
			{
				zb_err_code = zb_buf_get_out_delayed_ext(
					light_switch_send_on_off, cmd_id, 0);
				ZB_ERROR_CHECK(zb_err_code);
			}
			else
			{
				zb_err_code = zb_buf_get_out_delayed_ext(
					send_get_last_msg, cmd_id, 0);
				ZB_ERROR_CHECK(zb_err_code);
			}
		}
		break;
	default:
		break;
	}
}

May I know where I made the error?

Parents
  • Hi,

    From ZigBee Light Switch sample:

    "Once the light switch is successfully commissioned, it sends a broadcast message to find devices with the implemented Level Control and On/Off clusters."

    I see that the sample code uses ZB_NWK_BROADCAST_RX_ON_WHEN_IDLE, defined here, where I also see some other broadcast values.

    Try to modify this sample to use all devices and check if you can see the broadcast on the sniffer then.

    Regards,
    Sigurd Hellesvik

  • Thank you for your answer.
    When the ZB_NWK_BROADCAST_RX_ON_WHEN_IDLE described in the light_switch code was modified to ZB_NWK_BROADCAST_ROUTER_COORDINATOR, the sniffer confirmed that it was changed from 0xfffd to 0xfffc.

    But the code I want to implement is to send a broadcast message from light_bulb (ZR) to light_switch (ZED).

    So if you look at light_bulb's send_display_msg

    static void send_display_msg(zb_bufid_t bufid, zb_uint16_t cmd_id)
    {
    zb_uint8_t messages[] = "SEND MESSAGE";
    test_disp.extended_message_control = 0x00;
    test_disp.message_len = sizeof(messages) -1 ;
    test_disp.message = messages;

    zb_addr_u dst_addr;
    dst_addr.addr_short = ZB_NWK_BROADCAST_ALL_DEVICES;

    ZB_ZCL_MESSAGING_SEND_DISPLAY_MSG(bufid, &dst_addr , ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
    ZB_ZCL_BROADCAST_ENDPOINT, DIMMABLE_LIGHT_ENDPOINT, &test_disp);

    LOG_INF("send_display_msg 0x%04hx",dst_addr.addr_short);
    }

    Here
    When dst_addr.addr_short = 0xABCD; set to (ABCD = ZED address), it was confirmed that the ZR device sends data at 0xABCD. However
    If dst_addr.addr_short = ZB_NWK_BROADCAST_ALL_DEVICS; it is confirmed that no data is sent.

  • Hi,

    It seems like this is due to how the Messaging cluster is intended to work. Messages are expected to be delivered via the Energy Service Interface (ESI) and then unicast to devices. The ESI will, in this case, be the light bulb sending the Display Message command. This is based on the Zigbee Smart Energy Standard specification.

    Best regards,
    Marte

  • In Zigbee Smart Energy Standard,  " Messages are expected to be delivered via the ESI and then unicast to all individually registered devices implementing the Messaging Cluster on the ZigBee network, or just made available to all devices for later pickup "

    Should I take it as saying that the messaging cluster cannot transmit data by broadcast according to your words?

Reply
  • In Zigbee Smart Energy Standard,  " Messages are expected to be delivered via the ESI and then unicast to all individually registered devices implementing the Messaging Cluster on the ZigBee network, or just made available to all devices for later pickup "

    Should I take it as saying that the messaging cluster cannot transmit data by broadcast according to your words?

Children
Related