mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-29 10:17:15 +02:00
v2.0.0 Add support for ESP32S2 and update ESP-IDF to 4.4 (#4996)
This is very much still work in progress and much more will change before the final 2.0.0 Some APIs have changed. New libraries have been added. LittleFS included. Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Mike Dunston <m_dunston@comcast.net> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: microDev <70126934+microDev1@users.noreply.github.com> Co-authored-by: tobozo <tobozo@users.noreply.github.com> Co-authored-by: bobobo1618 <bobobo1618@users.noreply.github.com> Co-authored-by: lorol <lorolouis@gmail.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net> Co-authored-by: Sweety <switi.mhaiske@espressif.com> Co-authored-by: Loick MAHIEUX <loick111@gmail.com> Co-authored-by: Larry Bernstone <lbernstone@gmail.com> Co-authored-by: Valerii Koval <valeros@users.noreply.github.com> Co-authored-by: 快乐的我531 <2302004040@qq.com> Co-authored-by: chegewara <imperiaonline4@gmail.com> Co-authored-by: Clemens Kirchgatterer <clemens@1541.org> Co-authored-by: Aron Rubin <aronrubin@gmail.com> Co-authored-by: Pete Lewis <601236+lewispg228@users.noreply.github.com>
This commit is contained in:
@ -12,16 +12,6 @@ This example allows Arduino user to choose either BLE or SOFTAP as a mode of tra
|
||||
|
||||
Using this API user can register to receive WiFi Events and Provisioning Events
|
||||
|
||||
#### Parameters passed
|
||||
|
||||
A function with following signature
|
||||
* void SysProvEvent(system_event_t * , wifi_prov_event_t * );
|
||||
|
||||
#### structure [ wifi_prov_event_t ]
|
||||
|
||||
* wifi_prov_cb_event_t event;
|
||||
* void * event_data;
|
||||
|
||||
## WiFi.beginProvision()
|
||||
|
||||
WiFi.beginProvision(void ( * scheme_cb)(), wifi_prov_scheme_event_handler_t scheme_event_handler, wifi_prov_security_t security, char * pop, char * service_name, char * service_key, uint8_t * uuid);
|
||||
|
@ -1,52 +1,42 @@
|
||||
#include "WiFiProv.h"
|
||||
void SysProvEvent(system_event_t *sys_event,wifi_prov_event_t *prov_event)
|
||||
#include "WiFi.h"
|
||||
void SysProvEvent(arduino_event_t *sys_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;
|
||||
}
|
||||
switch (sys_event->event_id) {
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||
Serial.print("\nConnected IP address : ");
|
||||
Serial.println(IPAddress(sys_event->event_info.got_ip.ip_info.ip.addr));
|
||||
break;
|
||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
||||
Serial.println("\nDisconnected. Connecting to the AP again... ");
|
||||
break;
|
||||
case ARDUINO_EVENT_PROV_START:
|
||||
Serial.println("\nProvisioning started\nGive Credentials of your access point using \" Android app \"");
|
||||
break;
|
||||
case ARDUINO_EVENT_PROV_CRED_RECV: {
|
||||
Serial.println("\nReceived Wi-Fi credentials");
|
||||
Serial.print("\tSSID : ");
|
||||
Serial.println((const char *) sys_event->event_info.prov_cred_recv.ssid);
|
||||
Serial.print("\tPassword : ");
|
||||
Serial.println((char const *) sys_event->event_info.prov_cred_recv.password);
|
||||
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;
|
||||
}
|
||||
case ARDUINO_EVENT_PROV_CRED_FAIL: {
|
||||
Serial.println("\nProvisioning failed!\nPlease reset to factory and retry provisioning\n");
|
||||
if(sys_event->event_info.prov_fail_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 ARDUINO_EVENT_PROV_CRED_SUCCESS:
|
||||
Serial.println("\nProvisioning Successful");
|
||||
break;
|
||||
case ARDUINO_EVENT_PROV_END:
|
||||
Serial.println("\nProvisioning Ends");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,8 +46,11 @@ void setup() {
|
||||
/* uint8_t uuid[16] = {0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf,
|
||||
0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02 };*/
|
||||
WiFi.onEvent(SysProvEvent);
|
||||
//WiFiProv.beginProvision(provSchemeBLE, WIFI_PROV_SCHEME_BLE_EVENT_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "PROV_XXX", NULL, NULL);
|
||||
WiFiProv.beginProvision(provSchemeSoftAP, WIFI_PROV_EVENT_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", NULL, NULL, NULL);
|
||||
#if CONFIG_IDF_TARGET_ESP32 && CONFIG_BLUEDROID_ENABLED
|
||||
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
|
||||
#else
|
||||
WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, "abcd1234", "Prov_123");
|
||||
#endif
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
Reference in New Issue
Block a user