Update ESP32 and Arduino examples

This commit is contained in:
Daniele Viganò 2023-09-09 13:06:13 +02:00
parent 5ec9fb7a86
commit af832c44d1
2 changed files with 8 additions and 8 deletions

View File

@ -55,7 +55,7 @@ struct netConfig {
} config;
char serial[9];
const String apiURL = "/api/device/subscribe/";
const String dpsURL = "/dps/device/subscribe/";
const String telemetryURL = "/telemetry/";
void setup(void) {
@ -63,7 +63,7 @@ void setup(void) {
analogReference(EXTERNAL);
StaticJsonDocument<20> api;
StaticJsonDocument<20> dps;
byte mac[6];
int eeAddress = 0;
@ -110,8 +110,8 @@ void setup(void) {
Serial.println("DEBUG: clock updated via NTP.");
#endif
api["serial"] = serial;
postData(config, apiURL, api);
dps["serial"] = serial;
postData(config, dpsURL, dps);
telemetry["device"] = serial;
// payload["id"] = serverName;

View File

@ -55,13 +55,13 @@ struct netConfig {
} config;
char* serial;
const String apiURL = "/api/device/subscribe/";
const String dpsURL = "/dps/device/subscribe/";
const String telemetryURL = "/telemetry/";
void setup(void) {
Serial.begin(115200);
StaticJsonDocument<64> api;
StaticJsonDocument<64> dps;
preferences.begin("iot");
// Get the serial number from flash
@ -117,8 +117,8 @@ void setup(void) {
Serial.println("DEBUG: clock updated via NTP.");
#endif
api["serial"] = serial;
postData(config, apiURL, api);
dps["serial"] = serial;
postData(config, dpsURL, dps);
telemetry["device"] = serial;
// payload["id"] = serverName;