Closed ruediger218 closed 6 days ago
This type is defined in zcl/zb_zcl_common.h
thanx a lot - but it's not the solution at all ;-(
sorry for my silly questions. now i get
undefined reference to `zb_buf_len_func(unsigned char)'
found that in zboss_api_buf.h but this didnt fix the error
@ruediger218 Hello, can you please share where did you get those APIs from? Are they available in esp-zigbee-sdk? If yes, can you please post a link? Thanks
hello, the source for the callback function is from https://github.com/espressif/esp-zigbee-sdk/issues/94 and yes, the code is working when i build in commandline idf
The zb_buf_len_func(unsigned char)
is located in zboss_api_buf.h
as you wrote.
I can see the file included in the libs for Esp32 Arduino.
Path:
/Users/prochy/Documents/Arduino/hardware/espressif/esp32/tools/esp32-arduino-libs/esp32c6/include/espressif__esp-zboss-lib/include/zboss_api_buf.h
I don't see an issue there? Can you post your includes?
my includes are as follow:
//include "zboss_api_zcl.h"
hmm #include "zboss_api.h"
is already including the "zboss_api_buf.h"
This is inside zboss_api.h
:
#include "zb_version.h"
#include "zb_channel_page.h"
#include "zboss_api_core.h"
#include "zboss_api_buf.h"
#include "zboss_api_internal.h"
#include "zboss_api_nwk.h"
#include "zboss_api_af.h"
#include "zboss_api_zdo.h"
#include "zboss_api_aps.h"
#ifdef ZB_ENABLE_HA
#include "zb_ha.h"
#endif
#include "zb_address.h"
#ifdef ZB_ENABLE_SE_MIN_CONFIG
#include "zboss_api_se.h"
#endif
#ifdef ZB_ENABLE_ZCL
#include "zboss_api_zcl.h"
#endif /* ZB_ENABLE_ZCL */
#ifdef ZB_ENABLE_ZGP
#include "zboss_api_zgp.h"
#endif
ok, with the includes:
//#include "zboss_api_buf.h"
//include "zboss_api_zcl.h"
i get the same error
c:/users/ruedi/appdata/local/arduino15/packages/esp32/tools/esp-rv32/2302/bin/../lib/gcc/riscv32-esp-elf/12.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\ruedi\AppData\Local\Temp\arduino\sketches\29E8A595CBE8784E42F9150A1F97F12D\sketch\BewZigbee03.ino.cpp.o: in function rawCmdHandlerCb(unsigned char)': C:\Users\ruedi\Documents\Arduino\BewZigbee03/BewZigbee03.ino:238: undefined reference to
zb_buf_len_func(unsigned char)'
c:/users/ruedi/appdata/local/arduino15/packages/esp32/tools/esp-rv32/2302/bin/../lib/gcc/riscv32-esp-elf/12.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\ruedi\Documents\Arduino\BewZigbee03/BewZigbee03.ino:239: undefined reference to zb_buf_get_tail_func(unsigned char, unsigned int)' c:/users/ruedi/appdata/local/arduino15/packages/esp32/tools/esp-rv32/2302/bin/../lib/gcc/riscv32-esp-elf/12.2.0/../../../../riscv32-esp-elf/bin/ld.exe: C:\Users\ruedi\Documents\Arduino\BewZigbee03/BewZigbee03.ino:241: undefined reference to
zb_buf_begin_func(unsigned char)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Compilation error: exit status 1
hello, in my opinion it's not a problem with the include's but a problem of the linker for me it seems that on arduino-esp the include doesn't "inform" the linker to get the spec. boss libs for linking (not all) or am i wrong? by the way: can i do anything as workarround to get the brightness callback in the normal esp_zb_core_action_handler_register ?
@ruediger218 Will you be able to test it with Arduino as component in IDF to see if its working for you there and you have everything linked properly? Also if you can post reproducible sketch for me so I can investigate? Thanks
Those are our linked prebuilt libs in Arduino, depending on selected zigbee mode:
esp32h2.menu.ZigbeeMode.ed=Zigbee ED (end device)
esp32h2.menu.ZigbeeMode.ed.build.zigbee_mode=-DZIGBEE_MODE_ED
esp32h2.menu.ZigbeeMode.ed.build.zigbee_libs=-lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port
esp32h2.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator)
esp32h2.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR
esp32h2.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port
esp32h2.menu.ZigbeeMode.rcp=Zigbee RCP (radio co-processor)
esp32h2.menu.ZigbeeMode.rcp.build.zigbee_mode=-DZIGBEE_MODE_RCP
esp32h2.menu.ZigbeeMode.rcp.build.zigbee_libs=-lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port
ok. i try to collect minimal files: Here is the idf file `/*
static const char *TAG = "test_rawmode";
bool rawCmdHandlerCb(uint8_t bufid) { uint8_t buf[zb_buf_len(bufid)]; zb_zcl_parsed_hdr_t *cmd_info = ZB_BUF_GET_PARAM(bufid, zb_zcl_parsed_hdr_t); printf("cluster id: 0x%x, command id: %d\n", cmd_info->cluster_id, cmd_info->cmd_id); memcpy(buf, zb_buf_begin(bufid), sizeof(buf)); if ((cmd_info->cluster_id == 8) && (cmd_info->cmd_id == 4)){ ESP_LOGI("RAW", "brightness: %d", buf[0]); } else{ ESP_LOGI("RAW", "bufid: %d size: %d", bufid, sizeof(buf)); for (int i = 0; i < sizeof(buf); ++i) { ESP_LOGI("RAW", "buf[%d]: %d", i, buf[i]); //printf("0x%02X ", buf[i]); } //printf("\n"); } //return true; return false; }
static void esp_zb_task(void *pvParameters) { esp_zb_raw_command_handler_register(rawCmdHandlerCb); }
void app_main(void)
{
xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL);
}
the arduino sketch is following
#define ARDUINO
static const char *TAG = "test_rawmode";
/ Default End Device config /
{ \ .esp_zb_role = ESP_ZB_DEVICE_TYPE_ED, .install_code_policy = INSTALLCODE_POLICY_ENABLE, \ .nwk_cfg = { \ .zed_cfg = \ { \ .ed_timeout = ED_AGING_TIMEOUT, \ .keep_alive = ED_KEEP_ALIVE, \ }, \ }, \ }
{ .radio_mode = ZB_RADIO_MODE_NATIVE, }
{ .host_connection_mode = ZB_HOST_CONNECTION_MODE_NONE, }
/ Zigbee configuration /
static esp_err_t zb_attribute_handler(const esp_zb_zcl_set_attr_value_message_t *message);
bool rawCmdHandlerCb(uint8_t bufid) { uint8_t buf[zb_buf_len(bufid)]; zb_zcl_parsed_hdr_t *cmd_info = ZB_BUF_GET_PARAM(bufid, zb_zcl_parsed_hdr_t); printf("cluster id: 0x%x, command id: %d\n", cmd_info->cluster_id, cmd_info->cmd_id); memcpy(buf, zb_buf_begin(bufid), sizeof(buf)); if ((cmd_info->cluster_id == 8) && (cmd_info->cmd_id == 4)){ ESP_LOGI("RAW", "brightness: %d", buf[0]); } else{ ESP_LOGI("RAW", "bufid: %d size: %d", bufid, sizeof(buf)); for (int i = 0; i < sizeof(buf); ++i) { ESP_LOGI("RAW", "buf[%d]: %d", i, buf[i]); //printf("0x%02X ", buf[i]); } //printf("\n"); } //return true; return false; }
static void esp_zb_task(void *pvParameters) { esp_zb_raw_command_handler_register(rawCmdHandlerCb); }
void app_main(void) { xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL); }
/***** Arduino functions **/ void setup() {
Serial.begin(115200); // set default RX/TX pin because nothing was defined in the call
// Init Zigbee Serial.println("Zigbee init"); esp_zb_platform_config_t config = { .radio_config = ESP_ZB_DEFAULT_RADIO_CONFIG(), .host_config = ESP_ZB_DEFAULT_HOST_CONFIG(), }; ESP_ERROR_CHECK(esp_zb_platform_config(&config));
// Start Zigbee task //Serial.println("Zigbee start main"); xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL); }
void loop() {
//empty, zigbee running in task
}
the idf compiles fine but the arduino sketch breaks with undefined reference to
zb_buf_len_func(unsigned char)'
here comes test_rawmode.h `/*
/ Zigbee configuration /
{ \
.esp_zb_role = ESP_ZB_DEVICE_TYPE_ED, \
.install_code_policy = INSTALLCODE_POLICY_ENABLE, \
.nwk_cfg.zed_cfg = { \
.ed_timeout = ED_AGING_TIMEOUT, \
.keep_alive = ED_KEEP_ALIVE, \
}, \
}
{ \
.radio_mode = RADIO_MODE_NATIVE, \
}
{ \
.host_connection_mode = HOST_CONNECTION_MODE_NONE, \
}
`
@ruediger218 , please try to include zboss_api_h with linkage specification:
extern "C" {
}
thats the solution - thank you so much ! one little difference is that the cluster_id in arduino ide is a int > 1000 and when i use idf then its < 100, have you a hint for that?
I'm not sure, does the cluster_id number make sense? Does the other device only send to cluster_id 8(LEVEL_CONTROL)? In the esp_zigbee_zcl_common.h file, there is an enum listing the cluster_id numbers.
the cluster id is in the upper byte (here "8")
btw can you have a look on #9856 it seems like a similar problem?
I tried your code from issue #9856, here it worked. The difference is that I used a CC2531 dongle with Z2M. Try debugging with wireshark to see if there are zigbee packets leaving from your board.
I tried your code from issue #9856, here it worked. The difference is that I used a CC2531 dongle with Z2M. Try debugging with wireshark to see if there are zigbee packets leaving from your board.
thanks for your help. i made some more new tests and it seems that i had - for every software change in my esp code - stop zigbee2mqtt, delete my device in zigbee2mqtt database, start zigbee2mqtt and at last start my esp device (with changed code). when i changed code without deleting in the zigbee2mqtt database then there are no temperature changes visible in zigbee2mqtt status.
Hello @ruediger218, as your code uses esp-zigbee-sdk APIs, I am closing this issue. If you want you can try the Zigbee Library that was recently added to the Arduino core. If you want to continue on this issue, I suggest to open an issue in the esp-zigbee-sdk repository. Thanks
Board
esp32c6
Device Description
esp32c6 dev module
Hardware Configuration
no
Version
v3.0.0
IDE Name
arduino ide
Operating System
windows 11
Flash frequency
80mhz
PSRAM enabled
yes
Upload speed
115200
Description
i want to develop a zigbee device with 4 on/off endpoints + a light endpoint for brightness configuration. my sourcecode based on the HA_on_off_light example i am not able to get callbacks when changing brightness. therefor i found a hint in using the function
this works perfect when i compile per commandline. in arduino ide i get the message: 'zb_zcl_parsed_hdr_t' was not declared in this scope are these raw functions not in the arduino environment? how can i get access to brightness (analog) values?
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide