kardia-as / zigpy-zboss

GNU General Public License v3.0
36 stars 4 forks source link

[REQUEST] Compatibility with ESP ZBOSS 3.0 Libraries (esp-zboss-lib from Espressif) for ESP32-C6 and ESP32-H2? #19

Closed Hedda closed 4 months ago

Hedda commented 1 year ago

Espressif of ESP32 fame joined ZOI (ZBOSS Open Initiative) more than a year ago and has now fully released ESP ZBOSS 3.0 binary libraries supporting the Zboss Zigbee 3.0 stack for ESP32-C6 and ESP32-H2 SoCs which features embedded 802.15.4 radio for Zigbee (and Thread) support:

Would it be possible to make zigpy-zboss compatible with a serial interface for Espressif's "esp-zboss-lib" (ESP ZBOSS 3.0 Libraries) to allow using a serial-server on ESP32-C6 or ESP32-H2 for Serial-over-IP pass-through proxy (similar to ser2net) to enable TCP streaming of the serial communication bridge to allow it to be used as a network-attached remote Zigbee Coordinator so that the Home Assistant's ZHA integration can connect to it via a socket (socat)?

Bonus is if that serial streaming server is advertised on the network via Zeroconf for automatic network discovery that ZHA can find:

Espressif has also released a couple of development kits based on ESP32-H2 as reference hardware such and similar solutions:

https://www.cnx-software.com/2023/06/20/espressif-esp-thread-border-router-board-combines-esp32-h2-esp32-c3-wireless-chips/

image

That is a new ESP32-H2 + ESP32-C3 combo development board kit marketed as ESP Thread Boarder Router / Zigbee Gateway with an optional Ethernet daughter-board/sub-board sold separately (which would normally be recommended as streaming serial communication over WiFi does not work well), although that Ethernet daughter-board/sub-board is based on WIZnet W5500 which uses a non-standard SPI interface instead of RMII so might not yet be supported by ESPHome (and not yet supported in Tasmota).

An earlier two-board ESP Thread Border Router / Zigbee Gateway solution that combined separate ESP32-C6 and ESP32-H2 boards was previously available as an example project for reference to achieve the same result:

image

With either of those hardware combinations it should be possible to make a network-attached "Zigbee Coordinator" adapter products based on ESPHome (or Tasmota) similar to TubesZB Zigbee Gateways with ESP32-C6 or ESP32-H2 that simply tunnel/passthrough the serial connection to the serial interface for Espressif's "esp-zboss-lib" (ESP ZBOSS 3.0 Libraries) from Home Assistant's ZHA integration.

ESP ZBOSS 3.0 Libraries

This repository contains binary libraries supporting the Zboss Zigbee 3.0 stack for ESP32 series chips.

Packages from this repository are uploaded to Espressif’s component service. You can add them to your project via idf.py add-dependency

More information about idf-component-manager can be found in Espressif API guide or PyPi registry.

There now looks to be some Zigbee examples in Espressif’s IoT Development Framework (ESP-IDF):

Those examples include; Zigbee coordinator ("light coordinator"), "Zigbee RCP (radio co-processor"), and "Zigbee gateway":

"light_coordinator is a light coordinator example demonstrating Zigbee Coordinator role. It provides a formation of the Zigbee network. It runs on an 802.15.4 SoC like ESP32-H2. For more details to see the example readme file."

Wondering if "RPC" works similarly to Silicon Labs RPC which works like a dumb radio requiring external ESP ZBOSS 3.0 libraries?

"This test code shows how to configure Zigbee rcp (radio co-processor) device. Rcp doesn't function alone, it needs to work together with Zigbee gateway (see esp_zigbee_gateway example)"

"After rcp starts up, it will send its own MAC ieee address and Zigbee stack version number to the Zigbee gateway and start working together with Zigbee gateway via UART communication"

ESP32-H2 was apparently early on even certified as a “Zigbee Compliant Platform” by the CSA:

Type of Device: Zigbee Compliant Platform Zigbee PRO Feature Set (2017) Manufacturer: Espressif Systems (Shanghai) Co., Ltd. Model Identification: ESP32-H2 Firmware Version: V1.0 Hardware Version: V1.0 Certification Date: October 20, 2021 Certification ID Number: ZIG21030ZCP27315-24

kklem0 commented 1 year ago

Why would it not work with Espressif chips? I can probably buy one and test it out. I do see more and more products using H2 and C6 these days and their matter zigbee bridge is interesting.

Hedda commented 1 year ago

Why would it not work with Espressif chips? I can probably buy one and test it out.

Not sure if Espressif uses the same unmodified standard ZBOSS serial interface or if they have implementation some other custom or propriatory interface(s)?

I do see more and more products using H2 and C6 these days and their matter zigbee bridge is interesting.

Yes I think so too, though it should be mentioned that while it has been some time since Espressif announced the ESP32-H2 and ESP32-C6 they were actually just now made available and they have not yet ramped up manufacturing so they can currently be hard to get a hold of, and on top of that they are officially only supported in the upcoming ESP-IDF v5.1 SDK which is expected to be released soon (with Release Candidate 1 being made availavle for about two weeks now).

Hedda commented 11 months ago

@DamKast @kklem0 FYI, just noticed that grobasoz added some Zigbee RCP and CLI firmware images for ESP32-C6. Check out:

@grobasoz Any chance you could test ESP32-C6 with a USB to serial bridge/converter? Would it be ZigbeeCLI firmware then?

I also guess one of those could probably be used in a two-SoC setup setup could initially be useful in a proof-of-concept as a remote network-attached Zigbee Coordinator where the ESP32-S3 would be flashed with for example ESPHome or Tasmota and the ESP32-C6 would only run Zigbee/OpenThread firmware to simply act as a Zigbee/Thread radio connected via serial using CLI or RCP interface.

Again, if esp-zboss-lib from Espressif used the standard ZBOSS CLI interface then should as a proof-of-concept make it usable as a remote network-attached Zigbee Coordinator if configure via serial server pass-through as a proxy using socat to map the network socket (similar to ser2net) if one has added zigpy-zboss to Home Assistant's ZHA integration installation.

PS: Again, more discussion related to esp-zboss (DSR ZBOSS Zigbee stack) with zigpy in https://github.com/zigpy/zigpy/issues/1052 and https://github.com/zigpy/zigpy/issues/394

kklem0 commented 10 months ago

Me and @DamKast got a few C6 and we'll test it out as ESP-IDF v5.1 is released.

Hedda commented 10 months ago

Me and @DamKast got a few C6 and we'll test it out as ESP-IDF v5.1 is released.

@kklem0 FYI, ESP-IDF v5.1 (and v5.1.1 minor bug-fix update release) has been released with ESP32-C6 and ESP32-H2 support:

https://github.com/espressif/esp-idf/releases/tag/v5.1

https://github.com/espressif/esp-idf/releases/tag/v5.1.1

PlatformIO release with support for ESP32-C6-DevKitC-1 also looks to be available now(?):

https://docs.platformio.org/en/latest/boards/espressif32/esp32-c6-devkitc-1.html

And there is now even initial support for ESP32-C6 in ESPHome (see esphome dev branch, beta, or wait for 2023.09 release):

https://github.com/esphome/esphome/releases/tag/2023.9.0b1

https://github.com/esphome/esphome/pull/4377

https://github.com/esphome/esphome/pull/5354

ESP32-C6 Arduino support for ESP-IDF v5.1 is however lagging behind that:

https://github.com/espressif/arduino-esp32/issues/7713

https://github.com/espressif/arduino-esp32/issues/7852

https://github.com/espressif/arduino-esp32/tree/esp-idf-v5.1-libs

baylf2000 commented 9 months ago

As someone who has struggled for two weeks with the Espressif Zigbee SDK, I think you'll find the primary issue with that SDK is the extremely poor documentation. There are a few paragraphs of written introductions, and the rest is just Doxygen pages generated from header files with little or no commenting. The examples provided are also poor quality, lack comments, are not useful examples and often don't work at all. Add to that the fact that you can't even work around the lack of documentation by trawling their code because all the actual Zigbee code is locked in binaries.

I've tried raising this issue multiple times with their team, but they just keep pointing me back to the Doxygen pages as if that is all that is required.

I think if you were highly experienced with zigbee development on another platform you might be able to work things out, but otherwise it's an exercise in futility.

kklem0 commented 9 months ago

Me and Damian have checked out C6, esp-zigbee-sdk's zigbee features work well but unfortunately they're using ZBOSS RCP instead of NCP, and as it stated in README the current implementation uses ZBOSS NCP Host, and Nordic is releasing their ZBOSS NCP SoC firmware but not ESP.

By looking at their code it seems like it would be straightforward to send commands through RCP instead of NCP, but unfortunately our implementation is quite invested into using NCP Host. I've opened an issue at esp-zigbee-sdk and see if they could release ZBOSS NCP SoC firmware. If not it will likely not happen anytime soon.

Hedda commented 8 months ago

FYI, not sure if any use for this as an alternative to the ESP-IDF Zigbee library in the future if NCP suppot is added, but FYI, it looks like @P-R-O-C-H-Y is planning on porting the ESP-IDF Zigbee library and ZBOSS libraries to be available as Arduino library/libraries for ESP32:

https://github.com/espressif/arduino-esp32/issues/8807

https://github.com/espressif/esp32-arduino-lib-builder/issues/142

Hedda commented 4 months ago

Closing as done via zigpy-espzb and propriatory Zigbee NCP firmware:

https://github.com/lhespress/zigpy-espzb