e62ff6dc37
- Use Serial.print instead of log_i for QR code helper information, so that it is always printed by default. - Expose the RainMaker factory reset and wifi reset APIs. - Simplify example to have only a Switch device. Create another example for custom device. - Enable push button based Factory reset and Wi-Fi reset. - Added support for the TimeZone service. - Moved API doc to RainMaker library's top level README. - Other minor doc changes.
25 lines
876 B
C
25 lines
876 B
C
#include "esp_system.h"
|
|
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_IDF_TARGET_ESP32
|
|
|
|
#include <qrcode.h>
|
|
|
|
#define PROV_QR_VERSION "v1"
|
|
#define QRCODE_BASE_URL "https://rainmaker.espressif.com/qrcode.html"
|
|
|
|
static void printQR(const char *name, const char *pop, const char *transport)
|
|
{
|
|
if (!name || !pop || !transport) {
|
|
log_w("Cannot generate QR code payload. Data missing.");
|
|
return;
|
|
}
|
|
char payload[150];
|
|
snprintf(payload, sizeof(payload), "{\"ver\":\"%s\",\"name\":\"%s\"" \
|
|
",\"pop\":\"%s\",\"transport\":\"%s\"}",
|
|
PROV_QR_VERSION, name, pop, transport);
|
|
Serial.printf("Scan this QR code from the ESP RainMaker phone app.\n");
|
|
qrcode_display(payload);
|
|
Serial.printf("If QR code is not visible, copy paste the below URL in a browser.\n%s?data=%s\n", QRCODE_BASE_URL, payload);
|
|
}
|
|
|
|
#endif
|