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

Bind switch to coordinator bind error - how to debug? (TZ-1134) #428

Closed
mw75 opened this issue Sep 12, 2024 · 1 comment
Closed

Bind switch to coordinator bind error - how to debug? (TZ-1134) #428

mw75 opened this issue Sep 12, 2024 · 1 comment
Labels

Comments

@mw75
Copy link

mw75 commented Sep 12, 2024

Question

I'm implementing a Zigbee to Can-Bus bridge. Can-bus to Power-Plug is working by a modified Zigbee_Light_Switch example.

Now i try to get actions/attribute updates from a switch/remote. I can read the cluster list from the simple description, but when i try to bind the on-Off-cluster to the coordinator i just get an error in the bind callback.

How to debug what's wrong?

I have registered an action handler and expect calls when the switch button is pressed. Is this a valid assumption?

Additional context.

static void simple_desc_cb(esp_zb_zdp_status_t zdo_status, esp_zb_af_simple_desc_1_1_t *simple_desc, void *user_ctx)
{
    log_i("simple_desc_cb called: %s",esp_err_to_name(zdo_status ) );
    uint16_t *dev = (uint16_t*)(user_ctx);
    if (zdo_status == ESP_ZB_ZDP_STATUS_SUCCESS) {
        log_i("Simple desc response: status(%s), device_id(%d), app_version(%d), profile_id(0x%x), endpoint_ID(%d)",
            esp_err_to_name(zdo_status),
            simple_desc->app_device_id,
            simple_desc->app_device_version,
            simple_desc->app_profile_id,
            simple_desc->endpoint
        );
        log_i("Cluster ID list:");
        for (int i = simple_desc->app_input_cluster_count; i < (simple_desc->app_input_cluster_count + simple_desc->app_output_cluster_count); i++) {
            log_i("0x%x",*(simple_desc->app_cluster_list + i));
            if(*(simple_desc->app_cluster_list + i)==ESP_ZB_ZCL_CLUSTER_ID_ON_OFF){
              esp_zb_zdo_bind_req_param_t bind_req;
              bind_req.src_endp = simple_desc->endpoint;
              bind_req.cluster_id = ESP_ZB_ZCL_CLUSTER_ID_ON_OFF;
              bind_req.dst_addr_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
              esp_zb_get_long_address(bind_req.dst_address_u.addr_long);
              bind_req.dst_endp = HA_ONOFF_SWITCH_ENDPOINT;
              bind_req.req_dst_addr = esp_zb_get_short_address();
              log_i("Try to bind On/Off");
              esp_zb_zdo_device_bind_req(&bind_req, bind_cb, user_ctx);
            }
        }
    }
}
static void bind_cb(esp_zb_zdp_status_t zdo_status, void *user_ctx) {
  log_i("bind_cb called: %s",esp_err_to_name(zdo_status ) );
  if (zdo_status == ESP_ZB_ZDP_STATUS_SUCCESS) {
    log_i("Bound successfully!");
    if (user_ctx) {
      zb_device_params_t *dev = (zb_device_params_t *)user_ctx;
      log_i("The device originating from address(0x%x) on endpoint(%d)", dev->short_addr, dev->endpoint);
      free(dev);
    }
  }
}

[ 7854][I][Zigbee_Light_Switch.ino:157] simple_desc_cb(): simple_desc_cb called: ESP_OK
[ 7854][I][Zigbee_Light_Switch.ino:160] simple_desc_cb(): Simple desc response: status(ESP_OK), device_id(2080), app_version(1), profile_id(0x104), endpoint_ID(1)
[ 7855][I][Zigbee_Light_Switch.ino:167] simple_desc_cb(): Cluster ID list:
[ 7856][I][Zigbee_Light_Switch.ino:169] simple_desc_cb(): 0x3
[ 7856][I][Zigbee_Light_Switch.ino:169] simple_desc_cb(): 0x4
[ 7856][I][Zigbee_Light_Switch.ino:169] simple_desc_cb(): 0x5
[ 7857][I][Zigbee_Light_Switch.ino:169] simple_desc_cb(): 0x6
[ 7857][I][Zigbee_Light_Switch.ino:178] simple_desc_cb(): Try to bind On/Off
[ 7857][I][Zigbee_Light_Switch.ino:169] simple_desc_cb(): 0x8
[ 7858][I][Zigbee_Light_Switch.ino:169] simple_desc_cb(): 0x19
[ 7858][I][Zigbee_Light_Switch.ino:169] simple_desc_cb(): 0x1000
[ 7859][I][Zigbee_Light_Switch.ino:113] bind_cb(): bind_cb called: ERROR

@mw75 mw75 added the Question label Sep 12, 2024
@github-actions github-actions bot changed the title Bind switch to coordinator bind error - how to debug? Bind switch to coordinator bind error - how to debug? (TZ-1134) Sep 12, 2024
@lpy4105
Copy link
Contributor

lpy4105 commented Sep 19, 2024

You can print out the value of zdo_status and check the defination of esp_zb_zdp_status_t to identify the reason for the zdo request failure.

Going over the code you provided, I'm suspecting that you populated a wrong request destionation address.

bind_req.req_dst_addr = esp_zb_get_short_address();

I believe it should be the peer address you want the request to be sent to.

@mw75 mw75 closed this as completed Sep 25, 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

2 participants