XBee serial communication

Hi,
I’m hoping that someone is still looking at this thread and can help me out here.

I have a Sonoff Zigbee USB device attached to Home Assistant and ZHA. I bought an XBee 2 and I’ve set it up with XCTU to attach it to ZHA and it was recognised as an XBee 3. I’m assuming that this isn’t a problem as it joined the network and comes up in Home Assistant.

I’ve started experimenting with the UART.
I’ve attached the XBee Tx/Rx to an ESP32 (via a level shifter) and I’ve been using Arduino to write code for the ESP32. I’m using the xbee Arduino library with XBeeWithCallbacks.
When I call the HA Service zha.issue_zigbee_cluster_command the data appears at my ESP32 so I know the path works. This is what I’m using:

service: zha.issue_zigbee_cluster_command
data:
  endpoint_id: 232
  cluster_id: 17
  cluster_type: in
  command: 0
  command_type: server
  args: Hello World
  ieee: 00:13:A2:00:41:F2:A5:19

And this is the display from my Arduino code

14:34:40.931 -> ER => RemAddr=   0 Src=1 Dst=E8 Clus=  11 Prof=260 Opt=0  Offset=17
14:34:40.931 ->  Length = 11   Data = 48 65 6C 6C 6F 20 57 6F 72 6C 64

ER means ZBExplicitRxResponse in xbee.h
As you can see the data is “Hello World”

The problem I have is sending data from the ESP32.

I’ve used the developer tools in HA to listen to ‘zha_event’ but nothing happens (I do not have any other Zigbee devices).

This link says that incoming UART data will generate this Event in HA but I’ve tried all combinations of the various data structures from xbee.h on the Arduino.

This is my Arduino loop

#define BIGNUM 100000
void loop() {
  xbee.loop();
  if (ctr++ % BIGNUM == 0) {
    // Create an array for holding the data you want to send.
    uint8_t payload[] = { 'H', 'i' };

    // Specify the address of the remote XBee (this is the SH + SL)
    XBeeAddress64 addr64 = XBeeAddress64(0x00124B00, 0x26B72A67);
    //XBeeAddress64 addr64 = XBeeAddress64(0x0, 0x0);
    //XBeeAddress64 addr64 = XBeeAddress64(0x0, 0x7FFF);

    // Create a TX Request
    ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));

    zbTx.setFrameId((ctr / BIGNUM) % 256);

    // Send your request
    xbee.send(zbTx);
  }
}

When the above does the send I get an ZBTxStatusResponse callback with isSuccess set TRUE so I assume it works.
I’ve tried ZBTxRequest and ZBExplicitTxRequest. I also tried the series 1 versions: Tx16Request and Tx64Request.

I also have a packet sniffer setup and I can see a flurry of packets at the appropriate times but I have no idea whats going on. The data content looks nothing like the data I’m sending.

Can anyone help please. What code in the Arduino using xbee.h should I be using, anyone have examples of this setup working.

One more thing, I’m not sure if this is relevant but I have the logger set up in HA. When the Arduino sends I get this in the HA log file:

2022-10-29 14:50:52.818 DEBUG (MainThread) [zigpy_znp.api] Received command: ZDO.SrcRtgInd.Callback(DstAddr=0x293C, Relays=[])