Unverified Commit 8004a812 authored by Sanket Wadekar's avatar Sanket Wadekar Committed by GitHub

Rainmaker Example Changes (#7591)

* Changed OTA type in Rainmaker examples

* fix: Added patch in Rainmaker examples
to prevent crashes during provisioning
parent c2caad9a
...@@ -29,13 +29,19 @@ void sysProvEvent(arduino_event_t *sys_event) ...@@ -29,13 +29,19 @@ 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_ESP32S2 #if CONFIG_IDF_TARGET_ESP32S2
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 #else
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop); Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble"); printQR(service_name, pop, "ble");
#endif #endif
break; break;
case ARDUINO_EVENT_PROV_INIT:
wifi_prov_mgr_disable_auto_stop(10000);
break;
case ARDUINO_EVENT_PROV_CRED_SUCCESS:
wifi_prov_mgr_stop_provisioning();
break;
default:; default:;
} }
} }
...@@ -83,7 +89,7 @@ void setup() ...@@ -83,7 +89,7 @@ void setup()
my_node.addDevice(my_device); my_node.addDevice(my_device);
//This is optional //This is optional
RMaker.enableOTA(OTA_USING_PARAMS); RMaker.enableOTA(OTA_USING_TOPICS);
//If you want to enable scheduling, set time zone for your region using setTimeZone(). //If you want to enable scheduling, set time zone for your region using setTimeZone().
//The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html //The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html
// RMaker.setTimeZone("Asia/Shanghai"); // RMaker.setTimeZone("Asia/Shanghai");
......
...@@ -46,13 +46,19 @@ void sysProvEvent(arduino_event_t *sys_event) ...@@ -46,13 +46,19 @@ 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_ESP32S2 #if CONFIG_IDF_TARGET_ESP32S2
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 #else
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop); Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble"); printQR(service_name, pop, "ble");
#endif #endif
break; break;
case ARDUINO_EVENT_PROV_INIT:
wifi_prov_mgr_disable_auto_stop(10000);
break;
case ARDUINO_EVENT_PROV_CRED_SUCCESS:
wifi_prov_mgr_stop_provisioning();
break;
default:; default:;
} }
} }
...@@ -143,7 +149,7 @@ void setup() ...@@ -143,7 +149,7 @@ void setup()
my_node.addDevice(my_device); my_node.addDevice(my_device);
//This is optional //This is optional
// RMaker.enableOTA(OTA_USING_PARAMS); // RMaker.enableOTA(OTA_USING_TOPICS);
//If you want to enable scheduling, set time zone for your region using setTimeZone(). //If you want to enable scheduling, set time zone for your region using setTimeZone().
//The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html //The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html
// RMaker.setTimeZone("Asia/Shanghai"); // RMaker.setTimeZone("Asia/Shanghai");
......
...@@ -39,21 +39,29 @@ void sysProvEvent(arduino_event_t *sys_event) ...@@ -39,21 +39,29 @@ 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_ESP32
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop); Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble"); printQR(service_name, pop, "ble");
#else #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 #endif
break; break;
case ARDUINO_EVENT_WIFI_STA_CONNECTED: case ARDUINO_EVENT_WIFI_STA_CONNECTED:
Serial.printf("\nConnected to Wi-Fi!\n"); Serial.printf("\nConnected to Wi-Fi!\n");
digitalWrite(gpio_led, true); digitalWrite(gpio_led, true);
break; break;
case ARDUINO_EVENT_PROV_INIT:
wifi_prov_mgr_disable_auto_stop(10000);
break;
case ARDUINO_EVENT_PROV_CRED_SUCCESS:
wifi_prov_mgr_stop_provisioning();
break;
default:; default:;
} }
} }
void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx) void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx)
{ {
const char *device_name = device->getDeviceName(); const char *device_name = device->getDeviceName();
...@@ -129,7 +137,7 @@ void setup() ...@@ -129,7 +137,7 @@ void setup()
my_node.addDevice(my_switch2); my_node.addDevice(my_switch2);
//This is optional //This is optional
RMaker.enableOTA(OTA_USING_PARAMS); RMaker.enableOTA(OTA_USING_TOPICS);
//If you want to enable scheduling, set time zone for your region using setTimeZone(). //If you want to enable scheduling, set time zone for your region using setTimeZone().
//The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html //The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html
// RMaker.setTimeZone("Asia/Shanghai"); // RMaker.setTimeZone("Asia/Shanghai");
......
...@@ -28,13 +28,19 @@ void sysProvEvent(arduino_event_t *sys_event) ...@@ -28,13 +28,19 @@ 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_ESP32S2 #if CONFIG_IDF_TARGET_ESP32S2
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 #else
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop); Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble"); printQR(service_name, pop, "ble");
#endif #endif
break; break;
case ARDUINO_EVENT_PROV_INIT:
wifi_prov_mgr_disable_auto_stop(10000);
break;
case ARDUINO_EVENT_PROV_CRED_SUCCESS:
wifi_prov_mgr_stop_provisioning();
break;
default:; default:;
} }
} }
...@@ -72,7 +78,7 @@ void setup() ...@@ -72,7 +78,7 @@ void setup()
my_node.addDevice(my_switch); my_node.addDevice(my_switch);
//This is optional //This is optional
RMaker.enableOTA(OTA_USING_PARAMS); RMaker.enableOTA(OTA_USING_TOPICS);
//If you want to enable scheduling, set time zone for your region using setTimeZone(). //If you want to enable scheduling, set time zone for your region using setTimeZone().
//The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html //The list of available values are provided here https://rainmaker.espressif.com/docs/time-service.html
// RMaker.setTimeZone("Asia/Shanghai"); // RMaker.setTimeZone("Asia/Shanghai");
......
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