Rainmaker & WifiLocation

Quabis
Posts: 10
Joined: Sun Nov 20, 2022 5:28 pm

Rainmaker & WifiLocation

Postby Quabis » Sun Nov 20, 2022 5:37 pm

Hello Everybody,

I got Rainmaker Running and i got WifiLocation(https://github.com/gmag11/WifiLocation) running by themselfes, but as soon as i merge the WifiLocation to my working Rainmaker solution i get lot's of errors.

ERROR list
[ 23373][E][esp_crt_bundle.c:184] esp_crt_bundle_attach(): Failed to attach bundle
E (23821) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x7680
E (23822) esp-tls: Failed to open new connection
E (23822) TRANSPORT_BASE: Failed to open a new connection
E (23827) MQTT_CLIENT: Error transport connect
E (23830) esp_mqtt_glue: MQTT_EVENT_ERROR


and Sometimes:
E (3208) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x7680
E (3209) esp-tls: Failed to open new connection
E (3209) TRANSPORT_BASE: Failed to open a new connection
E (3215) HTTP_CLIENT: Connection failed, sock < 0
E (3217) esp_claim: Failed to open connection to https://esp-claiming.rainmaker.espressif.com/claim/initiate
E (3227) esp_claim: Claim Init Request Failed.
E (3231) esp_claim: Claim Init Sequence Failed.
E (3235) esp_rmaker_core: esp_rmaker_self_claim_perform() returned -1. Aborting


I think it mixes up the certificates or sth, since WifiLocation usses the google API....

Did anyone tried something similiar yet?


Thank you and best regards
Quabsi

Quabis
Posts: 10
Joined: Sun Nov 20, 2022 5:28 pm

Re: Rainmaker & WifiLocation

Postby Quabis » Sun Dec 25, 2022 1:50 pm

no one?

ESP_Piyush
Posts: 309
Joined: Wed Feb 20, 2019 7:02 am

Re: Rainmaker & WifiLocation

Postby ESP_Piyush » Tue Dec 27, 2022 10:13 am

There are high chances that the issue is occurring because of low memory. Can you try disabling local control (CONFIG_ESP_RMAKER_LOCAL_CTRL_ENABLE) to free up some memory and see if this works?

Quabis
Posts: 10
Joined: Sun Nov 20, 2022 5:28 pm

Re: Rainmaker & WifiLocation

Postby Quabis » Tue Dec 27, 2022 9:39 pm

Hi ESP_Piyush,

thank you very much for your reply, how and where can i find the config file i need to change?
Also how much Memmory should be available?
I included

Code: Select all

Serial.println("Available Ram: " + String(ESP.getFreeHeap()) + " byte");
before calling

Code: Select all

WifiLocation location (googleApiKey);
loc = location.getGeoFromWiFi();
it looks like i got: 174720 byte Available Ram...



Best regards and thank you for your help!

sanketwadekar
Posts: 32
Joined: Tue Jul 26, 2022 10:08 am

Re: Rainmaker & WifiLocation

Postby sanketwadekar » Wed Dec 28, 2022 3:27 am

Hi,
The error code -0x7680(MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED) means that no CA chain is set. Secondly, local control is not available for Rainmaker with Arduino.

Alternatively, you can let the device connect to the MQTT broker first and then run your code by creating an event handler like this.

Code: Select all

/* Event handler for catching RainMaker events */
static void event_handler(void* arg, esp_event_base_t event_base,
                          int32_t event_id, void* event_data)
{
    if (event_base == RMAKER_COMMON_EVENT) {
        switch (event_id) {
            case RMAKER_MQTT_EVENT_CONNECTED:
                log_i("MQTT Connected.");
                // Your WiFiLocation code
                break;
            default:
                break;
        }
    }
}
To attach event handler, you need to call the function below after RMaker.initNode() function inside setup()

Code: Select all

void setup()
{
    ....
    esp_event_handler_register(RMAKER_COMMON_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL);
    ....
}

Quabis
Posts: 10
Joined: Sun Nov 20, 2022 5:28 pm

Re: Rainmaker & WifiLocation

Postby Quabis » Thu Dec 29, 2022 8:32 pm

Thank you very much for the great idea.

i tried it the following way:

Code: Select all

 /* Event handler for catching RainMaker events */
static void event_handler(void* arg, esp_event_base_t event_base,
                          int32_t event_id, void* event_data)
{
    if (event_base == RMAKER_COMMON_EVENT) {
        switch (event_id) {
            case  RMAKER_MQTT_EVENT_CONNECTED:
                {
                    log_i("MQTT Connected.");
                    // Your WiFiLocation code
                    Serial.println("getting location...");
                    Serial.println("Available Ram: " + String(ESP.getFreeHeap()) + " byte");
                    WiFiClientSecure  client;   // <= as soon as i include this line it fails
                    location_t loc2 = getGeoFromWiFi2(client);
                    Serial.println("Latitude: " + String(loc.lat, 7));
                    Serial.println("Longitude: " + String(loc.lon, 7));
                    Serial.println("Accuracy: " + String(loc.accuracy));
                    break;
                }
            default:
                break;
        }
    }
}
but i still get the same error below.

[247842][E][esp_crt_bundle.c:184] esp_crt_bundle_attach(): Failed to attach bundle
E (248256) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x7680
E (248256) esp-tls: Failed to open new connection
E (248256) TRANSPORT_BASE: Failed to open a new connection
E (248262) MQTT_CLIENT: Error transport connect
E (248265) esp_mqtt_glue: MQTT_EVENT_ERROR


it seems that as soon as i create a new WiFiClientSecure object it fails, even before the MQTT Event is fired...
in fact it never reaches the code above because RMAKER_MQTT_EVENT_CONNECTED is never happening.

Quabis
Posts: 10
Joined: Sun Nov 20, 2022 5:28 pm

Re: Rainmaker & WifiLocation

Postby Quabis » Sun Jan 01, 2023 8:36 pm

after more debugging it looks like the error occures because of setCACert(googleCA); in WifiLocation solution. Maybe that's overwritting something from Rainmaker...

Quabis
Posts: 10
Joined: Sun Nov 20, 2022 5:28 pm

Re: Rainmaker & WifiLocation

Postby Quabis » Tue Jan 10, 2023 6:36 am

I found the solution => https://github.com/espressif/arduino-esp32/issues/7363

topic can be closed

Who is online

Users browsing this forum: No registered users and 27 guests