M5NanoC6-Zigbee-Test icon indicating copy to clipboard operation
M5NanoC6-Zigbee-Test copied to clipboard

Compilation errors

Open WayneManion opened this issue 1 year ago • 2 comments

I tried to compile the provided code and got these errors in the Arduino IDE:

/home/wayne/Arduino/sketch_jun27a/sketch_jun27a.ino:59:41: error: could not convert '10' from 'int' to 'esp_zb_endpoint_config_t' {aka 'esp_zb_endpoint_config_s'}
   59 | #define HA_ESP_LIGHT_ENDPOINT           10    /* esp light bulb device endpoint, used to process light controlling commands */
      |                                         ^~
      |                                         |
      |                                         int
/home/wayne/Arduino/sketch_jun27a/sketch_jun27a.ino:200:64: note: in expansion of macro 'HA_ESP_LIGHT_ENDPOINT'
  200 |     esp_zb_ep_list_add_ep(esp_zb_ep_list, esp_zb_cluster_list, HA_ESP_LIGHT_ENDPOINT, ESP_ZB_AF_HA_PROFILE_ID, ESP_ZB_HA_ON_OFF_OUTPUT_DEVICE_ID);
      |                                                                ^~~~~~~~~~~~~~~~~~~~~
/home/wayne/Arduino/sketch_jun27a/sketch_jun27a.ino: In function 'void setup()':
/home/wayne/Arduino/sketch_jun27a/sketch_jun27a.ino:47:23: error: 'RADIO_MODE_NATIVE' was not declared in this scope; did you mean 'ZB_RADIO_MODE_NATIVE'?
   47 |         .radio_mode = RADIO_MODE_NATIVE,                        \
      |                       ^~~~~~~~~~~~~~~~~
/home/wayne/Arduino/sketch_jun27a/sketch_jun27a.ino:253:25: note: in expansion of macro 'ESP_ZB_DEFAULT_RADIO_CONFIG'
  253 |         .radio_config = ESP_ZB_DEFAULT_RADIO_CONFIG(),
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/wayne/Arduino/sketch_jun27a/sketch_jun27a.ino:52:33: error: 'HOST_CONNECTION_MODE_NONE' was not declared in this scope; did you mean 'ZB_HOST_CONNECTION_MODE_NONE'?
   52 |         .host_connection_mode = HOST_CONNECTION_MODE_NONE,      \
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/wayne/Arduino/sketch_jun27a/sketch_jun27a.ino:254:24: note: in expansion of macro 'ESP_ZB_DEFAULT_HOST_CONFIG'
  254 |         .host_config = ESP_ZB_DEFAULT_HOST_CONFIG(),
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~

exit status 1

Compilation error: could not convert '10' from 'int' to 'esp_zb_endpoint_config_t' {aka 'esp_zb_endpoint_config_s'}

WayneManion avatar Jun 27 '24 22:06 WayneManion

I am not at a place where I can refollow the steps I did and see if something changed. That said, it does look like they did some changes that might affect the parameters in this update on 24-May-2024:

https://github.com/espressif/esp-zigbee-sdk/commit/9b2a25d84666d8bc8515f84abcf92271524d2896

Just as an off the cuff idea, you might try changing :

#define HA_ESP_LIGHT_ENDPOINT           10    /* esp light bulb device endpoint, used to process light controlling commands */

to

#define HA_ESP_LIGHT_ENDPOINT           10U   /* esp light bulb device endpoint, used to process light controlling commands */

You might try posting a question on the ESP github for the zigbee stuff :

https://github.com/espressif/esp-zigbee-sdk/issues

Good hunting!

deepcoder avatar Jun 28 '24 17:06 deepcoder

This code uses an outdated version of the ESP IDF. Newer versions changed the definition of some of the used functions.

I made some progress and managed to compile it, it is recognized correctly in Home Assistant, with some hiccups apparently.

The first thing is to fix the definition of HA_ESP_LIGHT_ENDPOINT. It used to be just an integer, but now it is an structure, with one of the fields being the endpoint as used before:

// This is not supported anymore
// #define HA_ESP_LIGHT_ENDPOINT           10    /* esp light bulb device endpoint, used to process light controlling commands */

// Now it is a struct, and must be initialised accordingly
struct esp_zb_endpoint_config_s HA_ESP_LIGHT_ENDPOINT = {
  10,                                // uint8_t endpoint
  ESP_ZB_AF_HA_PROFILE_ID,           // uint16_t app_profile_id
  ESP_ZB_HA_ON_OFF_OUTPUT_DEVICE_ID, // uint16_t app_device_id
  1,                                 // uint32_t app_device_version
};

Now it is necessary to use the new signature for the esp_zb_ep_list_add_ep function.

    // This is no longer correct
    // esp_zb_ep_list_add_ep(esp_zb_ep_list, esp_zb_cluster_list, HA_ESP_LIGHT_ENDPOINT, ESP_ZB_AF_HA_PROFILE_ID, ESP_ZB_HA_ON_OFF_OUTPUT_DEVICE_ID);

    // This is the how it is done using the new API
    esp_zb_ep_list_add_ep(esp_zb_ep_list, esp_zb_cluster_list, HA_ESP_LIGHT_ENDPOINT);

It is also necessary to update the some configurations to use constants that got renamed (these use the ZB_ prefix that wasn't present before):

#define ESP_ZB_DEFAULT_RADIO_CONFIG()                           \
    {                                                           \
        .radio_mode = ZB_RADIO_MODE_NATIVE,                     \
    }

#define ESP_ZB_DEFAULT_HOST_CONFIG()                            \
    {                                                           \
        .host_connection_mode = ZB_HOST_CONNECTION_MODE_NONE,   \
    }

Last, it is necessary to make a small change to use the field of the struct when checking the endpoint ID:

    // This needs to be fixed to use the struct field instead 
    // if (message->info.dst_endpoint == HA_ESP_LIGHT_ENDPOINT) {

    // This is the how it is done using the struct field
    if (message->info.dst_endpoint == HA_ESP_LIGHT_ENDPOINT.endpoint) {

marcuscps avatar Aug 03 '24 18:08 marcuscps