Open Luxni opened 2 weeks ago
@Luxni Can you confirm it again use the firmware build0717.zip which match with fixes-serialization branch
build0717.zip is not work with esp32c6.
$ esptool.py --chip esp32c6 -p /dev/ttyACM0 \
-b 460800 --before=default_reset --after=hard_reset \
write_flash --flash_mode dio --flash_freq 80m --flash_size 2MB \
0x20000 esp_zigbee_ncp.bin \
0x8000 partition_table/partition-table.bin \
0xf000 ota_data_initial.bin
esptool.py v4.7.0
Serial port /dev/ttyACM0
Connecting....
Chip is ESP32-C6 (QFN40) (revision v0.0)
Features: WiFi 6, BT 5, IEEE802.15.4
Crystal is #40MHz
MAC: 40:4c:ca:ff:fe:49:61:40
BASE MAC: 40:4c:ca:49:61:40
MAC_EXT: ff:fe
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Unexpected chip id in image. Expected 13 but value was 16. Is this image for a different chip model?
A fatal error occurred: esp_zigbee_ncp.bin is not an ESP32-C6 image. Use --force to flash anyway.
can be make a new one for esp32c6?
@Luxni Please confirm it use the firmware build_1009.zip.
@lhespress
When the burning is finished, I can get the log in UART,
when I try to run the tests for it , but it seems connected time out (I tried using another usb port, but got the same result ).
Hardware: nanoESP32-C6 UART use the pin_24/pin_25
Tests:
import unittest
from unittest.mock import Mock
import zigpy.config as config
from zigpy_espzb.api import Znsp
async def test_api():
app = Mock()
znsp = Znsp(
app,
{
config.CONF_DEVICE_PATH: "/dev/ttyACM0",
config.CONF_DEVICE_BAUDRATE:115200,
},
)
await znsp.connect()
await znsp.form_network()
await znsp.start(autostart=False)
class TestAPI(unittest.IsolatedAsyncioTestCase):
async def test_demo(self):
await test_api()
pass
File "/home/luxni/homeassistant/zigpy-espzb/tests/test_api.py", line 21, in test_api
await znsp.form_network()
File "/home/luxni/homeassistant/zigpy-espzb/zigpy_espzb/api.py", line 314, in form_network
await self.send_command(
File "/home/luxni/homeassistant/zigpy-espzb/zigpy_espzb/api.py", line 146, in send_command
async with asyncio_timeout(COMMAND_TIMEOUT):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
raise TimeoutError from exc_val
TimeoutError [21, 5]
@Luxni Please confirm it use the firmware build_1011.zip which UART use GPIO4 (RX) and GPIO5 (TX).
@lhespress the test_api.py is working , but test_application.py is going wrong.
test_application.py
import unittest
import zigpy.config as config
from zigpy_espzb.zigbee.application import ControllerApplication
async def test_application():
app = ControllerApplication(
{
config.CONF_DEVICE: {
config.CONF_DEVICE_PATH: "/dev/ttyUSB0",
config.CONF_DEVICE_BAUDRATE:115200,
}
}
)
await app.connect()
class TestAPP(unittest.IsolatedAsyncioTestCase):
async def testapi(self):
await test_application()
File "/home/luxni/homeassistant/core/core-2024.9.3/venv/lib/python3.12/site-packages/zigpy/config/validators.py", line 125, in cv_ota_provider
provider_type = obj.get(zigpy.config.CONF_OTA_PROVIDER_TYPE)
^^^^^^^
AttributeError: 'Ledvance' object has no attribute 'get'
I checkout the error , it seems wrong with this code:
class ControllerApplication(zigpy.application.ControllerApplication):
_probe_config_variants = [
{zigpy.config.CONF_DEVICE_BAUDRATE: 115200},
]
_watchdog_period = 600 * 0.75
def __init__(self, config: dict[str, Any]):
"""Initialize instance."""
# config is error
# super().__init__(config=zigpy.config.ZIGPY_SCHEMA(config))
# should be
super().__init__(config=config)
self._api = None
self._pending = zigpy.util.Requests()
self._reconnect_task = None
when I running in homeassistant's ZHA , it still wrong with:
I (3274) ESP_NCP_ZB: dst_addr_mode 2, dst_short_addr fffe, dst_endpoint 0, src_endpoint 0, profile_id 00, cluster_id 02, tx_options 00, use_alias 00, radius 0
I (3294) ESP_NCP_ZB: esp_ncp_zb_aps_data_indication_handler 149
I (3304) ESP_NCP_ZB: esp_ncp_zb_aps_data_confirm_handler 189
I (3304) ESP_NCP_ZB: esp_ncp_zb_aps_data_indication_handler 149
I (3424) ESP_NCP_FRAME: 00 00 00 03 18 22 00 fe ff 00 00 00 00 00 00 00
I (3424) ESP_NCP_FRAME: 00 02 00 00 05 00 00 00 fe ff 00 00 00 00 00 00
I (3434) ESP_NCP_FRAME: 02 00 03 00 00 00 02 fe ff c6 27
I (3434) ESP_NCP_ZB: dst_addr_mode 2, dst_short_addr fffe, dst_endpoint 0, src_endpoint 0, profile_id 00, cluster_id 05, tx_options 00, use_alias 00, radius 0
I (3454) ESP_NCP_ZB: esp_ncp_zb_aps_data_indication_handler 149
I (3454) ESP_NCP_ZB: esp_ncp_zb_aps_data_confirm_handler 189
I (3464) ESP_NCP_ZB: esp_ncp_zb_aps_data_indication_handler 149
I (3494) ESP_NCP_FRAME: 00 00 00 03 19 23 00 fe ff 00 00 00 00 00 00 00
I (3494) ESP_NCP_FRAME: 00 02 00 00 04 00 00 00 fe ff 00 00 00 00 00 00
I (3494) ESP_NCP_FRAME: 03 00 04 00 00 00 03 fe ff f2 a0 92
I (3504) ESP_NCP_ZB: dst_addr_mode 2, dst_short_addr fffe, dst_endpoint 0, src_endpoint 0, profile_id 00, cluster_id 04, tx_options 00, use_alias 00, radius 0
I (3524) ESP_NCP_ZB: esp_ncp_zb_aps_data_indication_handler 149
I (3524) ESP_NCP_ZB: esp_ncp_zb_aps_data_confirm_handler 189
I (3534) ESP_NCP_ZB: esp_ncp_zb_aps_data_indication_handler 149
I (3564) ESP_NCP_FRAME: 00 00 04 00 1a 03 00 00 00 14 f6 c9
I (5604) ESP_NCP_FRAME: 00 00 00 03 1b 26 00 fe ff 00 00 00 00 00 00 00
I (5604) ESP_NCP_FRAME: 00 02 00 00 38 00 00 00 fe ff 00 00 00 00 00 00
I (5614) ESP_NCP_FRAME: 04 00 07 00 00 00 04 00 f8 ff 07 04 01 29 83
I (5614) ESP_NCP_ZB: dst_addr_mode 2, dst_short_addr fffe, dst_endpoint 0, src_endpoint 0, profile_id 00, cluster_id 38, tx_options 00, use_alias 00, radius 0
I (5634) ESP_NCP_ZB: esp_ncp_zb_aps_data_indication_handler 149
I (5644) ESP_NCP_ZB: esp_ncp_zb_aps_data_confirm_handler 189
Zigbee stack assertion failed common/zb_bufpool_mult.c:1226
abort() was called at PC 0x4201efbf on core 0
--- 0x4201efbf: done_with_this_ack at aps_main.c.obj:?
@Luxni Please confirm it use the firmware build_1016.zip which UART use GPIO4 (RX) and GPIO5 (TX).
@lhespress
There is great progress, homeassistant has created the device, but there is still one small problem to solve.
esp32c6 log:
I (3095) ESP_NCP_FRAME: 00 00 00 01 16 1a 00 01 04 01 00 04 00 05 04 00
I (3095) ESP_NCP_FRAME: 00 06 00 0a 00 19 00 01 05 01 00 20 00 00 05 02
I (3105) ESP_NCP_FRAME: 05 a0 01
I (3105) ESP_NCP_ZB: endpoint 1, profileId 104, deviceId 400, appFlags 0, inputClusterCount 5, outputClusterCount 4
I (3115) ESP_NCP_ZB: inputClusterList 00
I (3125) ESP_NCP_ZB: inputClusterList 06
I (3125) ESP_NCP_ZB: inputClusterList 0a
I (3125) ESP_NCP_ZB: inputClusterList 19
I (3135) ESP_NCP_ZB: inputClusterList 501
I (3135) ESP_NCP_ZB: outputClusterList 01
I (3145) ESP_NCP_ZB: outputClusterList 20
I (3145) ESP_NCP_ZB: outputClusterList 500
I (3155) ESP_NCP_ZB: outputClusterList 502
I (3235) ESP_NCP_FRAME: 00 00 00 03 17 22 00 00 00 00 00 00 00 00 00 00
I (3235) ESP_NCP_FRAME: 00 02 00 00 02 00 00 00 00 00 00 00 00 00 00 00
I (3245) ESP_NCP_FRAME: 01 00 03 00 00 00 01 00 00 66 dd
I (3245) ESP_NCP_ZB: dst_addr_mode 2, dst_short_addr 00, dst_endpoint 0, src_endpoint 0, profile_id 00, cluster_id 02, tx_options 00, use_alias 00, radius 0
I (3265) ESP_NCP_ZB: esp_ncp_zb_aps_data_indication_handler 149
I (3275) ESP_NCP_ZB: esp_ncp_zb_aps_data_confirm_handler 189
I (3275) ESP_NCP_ZB: esp_ncp_zb_aps_data_indication_handler 149
zigp-espzb log:
2024-10-17 11:59:30.714 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Znsp.data_received.<locals>.<lambda>() at /home/luxni/homeassistant/core/core-2024.9.3/venv/lib/python3.12/site-packages/zigpy_espzb/api.py:233 (None): File "/home/luxni/homeassistant/core/core-2024.9.3/homeassistant/runner.py", line 189, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
self.run_forever()
File "/usr/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
self._run_once()
File "/usr/lib/python3.12/asyncio/base_events.py", line 1978, in _run_once
handle._run()
File "/usr/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/home/luxni/homeassistant/core/core-2024.9.3/venv/lib/python3.12/site-packages/serial_asyncio_fast/__init__.py", line 143, in _read_ready
self._protocol.data_received(data)
File "/home/luxni/homeassistant/core/core-2024.9.3/venv/lib/python3.12/site-packages/zigpy_espzb/uart.py", line 103, in data_received
self._api.data_received(frame)
File "/home/luxni/homeassistant/core/core-2024.9.3/venv/lib/python3.12/site-packages/zigpy_espzb/api.py", line 233, in data_received
asyncio.get_running_loop().call_soon(lambda: handler(**params.as_dict()))
Traceback (most recent call last):
File "/usr/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/home/luxni/homeassistant/core/core-2024.9.3/venv/lib/python3.12/site-packages/zigpy_espzb/api.py", line 233, in <lambda>
asyncio.get_running_loop().call_soon(lambda: handler(**params.as_dict()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/luxni/homeassistant/core/core-2024.9.3/venv/lib/python3.12/site-packages/zigpy_espzb/api.py", line 260, in _handle_aps_data_indication
dst=addr_mode_with_eui64_to_addr_mode_address(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/luxni/homeassistant/core/core-2024.9.3/venv/lib/python3.12/site-packages/zigpy_espzb/types.py", line 70, in addr_mode_with_eui64_to_addr_mode_address
zigpy_addr_mode = addr_mode.to_zigpy_addr_mode()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/luxni/homeassistant/core/core-2024.9.3/venv/lib/python3.12/site-packages/zigpy_espzb/types.py", line 56, in to_zigpy_addr_mode
return {
^
KeyError: <ExtendedAddrMode.undefined_0xff: 255>
2024-10-17 11:59:41.083 DEBUG (MainThread) [zigpy_espzb.api] Serial '/dev/ttyUSB0' connection lost unexpectedly: None
I've had this problem before, use esp_zigbee_ncp
I try to solve this problem using the following code.
static bool esp_ncp_zb_aps_data_indication_handler(esp_zb_apsde_data_ind_t ind)
{
// .................
esp_ncp_zb_aps_data_ind_t *aps_data = (esp_ncp_zb_aps_data_ind_t *)output;
// bypass
if (0xff == ind.dst_addr_mode)
{
aps_data->dst_addr_mode = 2;
}
else
{
aps_data->dst_addr_mode = ind.dst_addr_mode;
}
//....................
}
Why ind.dst_addr_mode==0xff ?
I having some problems with ZHA of Homeassistant.
In order to make espzb work, I used some special methods (skipping some logic processing). But there are several issues that need to be addressed:
test environment: