#error: invalid operands of types 'int' and 'void(void*, esp_event_base_t, int32_t, void*)' {aka 'voi

25 messages · Page 1 of 1 (latest)

hot umbra
#

(This uses ESP-IDF framework)

I have frankly no idea what the error is telling me

   69 |                                                 &event_handler,```

```c++
    status = esp_event_handler_instance_register(WIFI_EVENT,
                                                ESP_EVENT_ANY_ID
                                                &event_handler,
                                                nullptr,
                                                nullptr);

    status = esp_event_handler_instance_register(IP_EVENT,
                                                IP_EVENT_STA_GOT_IP,
                                                &event_handler,
                                                nullptr,
                                                nullptr);

The function i am calling

void WiFiclient::event_handler(void *arg, esp_event_base_t event_base,
                            int32_t event_id, void *event_data)
wise mistBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

hot umbra
#

Documentation (incase needed):
esp_err_t esp_event_handler_instance_register(esp_event_base_t event_base, int32_t event_id, esp_event_handler_t event_handler, void *event_handler_arg, esp_event_handler_instance_t *instance)

Description:

    **event_base** – [in] the base ID of the event to register the handler for

    **event_id** – [in] the ID of the event to register the handler for

    **event_handler** – [in] the handler function which gets called when the event is dispatched

    **event_handler_arg** – [in] data, aside from event data, that is passed to the handler when it is called

    **instance** – [out] An event handler instance object related to the registered event handler and data, can be NULL. This needs to be kept if the specific callback instance should be unregistered before deleting the whole event loop. Registering the same event handler multiple times is possible and yields distinct instance objects. The data can be the same for all registrations. If no unregistration is needed, but the handler should be deleted when the event loop is deleted, instance can be NULL.
weary plinth
hot umbra
# weary plinth where is that code? inside `WiFiclient`?
void WiFiclient::event_handler(void *arg, esp_event_base_t event_base,
                            int32_t event_id, void *event_data)
{
    if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) 
    {
        esp_wifi_connect();

    } 

    else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) 
    {
        if (retry_num < max_retry) 
        {
            esp_wifi_connect();
            printf("Retrying to connect to WiFi, attempt: %d\n", retry_num);
            retry_num++;
        } 
        else 
        {
            xEventGroupSetBits(wifi::s_wifi_event_group, WIFI_FAIL_BIT);
        }
        printf("Connect to WiFi failed.\n");

    }

    else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
    {
        ip_event_got_ip_t* event = (ip_event_got_ip_t*)event_data;
        printf("GOT IP:%d.%d.%d.%d", IP2STR(&event->ip_info.ip));
        retry_num = 0;
        xEventGroupSetBits(wifi::s_wifi_event_group, WIFI_CONNECTED_BIT);

    }

}
weary plinth
#

I mean the code that has the error

#

esp_event_handler_instance_register(...)

hot umbra
#

I posted it

weary plinth
#

where is it

hot umbra
weary plinth
#

is it inside WiFiclient or not?

hot umbra
#

Yes

#

Its inside esp_err_t WiFiclient::_init(), where the event_handler_instance_register is.

weary plinth
#

is it static?

hot umbra
#

Yes

weary plinth
#

are there any errors in the compiler output?

hot umbra
#

Header: static esp_err_t _init();

#

Only error currently is: error: invalid operands of types 'int' and 'void(void*, esp_event_base_t, int32_t, void*)' {aka 'void(void*, const char*, long int, void*)'} to binary 'operator&' 69 | &event_handler,

weary plinth
#

ahh

#

I see it

potent yarrow
#

Missing comma?

weary plinth
#

you're missing a , in the previous line

hot umbra
#

fuck sakes

#

Thanks 😅 kekw

#

!solved