Open hasan12977 opened 3 months ago
Hi @hasan12977, thank you for nice report. I have tested the esp32c3 with the RainMaker Switch example, and I did get the same errors:
E (75427) esp-x509-crt-bundle: PK verify failed with error FFFFBD70
E (75428) esp-x509-crt-bundle: Failed to verify certificate
E (75429) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x3000
E (75434) esp-tls: Failed to open new connection
E (75438) transport_base: Failed to open a new connection
E (75444) mqtt_client: Error transport connect
E (75447) esp_mqtt_glue: MQTT_EVENT_ERROR
How ever, the switch is working normally, so if toggle the switch in APP I am receiving the messages:
Received value = false for Switch - Power
Received value = true for Switch - Power
And also if I toggle the switch with the button on the board, the state is updated in the RainMaker app.
Is your code not working at all or it's working even though you got those errors. Thanks
Hello.
I did not say that there is something wrong with the functionality of the code, ie the switch itself. The issue is that in the beginning, right after uploading the code to esp32c3, the QR code should be printed but it is not. I get the error I mentioned above, the first error. In order to initialize the esp rainmaker, I would need to hold the reset button for more than 3 seconds. Then I can see QR code and BLE provision would work. Then I would get the same errors as you got while adding the device to rainmaker app. Switching the button on and off would work fine. But if I click on reset button or power off and on the esp32c3, I would get the same errors as I got in the beginning, ie the first error.
I forgot to mention but I have three esp32c3 super mini that I am testing the code with and all shows the same errors. I don't think there is any problem with regular esp32, and I kind of want to get rid of esp32c3 because I basically can't get them work the way I want. I mainly wanted to use these for low power applications but seems like it is easier and more reliable to use regular esp32. I am pretty sure these issues have something to do with RISC V architecture and development process.
Hi @hasan12977, I am currently investigating this issue.
The QR code is shown only if the device is on factory reset or WiFi reset. If you have your board already added in the RainMaker, and you just flashed new firmware, it will connect again to the same wifi, no need for QR code. But there is an issue, that its not connecting again, failing to start WiFI STA.
With this workaround I made it to work. Can you please test it on your end?
in arduino-esp32/libraries/WiFi/src/STA.cpp
on line 296 replace the STAClass::begin
function with this one:
bool STAClass::begin(bool tryConnect) {
if (!WiFi.enableSTA(true)) {
log_e("STA enable failed!");
return false;
}
if (!waitStatusBits(ESP_NETIF_STARTED_BIT, 1000)) {
log_e("NETIF_STARTED_BIT not set! try to connect anyway...");
}
if (tryConnect) {
return connect();
}
return true;
}
With this workaround this error will get printed:
[ 2036][E][STA.cpp:302] begin(): NETIF_STARTED_BIT not set! try to connect anyway...
But the board will reconnect to WiFi and RainMaker will continue working.
To see the QR code you would need to do one of the following:
The other errors that gets printed I am discussing with the RainMaker team.
One more thing, as you are not using OTA -> used partition without OTA. You should comment/remove RMaker.enableOTA(OTA_USING_TOPICS);
function in the code. By that you will also get rid of first 2 errors that gets printed.
Hi @P-R-O-C-H-Y i faced one of above issue which is ESP32 will not connect to wifi after its restart/power off
i follow your workaround "mentioned above" and it works .
18:40:57.508 -> https://rainmaker.espressif.com/qrcode.html?data={"ver":"v1","name":"PROV_1234","pop":"12345678","transport":"ble"}
18:41:30.259 -> [ 40723][I][RMaker.cpp:19] event_handler(): RainMaker Claim Successful.
18:41:45.262 -> E (55721) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
18:41:45.262 -> E (55722) esp-tls: create_ssl_handle failed
18:41:45.262 -> E (55722) esp-tls: Failed to open new connection
18:41:45.262 -> E (55724) transport_base: Failed to open a new connection
18:41:45.262 -> E (55730) mqtt_client: Error transport connect
18:41:45.262 -> E (55733) esp_mqtt_glue: MQTT_EVENT_ERROR
18:41:55.989 -> E (79686) wifi_prov_scheme_ble: bt_mem_release of BTDM failed 259
18:42:04.353 -> [ 74859][I][RMaker.cpp:21] event_handler(): Unhandled RainMaker Event:
18:42:19.647 -> Received value = false for Switch - Power
18:42:22.680 -> Received value = true for Switch - Power
i tested it from app the i clicked (Reboot ) from app
18:42:38.435 -> E (122123) wifi:NAN WiFi stop
18:42:38.435 -> E (122126) transport_base: poll_read select error 113, errno = Software caused connection abort, fd = 48
18:42:38.435 -> E (122126) mqtt_client: Poll read error: 119, aborting connection
18:42:38.435 -> ets Jul 29 2019 12:21:46
18:42:38.435 ->
18:42:38.435 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
18:42:38.494 -> configsip: 0, SPIWP:0xee
18:42:38.494 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
18:42:38.494 -> mode:DIO, clock div:1
18:42:38.494 -> load:0x3fff0030,len:4832
18:42:38.494 -> load:0x40078000,len:16460
18:42:38.494 -> load:0x40080400,len:4
18:42:38.494 -> load:0x40080404,len:3504
18:42:38.494 -> entry 0x400805cc
18:42:39.216 -> [ 85][I][RMaker.cpp:17] event_handler(): RainMaker Initialized.
18:42:39.216 -> [ 101][I][WiFiProv.cpp:159] beginProvision(): Already Provisioned
18:42:39.216 -> [ 108][I][WiFiProv.cpp:163] beginProvision(): Attempting connect to AP: xxxxxxx
18:42:39.217 ->
18:42:39.310 -> E (188) wifi_prov_scheme_ble: bt_mem_release of BTDM failed 259
18:42:40.301 -> [ 1193][E][STA.cpp:302] begin(): NETIF_STARTED_BIT not set! try to connect anyway...
18:43:00.776 -> Received value = false for Switch - Power
18:43:02.343 -> Received value = true for Switch - Power`
yes, the workaround works and gives the errors that you mentioned. it does reconnect after I restart the esp32c3 super minis. but I prefer to have these in my serial monitor:
so I can see what is happening in the background.
this is from esp idf example. this is what happens when I restart the esp32c3. I used temperture sensor example from esp idf rather than arduino:
also, as you can see OTA works too. but I dont have that option in arduino. only 4mb and 4mb without ota. when I choose rainmaker 4mb, it gives error saying the program is bigger than 2 mb.
yes, the workaround works and gives the errors that you mentioned. it does reconnect after I restart the esp32c3 super minis. but I prefer to have these in my serial monitor:
so I can see what is happening in the background.
this is from esp idf example. this is what happens when I restart the esp32c3. I used temperture sensor example from esp idf rather than arduino:
also, as you can see OTA works too. but I dont have that option in arduino. only 4mb and 4mb without ota. when I choose rainmaker 4mb, it gives error saying the program is bigger than 2 mb.
Our binary is quite bigger as we use BlueDroid as the BLE lib. In IDF the default one is NimBLE, which is taking less space. We plan to switch over the NimBLE in future to make the binaries smaller. That's why you are not able to use the OTA on 4MB chips when using BLE provisioning.
I am already discussing the errors with the RainMaker team.
Board
ESP32C3
Device Description
[ ]
Hardware Configuration
no
Version
v3.0.4
IDE Name
arduino
Operating System
macos 14.5 (23F79)
Flash frequency
80
PSRAM enabled
no
Upload speed
921600
Description
the esp rainmker example codes dont work propperly. after uploading the codes with rainmaker 4Mb no ota partition, it uploads the code but gives this error. in order to connect it to wifi, I have to hold the reset button for more than 3 seconds to initialize the esp rainmmaker, otherwise it does not initialize and fails. the failing part is 'failed to start STA!'.
after I manually reset the code using reset button, it gives me the qr code and let me connect to it. while connecting the esp to wifi and confirming, I get these error that sound like something did not work right.
after the device is added to esp rainmaker app, If I disconnect and reconnect the esp32, I get the same error I got in the beginning. so basically, esp rainmaker is not usable at the moment.
on the other side, when I used esp idf examples of esp rainmaker, I would get the qr code after uploading the code and the process would go seemless. and after discoonecting and reconnecting, the esp32c3 would reconnect to wifi with no problem.
Sketch
Debug Message
Other Steps to Reproduce
please try esp idf rainmaker example and compare it to this one. you will see that many thing is different, even the texts from the core debug info is different than the one in arduino.
I have checked existing issues, online documentation and the Troubleshooting Guide