forked from espressif/arduino-esp32
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
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
# ESP RainMaker Examples
|
||||
|
||||
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).
|
||||
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
|
||||
- ESP32S2 Board: SoftAP Provisioning
|
||||
4. Set debug level to Info (Tools -> Core Debug Level -> Info). This is recommended, but not mandatory.
|
||||
- ESP32-C3 Board: BLE Provisioning
|
||||
- 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";
|
||||
const char *pop = "abcd1234";
|
||||
|
||||
//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
|
||||
static int gpio_0 = 0;
|
||||
static int gpio_dimmer = 16;
|
||||
/* Variable for reading pin status*/
|
||||
#endif
|
||||
|
||||
bool dimmer_state = true;
|
||||
|
||||
// The framework provides some standard device types like switch, lightbulb, fan, temperature sensor.
|
||||
@ -23,12 +28,12 @@ void sysProvEvent(arduino_event_t *sys_event)
|
||||
{
|
||||
switch (sys_event->event_id) {
|
||||
case ARDUINO_EVENT_PROV_START:
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
|
||||
printQR(service_name, pop, "ble");
|
||||
#else
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop);
|
||||
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
|
||||
break;
|
||||
}
|
||||
@ -89,10 +94,10 @@ void setup()
|
||||
RMaker.start();
|
||||
|
||||
WiFi.onEvent(sysProvEvent);
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
|
||||
#else
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,15 @@ const char *service_name = "PROV_1234";
|
||||
const char *pop = "abcd1234";
|
||||
|
||||
//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
|
||||
static int gpio_0 = 0;
|
||||
static int gpio_switch = 16;
|
||||
#endif
|
||||
|
||||
/* Variable for reading pin status*/
|
||||
bool switch_state = true;
|
||||
|
||||
@ -21,13 +27,13 @@ void sysProvEvent(arduino_event_t *sys_event)
|
||||
{
|
||||
switch (sys_event->event_id) {
|
||||
case ARDUINO_EVENT_PROV_START:
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
|
||||
printQR(service_name, pop, "ble");
|
||||
#else
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -74,10 +80,10 @@ void setup()
|
||||
RMaker.start();
|
||||
|
||||
WiFi.onEvent(sysProvEvent);
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
|
||||
#else
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user