Unverified Commit d8a99ed4 authored by Pedro Minatel's avatar Pedro Minatel Committed by GitHub

Added RainMaker support on Arduino IDE for ESP32-C3/S2/S3 (#6598)

* Added RainMaker support on Arduino IDE for ESP32-C3/S2/S3

Closes #6573
Note related to the issue #6435
parent 0a1ba74b
...@@ -184,6 +184,9 @@ esp32s3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 ...@@ -184,6 +184,9 @@ esp32s3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
esp32s3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS) esp32s3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS)
esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 esp32s3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
esp32s3.menu.PartitionScheme.rainmaker=RainMaker
esp32s3.menu.PartitionScheme.rainmaker.build.partitions=rainmaker
esp32s3.menu.PartitionScheme.rainmaker.upload.maximum_size=3145728
esp32s3.menu.CPUFreq.240=240MHz (WiFi) esp32s3.menu.CPUFreq.240=240MHz (WiFi)
esp32s3.menu.CPUFreq.240.build.f_cpu=240000000L esp32s3.menu.CPUFreq.240.build.f_cpu=240000000L
...@@ -304,6 +307,9 @@ esp32c3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 ...@@ -304,6 +307,9 @@ esp32c3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
esp32c3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS) esp32c3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS)
esp32c3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB esp32c3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
esp32c3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 esp32c3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
esp32c3.menu.PartitionScheme.rainmaker=RainMaker
esp32c3.menu.PartitionScheme.rainmaker.build.partitions=rainmaker
esp32c3.menu.PartitionScheme.rainmaker.upload.maximum_size=3145728
esp32c3.menu.CPUFreq.160=160MHz (WiFi) esp32c3.menu.CPUFreq.160=160MHz (WiFi)
esp32c3.menu.CPUFreq.160.build.f_cpu=160000000L esp32c3.menu.CPUFreq.160.build.f_cpu=160000000L
...@@ -475,6 +481,9 @@ esp32s2.menu.PartitionScheme.fatflash.upload.maximum_size=2097152 ...@@ -475,6 +481,9 @@ esp32s2.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
esp32s2.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS) esp32s2.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9MB FATFS)
esp32s2.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB esp32s2.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
esp32s2.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 esp32s2.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
esp32s2.menu.PartitionScheme.rainmaker=RainMaker
esp32s2.menu.PartitionScheme.rainmaker.build.partitions=rainmaker
esp32s2.menu.PartitionScheme.rainmaker.upload.maximum_size=3145728
esp32s2.menu.CPUFreq.240=240MHz (WiFi) esp32s2.menu.CPUFreq.240=240MHz (WiFi)
esp32s2.menu.CPUFreq.240.build.f_cpu=240000000L esp32s2.menu.CPUFreq.240.build.f_cpu=240000000L
......
# ESP RainMaker Examples # ESP RainMaker Examples
While building any examples for ESP RainMaker, take care of the following: While building any examples for ESP RainMaker, take care of the following:
1. Change partition scheme in Arduino IDE to RainMaker (Tools -> Partition Scheme -> RainMaker). 1. Change partition scheme in Arduino IDE to RainMaker (Tools -> Partition Scheme -> RainMaker).
2. Once ESP RainMaker gets started, compulsorily call `WiFi.beginProvision()` which is responsible for user-node mapping. 2. Once ESP RainMaker gets started, compulsorily call `WiFi.beginProvision()` which is responsible for user-node mapping.
3. Use appropriate provisioning scheme as per the board. 3. Use the appropriate provisioning scheme as per the board.
- ESP32 Board: BLE Provisioning - ESP32 Board: BLE Provisioning
- ESP32S2 Board: SoftAP Provisioning - ESP32-C3 Board: BLE Provisioning
4. Set debug level to Info (Tools -> Core Debug Level -> Info). This is recommended, but not mandatory. - ESP32-S3 Board: BLE Provisioning
- ESP32-S2 Board: SoftAP Provisioning
4. Set debug level to Info (Tools -> Core Debug Level -> Info). This is recommended debug level but not mandatory to run RainMaker.
...@@ -9,10 +9,15 @@ const char *service_name = "PROV_1234"; ...@@ -9,10 +9,15 @@ const char *service_name = "PROV_1234";
const char *pop = "abcd1234"; const char *pop = "abcd1234";
//GPIO for push button //GPIO for push button
static int gpio_0 = 0; #if CONFIG_IDF_TARGET_ESP32C3
static int gpio_0 = 9;
static int gpio_dimmer = 7;
#else
//GPIO for virtual device //GPIO for virtual device
static int gpio_0 = 0;
static int gpio_dimmer = 16; static int gpio_dimmer = 16;
/* Variable for reading pin status*/ #endif
bool dimmer_state = true; bool dimmer_state = true;
// The framework provides some standard device types like switch, lightbulb, fan, temperature sensor. // The framework provides some standard device types like switch, lightbulb, fan, temperature sensor.
...@@ -23,12 +28,12 @@ void sysProvEvent(arduino_event_t *sys_event) ...@@ -23,12 +28,12 @@ void sysProvEvent(arduino_event_t *sys_event)
{ {
switch (sys_event->event_id) { switch (sys_event->event_id) {
case ARDUINO_EVENT_PROV_START: case ARDUINO_EVENT_PROV_START:
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32S2
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble");
#else
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop); Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop);
printQR(service_name, pop, "softap"); printQR(service_name, pop, "softap");
#else
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble");
#endif #endif
break; break;
} }
...@@ -89,10 +94,10 @@ void setup() ...@@ -89,10 +94,10 @@ void setup()
RMaker.start(); RMaker.start();
WiFi.onEvent(sysProvEvent); WiFi.onEvent(sysProvEvent);
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32S2
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
#else
WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, pop, service_name); WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, pop, service_name);
#else
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
#endif #endif
} }
......
...@@ -8,9 +8,15 @@ const char *service_name = "PROV_1234"; ...@@ -8,9 +8,15 @@ const char *service_name = "PROV_1234";
const char *pop = "abcd1234"; const char *pop = "abcd1234";
//GPIO for push button //GPIO for push button
static int gpio_0 = 0; #if CONFIG_IDF_TARGET_ESP32C3
static int gpio_0 = 9;
static int gpio_switch = 7;
#else
//GPIO for virtual device //GPIO for virtual device
static int gpio_0 = 0;
static int gpio_switch = 16; static int gpio_switch = 16;
#endif
/* Variable for reading pin status*/ /* Variable for reading pin status*/
bool switch_state = true; bool switch_state = true;
...@@ -21,13 +27,13 @@ void sysProvEvent(arduino_event_t *sys_event) ...@@ -21,13 +27,13 @@ void sysProvEvent(arduino_event_t *sys_event)
{ {
switch (sys_event->event_id) { switch (sys_event->event_id) {
case ARDUINO_EVENT_PROV_START: case ARDUINO_EVENT_PROV_START:
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32S2
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble");
#else
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop); Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop);
printQR(service_name, pop, "softap"); printQR(service_name, pop, "softap");
#endif #else
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble");
#endif
break; break;
} }
} }
...@@ -74,10 +80,10 @@ void setup() ...@@ -74,10 +80,10 @@ void setup()
RMaker.start(); RMaker.start();
WiFi.onEvent(sysProvEvent); WiFi.onEvent(sysProvEvent);
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32S2
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
#else
WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, pop, service_name); WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, pop, service_name);
#else
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment