Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to implement command response manually (TZ-1197) #449

Open
kioelka opened this issue Oct 7, 2024 · 0 comments
Open

how to implement command response manually (TZ-1197) #449

kioelka opened this issue Oct 7, 2024 · 0 comments
Labels

Comments

@kioelka
Copy link

kioelka commented Oct 7, 2024

Question

ESP_IDF v.5.1.3 (also tested on 5.3.0), same problem

i'm trying to implement responds on command requests. i am doing something wrong but i dont know what please help to find mistakes.
on snippet i execute cluster 0x0201 (thermostat) command 0x02 (get weekly schedule) args (01 [day] 01[heat]) on another ESP coordinator using esp_zigbee_cli ROM
log on coordinator CLI

I (12758293) ESP_ZB_CLI: Network(0xf175) is open for 180 seconds
E (12760883) : Request timed out
W (12938313) ESP_ZB_CLI: Network(0xf175) closed, devices joining not allowed.
> zcl -c 6dbd 1 0x0201 2 payload 0101

code on ZR thermostat

... //somewhere in init function
    esp_zb_raw_command_handler_register(zb_command_handler);
...


static bool zb_command_handler(uint8_t bufid){
    uint16_t len = zb_buf_len(bufid);
    uint8_t * buf = checkMalloc(len);
    memcpy(buf, zb_buf_begin(bufid), len);
    zb_zcl_parsed_hdr_t *cmd_info = ZB_BUF_GET_PARAM(bufid, zb_zcl_parsed_hdr_t);
    DEBUG_MSG(CDL,(COL_GREEN"from addr 0x%04X cluster id: 0x%x, command id: %d\n", cmd_info->addr_data.common_data.source.u.short_addr, 
        cmd_info->cluster_id, cmd_info->cmd_id));
    ESP_LOG_BUFFER_HEXDUMP("bufID", buf, len, 0);
    switch (cmd_info->cmd_id){
        case ESP_ZB_ZCL_CMD_THERMOSTAT_GET_WEEKLY_SCHEDULE:
            zb_zcl_thermostat_get_weekly_schedule_req_t * req = (zb_zcl_thermostat_get_weekly_schedule_req_t*)buf; 
            uint8_t sendBuffer[512];
            esp_zb_lock_acquire(portMAX_DELAY);
            ZB_ZCL_THERMOSTAT_SEND_GET_WEEKLY_SCHEDULE_REQ(sendBuffer, cmd_info->addr_data.common_data.source.u.short_addr, ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                cmd_info->addr_data.common_data.src_endpoint, cmd_info->addr_data.common_data.dst_endpoint, ZB_AF_HA_PROFILE_ID, true, NULL, req->days_to_return,
                req->mode_to_return);
            esp_zb_lock_release();
            break;   
        default:
        break;
    }
    
    zb_buf_free(bufid);
    freeNull(buf);
    return true;
}

log on ZR thermostat

I (5285) zigbee.c:0413 : from addr 0x0000 cluster id: 0x201, command id: 2

I (5285) bufID: 0x4083a628   01 01                                             |..|
Zigbee stack assertion failed common/zb_bufpool_mult.c:640

abort() was called at PC 0x420b9bfb on core 0
0x420b9bfb: zb_assert at ??:?

Core  0 register dump:
MEPC    : 0x408005f6  RA      : 0x4080e5e8  SP      : 0x4082b520  GP      : 0x40813b70
0x408005f6: panic_abort at C:/Users/kelka/esp/v5.1.3/esp-idf/components/esp_system/panic.c:472
0x4080e5e8: __ubsan_include at C:/Users/kelka/esp/v5.1.3/esp-idf/components/esp_system/ubsan.c:313

TP      : 0x407ead80  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130
S0/FP   : 0x4082b55c  S1      : 0x4082b540  A0      : 0x4082b55c  A1      : 0x4082b53e
A2      : 0x00000000  A3      : 0x4082b589  A4      : 0x00000001  A5      : 0x40825000
A6      : 0x00000000  A7      : 0x76757473  S2      : 0x00000000  S3      : 0x000000a0
S4      : 0x4081c1d0  S5      : 0x420dda62  S6      : 0x00000000  S7      : 0x00000000
0x420dda62: zb_apsde_data_acknowledged at ??:?

S8      : 0x0000003d  S9      : 0x00000000  S10     : 0x000000a0  S11     : 0x00000007
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938
MSTATUS : 0x00001881  MTVEC   : 0x40800001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000
0x40800001: _vector_table at ??:?

MHARTID : 0x00000000

Stack memory:
4082b520: 0x000000a0 0x00000000 0x4082b53c 0x408117da 0x00000000 0x420dda62 0x4081c1d0 0x00000030
0x408117da: __assert_func at C:/Users/kelka/esp/v5.1.3/esp-idf/components/newlib/assert.c:34
0x420dda62: zb_apsde_data_acknowledged at ??:?

4082b540: 0x62303234 0x62666239 0x421bb700 0x408178a8 0x4082b540 0x408178c4 0x4082b53c 0x726f6261
4082b560: 0x20292874 0x20736177 0x6c6c6163 0x61206465 0x43502074 0x34783020 0x39623032 0x20626662
4082b580: 0x63206e6f 0x2065726f 0x00000030 0x00000000 0x0000002f 0x4081c1d0 0x421bb7ed 0x420b9bfe
0x420b9bfe: zb_aps_multi_pre_link_key_init at zb_init_common.c.obj:?

4082b5a0: 0x00000000 0x00000000 0x00000000 0x00000280 0x00000000 0x00020000 0x000000a0 0x420b8b6a
0x420b8b6a: zb_buf_free_func at ??:?

4082b5c0: 0x40840984 0x420dda62 0x00000000 0x40840984 0x40840984 0x00000000 0x000000a0 0x420ddd50
0x420dda62: zb_apsde_data_acknowledged at ??:?
0x420ddd50: zb_apsde_data_acknowledged at ??:?

4082b5e0: 0x0000000f 0x000000a0 0x00000042 0x40839138 0x000000a0 0x00000000 0x00000000 0x00516718
4082b600: 0x00000000 0x0000a0d5 0x7fffffff 0x000000ff 0x0000000f 0x00000001 0x7fffffff 0x000000ff
4082b620: 0x0000000f 0x00000000 0x4081c1d0 0x420be808 0x4083a1f8 0x00000000 0x00000000 0x00000000
0x420be808: zb_sched_loop_iteration at ??:?

4082b640: 0x4083a1f8 0x00000000 0x4083a098 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4082b660: 0x00000000 0x00000000 0x00000000 0x4083a418 0x4083a1f8 0x00000001 0x4083a224 0x420af4d6
0x420af4d6: esp_zb_stack_main_loop_iteration at ??:?

4082b680: 0x00000000 0x00000000 0x00000000 0x420af4ec 0x4083a1f8 0x00000001 0x4083a224 0x42039988
0x420af4ec: esp_zb_stack_main_loop at ??:?
0x42039988: esp_zb_task at X:/Dev/DS_Projects/dsexs-3-cc-3-vasiltsov/trunk/trunk_esp32c3/main/zigbee/zigbee.c:533

4082b6a0: 0xa5a5a5a5 0x01a5a5a5 0x01010401 0xa5a5a003 0x00000408 0x0a28ffff 0x010407d0 0x00000001
4082b6c0: 0x00000000 0x0000000a 0x00000000 0x00787307 0x00000000 0x00000000 0x00000000 0x72657409
4082b6e0: 0x006f656e 0x00000000 0x00000000 0x00000000 0x00000200 0x00000000 0x00000001 0x00000001
4082b700: 0x00000000 0x00000001 0x00000002 0x35414343 0x34363237 0x36343034 0x39443941 0x30413644
4082b720: 0x30303030 0x00383431 0x02010100 0x00000001 0x00000000 0x00000000 0x00000000 0x00000000
4082b740: 0x003c0001 0x00000032 0x00000000 0x00000000 0x00000000 0x003c0001 0x00000000 0xffff0104
4082b760: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4082b780: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4082b7a0: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x00000160 0x4082b2e0 0x000001c3 0x40818570 0x40818570
4082b7c0: 0x4082b7b0 0x40818568 0x00000014 0x4083a298 0x4083a298 0x4082b7b0 0x00000000 0x00000005
4082b7e0: 0x4082a7ac 0x6267695a 0x6d5f6565 0x006e6961 0x00000010 0x00000000 0x4082b7a0 0x0000000b
4082b800: 0x00000000 0x00000005 0x00000001 0x00000000 0x00000000 0x0002aa0f 0x00000000 0x40828fa4
4082b820: 0x4082900c 0x40829074 0x00000000 0x00000000 0x00000001 0x00000000 0x00000000 0x00000000
4082b840: 0x421897a0 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
0x421897a0: _cleanup_r at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/riscv32-esp-elf/src/newlib/newlib/libc/stdio/findfp.c:229

4082b860: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4082b880: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4082b8a0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4082b8c0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4082b8e0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4082b900: 0x00000000 0x00000000 0x00000000 0x40000000 0x0000005c 0x00000000 0x4082b914 0x00000000
0x40000000: _start in ROM




ELF file SHA256: 852214493eecccb3

Rebooting in  3 seconds...

Additional context.

No response

@kioelka kioelka changed the title how to implement commdna respone manually how to implement commdna response manually Oct 7, 2024
@kioelka kioelka changed the title how to implement commdna response manually how to implement command response manually Oct 7, 2024
@github-actions github-actions bot changed the title how to implement command response manually how to implement command response manually (TZ-1197) Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant