Description
Hardware:
Board: Wemos Lolin32
Core Installation version: Git master
IDE name: Arduino IDE
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Mac OSX
Description:
When running the example for WiFi provisioning I noticed I had to change the partitions to something non-default to even allow the sketch to fit. This surprised me as I had only experienced this before when working with BLE.
However I wanted to use the SoftAP transport method for provisioning. I modified the example sketch for this. I will put my code below.
Expected behaviour:
When I use SoftAP and don't explicitly use the BLE transport for provisioning the compiled binary shouldn't be so massive as it currently is.
Actual behaviour:
Just excluding the "WiFi.beginProvision" excludes all dependencies it seems.
But as soon as this line is uncommented he Sketch jumps from 724.780 to 1.472.272 bytes.
Sketch:
#include "WiFi.h"
void SysProvEvent(system_event_t *sys_event,wifi_prov_event_t *prov_event)
{
if(sys_event) {
switch (sys_event->event_id) {
case SYSTEM_EVENT_STA_GOT_IP:
Serial.print("\nConnected IP address : ");
Serial.println(ip4addr_ntoa(&sys_event->event_info.got_ip.ip_info.ip));
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
Serial.println("\nDisconnected. Connecting to the AP again... ");
break;
default:
break;
}
}
if(prov_event) {
switch (prov_event->event) {
case WIFI_PROV_START:
Serial.println("\nProvisioning started\nGive Credentials of your access point using \" Android app \"");
break;
case WIFI_PROV_CRED_RECV: {
Serial.println("\nReceived Wi-Fi credentials");
wifi_sta_config_t *wifi_sta_cfg = (wifi_sta_config_t *)prov_event->event_data;
Serial.print("\tSSID : ");
Serial.println((const char *) wifi_sta_cfg->ssid);
Serial.print("\tPassword : ");
Serial.println((char const *) wifi_sta_cfg->password);
break;
}
case WIFI_PROV_CRED_FAIL: {
wifi_prov_sta_fail_reason_t *reason = (wifi_prov_sta_fail_reason_t *)prov_event->event_data;
Serial.println("\nProvisioning failed!\nPlease reset to factory and retry provisioning\n");
if(*reason == WIFI_PROV_STA_AUTH_ERROR)
Serial.println("\nWi-Fi AP password incorrect");
else
Serial.println("\nWi-Fi AP not found....Add API \" nvs_flash_erase() \" before beginProvision()");
break;
}
case WIFI_PROV_CRED_SUCCESS:
Serial.println("\nProvisioning Successful");
break;
case WIFI_PROV_END:
Serial.println("\nProvisioning Ends");
break;
default:
break;
}
}
}
void setup() {
Serial.begin(115200);
//Delete saved credentials every time for debugging reasons
WiFi.enableSTA(true); // must be sta to disconnect erase
WiFi.disconnect(true,true);
WiFi.onEvent(SysProvEvent);
WiFi.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_EVENT_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", "PROV_ARDUINO_TEST");
}
void loop() {
}