change structure continued
This commit is contained in:
20
sketch/ConfigDataStructure.py
Normal file
20
sketch/ConfigDataStructure.py
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
configItems = [
|
||||
{"label":"_", "key":"magic", "type":"I", "default": ""},
|
||||
{"label":"Config Username", "key":"confUser", "type":"C", "length":16, "default":"admin"},
|
||||
{"label":"Config Password", "key":"confPasswd", "type":"C", "length":16, "default":"geheim123"},
|
||||
{"label":"Wifi SSID", "key":"wifiSsid", "type":"C", "length":32, "default":"test"},
|
||||
{"label":"Wifi Key", "key":"wifiKey", "type":"C", "length":64, "default":"geheim"},
|
||||
{"label":"MQTT Broker", "key":"mqttBroker", "type":"C", "length":32, "default":"broker.hottis.de"},
|
||||
{"label":"MQTT Username", "key":"mqttUser", "type":"C", "length":32, "default":"RgbLed1"},
|
||||
{"label":"MQTT Password", "key":"mqttPass", "type":"C", "length":32, "default":"geheim123"},
|
||||
{"label":"MQTT ClientId", "key":"mqttClientId", "type":"C", "length":32, "default":"RgbLed1"},
|
||||
{"label":"MQTT Port", "key":"mqttPort", "type":"I", "default":8883},
|
||||
{"label":"MQTT Topic Color Command", "key":"mqttTopicColorCommand", "type":"C", "length":64, "default":"IoT/RgbLed1/ColorCommand"},
|
||||
{"label":"MQTT Topic Command", "key":"mqttTopicCommand", "type":"C", "length":64, "default":"IoT/RgbLed1/Command"},
|
||||
{"label":"MQTT DebugTopic", "key":"mqttDebugTopic", "type":"C", "length":64, "default":"IoT/RgbLed1/Debug"},
|
||||
{"label":"DebugMode", "key":"debugMode", "type":"I", "default":0}
|
||||
]
|
||||
|
||||
magic = 3235774470
|
||||
appName = "ESP8266 based RGB-LED-Light"
|
220
sketch/application.cpp
Normal file
220
sketch/application.cpp
Normal file
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* productionMode.cpp
|
||||
*
|
||||
* Created on: Apr 05, 2019
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <mqttHandling.h>
|
||||
|
||||
|
||||
#ifdef WS2811
|
||||
#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
|
||||
#include <FastLED.h>
|
||||
#endif
|
||||
|
||||
#ifdef PL9823
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
|
||||
#ifdef WS2811
|
||||
CRGB leds[NUM_OF_LEDs];
|
||||
#endif
|
||||
|
||||
#ifdef PL9823
|
||||
typedef struct {
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} CRGB;
|
||||
|
||||
|
||||
Adafruit_NeoPixel pixels(NUM_OF_LEDs, PIXEL_PIN, NEO_RGB + NEO_KHZ400);
|
||||
#endif
|
||||
|
||||
bool show = false;
|
||||
|
||||
|
||||
|
||||
static CRGB evaluationColorWord(char* cmd) {
|
||||
uint8_t red = 0, green = 0, blue = 0;
|
||||
if ((! strcmp(cmd, "on")) || (! strcmp(cmd, "white"))) {
|
||||
red = 255;
|
||||
green = 255;
|
||||
blue = 255;
|
||||
} else if (! strcmp(cmd, "off")) {
|
||||
red = 0;
|
||||
green = 0;
|
||||
blue = 0;
|
||||
} else if (! strcmp(cmd, "warmwhite")) {
|
||||
red = 0;
|
||||
green = 0;
|
||||
blue = 0;
|
||||
} else if (! strcmp(cmd, "red")) {
|
||||
red = 255;
|
||||
green = 0;
|
||||
blue = 0;
|
||||
} else if (! strcmp(cmd, "green")) {
|
||||
red = 0;
|
||||
green = 255;
|
||||
blue = 0;
|
||||
} else if (! strcmp(cmd, "blue")) {
|
||||
red = 0;
|
||||
green = 0;
|
||||
blue = 255;
|
||||
} else if (! strcmp(cmd, "purple")) {
|
||||
red = 255;
|
||||
green = 0;
|
||||
blue = 255;
|
||||
} else if (! strcmp(cmd, "yellow")) {
|
||||
red = 255;
|
||||
green = 255;
|
||||
blue = 0;
|
||||
}
|
||||
|
||||
CRGB res;
|
||||
res.r = red;
|
||||
res.g = green;
|
||||
res.b = blue;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void subscribeApplication() {
|
||||
mqttClient.subscribe(configBlock.mqttTopicColorCommand);
|
||||
mqttClient.subscribe(configBlock.mqttTopicCommand);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void setColor(int8_t ledNumber, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
if (ledNumber == -1) {
|
||||
for (uint8_t i = 0; i < NUM_OF_LEDs; i++) {
|
||||
#ifdef WS2811
|
||||
leds[i].r = red;
|
||||
leds[i].g = green;
|
||||
leds[i].b = blue;
|
||||
#endif
|
||||
#ifdef PL9823
|
||||
pixels.setPixelColor(i, pixels.Color(red, green, blue));
|
||||
#endif
|
||||
}
|
||||
show = true;
|
||||
} else {
|
||||
if (ledNumber >= 0 && ledNumber < NUM_OF_LEDs) {
|
||||
|
||||
#ifdef WS2811
|
||||
leds[ledNumber].r = red;
|
||||
leds[ledNumber].g = green;
|
||||
leds[ledNumber].b = blue;
|
||||
#endif
|
||||
#ifdef PL9823
|
||||
pixels.setPixelColor(ledNumber, pixels.Color(red, green, blue));
|
||||
#endif
|
||||
show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void callbackApplication(char *topic, uint8_t tokenCnt, char **tokens) {
|
||||
if (! strcmp(topic, configBlock.mqttTopicCommand)) {
|
||||
int32_t n, b;
|
||||
CRGB pseudoColors;
|
||||
switch (tokenCnt) {
|
||||
case 1:
|
||||
// set brightness
|
||||
b = strtol(tokens[0], NULL, 10);
|
||||
setColor(-1, b, b, b);
|
||||
break;
|
||||
case 2:
|
||||
// set brightness for one LED
|
||||
n = strtol(tokens[0], NULL, 10);
|
||||
b = strtol(tokens[1], NULL, 10);
|
||||
setColor(n, b, b, b);
|
||||
break;
|
||||
}
|
||||
} else if (! strcmp(topic, configBlock.mqttTopicColorCommand)) {
|
||||
int32_t n, red, green, blue;
|
||||
CRGB colors;
|
||||
switch (tokenCnt) {
|
||||
case 1:
|
||||
// on, off, color word for all LEDs
|
||||
colors = evaluationColorWord(tokens[0]);
|
||||
setColor(-1, colors.r, colors.g, colors.b);
|
||||
break;
|
||||
case 2:
|
||||
// token0 = LED number, token1 = color
|
||||
n = strtol(tokens[0], NULL, 10);
|
||||
colors = evaluationColorWord(tokens[1]);
|
||||
setColor(n, colors.r, colors.g, colors.b);
|
||||
break;
|
||||
case 3:
|
||||
// token0 = red, token1 = green, token2 = blue
|
||||
red = strtol(tokens[0], NULL, 10);
|
||||
green = strtol(tokens[1], NULL, 10);
|
||||
blue = strtol(tokens[2], NULL, 10);
|
||||
setColor(-1, red, green, blue);
|
||||
break;
|
||||
case 4:
|
||||
// token0 = LED number, token1 = red, token2 = green, token3 = blue
|
||||
n = strtol(tokens[0], NULL, 10);
|
||||
red = strtol(tokens[1], NULL, 10);
|
||||
green = strtol(tokens[2], NULL, 10);
|
||||
blue = strtol(tokens[3], NULL, 10);
|
||||
setColor(n, red, green, blue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setupApplication() {
|
||||
mqttSetup();
|
||||
|
||||
#ifdef WS2811
|
||||
FastLED.addLeds<NEOPIXEL, PIXEL_PIN>(leds, NUM_OF_LEDs);
|
||||
#endif
|
||||
#ifdef PL9823
|
||||
pixels.begin();
|
||||
|
||||
for (uint8_t i = 0; i < NUM_OF_LEDs; i++) {
|
||||
pixels.setPixelColor(i, pixels.Color(0,0,0));
|
||||
}
|
||||
pixels.show();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void loopApplication() {
|
||||
mqttLoop();
|
||||
|
||||
|
||||
|
||||
if (show) {
|
||||
show = false;
|
||||
#ifdef WS2811
|
||||
FastLED.show();
|
||||
#endif
|
||||
#ifdef PL9823
|
||||
pixels.show();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
19
sketch/application.h
Normal file
19
sketch/application.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* productionMode.h
|
||||
*
|
||||
* Created on: Apr 5 2019
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef PRODUCTIONMODE_H_
|
||||
#define PRODUCTIONMODE_H_
|
||||
|
||||
|
||||
|
||||
void setupApplication();
|
||||
void loopApplication();
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* PRODUCTIONMODE_H_ */
|
389
sketch/configuration.cpp
Normal file
389
sketch/configuration.cpp
Normal file
@ -0,0 +1,389 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <EEPROM.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "configuration.h"
|
||||
|
||||
|
||||
tConfigBlock configBlock;
|
||||
const uint32_t MAGIC = 3235774470;
|
||||
const char* CONFIG_SSID = "espconfig";
|
||||
extern ESP8266WebServer webServer;
|
||||
|
||||
bool configSaved = false;
|
||||
|
||||
|
||||
static bool checkAuthentication() {
|
||||
Serial.print("User: "); Serial.println(configBlock.confUser);
|
||||
Serial.print("Pass: "); Serial.println(configBlock.confPasswd);
|
||||
return webServer.authenticate(configBlock.confUser, configBlock.confPasswd);
|
||||
}
|
||||
|
||||
void configServeIndex() {
|
||||
bool configValid = (configBlock.magic == MAGIC);
|
||||
|
||||
if (! configValid) {
|
||||
configBlock.magic = MAGIC;
|
||||
strcpy(configBlock.confUser, "admin");
|
||||
strcpy(configBlock.confPasswd, "geheim123");
|
||||
strcpy(configBlock.wifiSsid, "test");
|
||||
strcpy(configBlock.wifiKey, "geheim");
|
||||
strcpy(configBlock.mqttBroker, "broker.hottis.de");
|
||||
strcpy(configBlock.mqttUser, "RgbLed1");
|
||||
strcpy(configBlock.mqttPass, "geheim123");
|
||||
strcpy(configBlock.mqttClientId, "RgbLed1");
|
||||
configBlock.mqttPort = 8883;
|
||||
strcpy(configBlock.mqttTopicColorCommand, "IoT/RgbLed1/ColorCommand");
|
||||
strcpy(configBlock.mqttTopicCommand, "IoT/RgbLed1/Command");
|
||||
strcpy(configBlock.mqttDebugTopic, "IoT/RgbLed1/Debug");
|
||||
configBlock.debugMode = 0;
|
||||
}
|
||||
|
||||
if (! checkAuthentication()) {
|
||||
return webServer.requestAuthentication();
|
||||
}
|
||||
|
||||
|
||||
String buffer =
|
||||
"<!doctype html"
|
||||
"<html lang=\"en\">"
|
||||
" <head>"
|
||||
" <title>ESP8266 based RGB-LED-Light</title>"
|
||||
" </head>"
|
||||
" <body>"
|
||||
" <h1>ESP8266 based RGB-LED-Light - ESP8266 Configuration Page</h1>";
|
||||
|
||||
if (configSaved) {
|
||||
configSaved = false;
|
||||
buffer += "<h2>Configuration saved</h2>";
|
||||
}
|
||||
|
||||
buffer +=
|
||||
" <form action=\"/config\" method=\"GET\">"
|
||||
" <table>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"confUser\">Config Username</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"confUser\" id=\"confUser\" ";
|
||||
|
||||
buffer += " size=\"16\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.confUser;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"confPasswd\">Config Password</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"confPasswd\" id=\"confPasswd\" ";
|
||||
|
||||
buffer += " size=\"16\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.confPasswd;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"wifiSsid\">Wifi SSID</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"wifiSsid\" id=\"wifiSsid\" ";
|
||||
|
||||
buffer += " size=\"32\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.wifiSsid;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"wifiKey\">Wifi Key</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"wifiKey\" id=\"wifiKey\" ";
|
||||
|
||||
buffer += " size=\"64\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.wifiKey;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"mqttBroker\">MQTT Broker</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"mqttBroker\" id=\"mqttBroker\" ";
|
||||
|
||||
buffer += " size=\"32\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.mqttBroker;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"mqttUser\">MQTT Username</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"mqttUser\" id=\"mqttUser\" ";
|
||||
|
||||
buffer += " size=\"32\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.mqttUser;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"mqttPass\">MQTT Password</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"mqttPass\" id=\"mqttPass\" ";
|
||||
|
||||
buffer += " size=\"32\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.mqttPass;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"mqttClientId\">MQTT ClientId</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"mqttClientId\" id=\"mqttClientId\" ";
|
||||
|
||||
buffer += " size=\"32\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.mqttClientId;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"mqttPort\">MQTT Port</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"mqttPort\" id=\"mqttPort\" ";
|
||||
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.mqttPort;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"mqttTopicColorCommand\">MQTT Topic Color Command</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"mqttTopicColorCommand\" id=\"mqttTopicColorCommand\" ";
|
||||
|
||||
buffer += " size=\"64\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.mqttTopicColorCommand;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"mqttTopicCommand\">MQTT Topic Command</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"mqttTopicCommand\" id=\"mqttTopicCommand\" ";
|
||||
|
||||
buffer += " size=\"64\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.mqttTopicCommand;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"mqttDebugTopic\">MQTT DebugTopic</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"mqttDebugTopic\" id=\"mqttDebugTopic\" ";
|
||||
|
||||
buffer += " size=\"64\" ";
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.mqttDebugTopic;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td>"
|
||||
" <label for\"debugMode\">DebugMode</label>"
|
||||
" </td><td>"
|
||||
" <input type=\"text\" name=\"debugMode\" id=\"debugMode\" ";
|
||||
|
||||
buffer += " value=\"";
|
||||
buffer += configBlock.debugMode;
|
||||
buffer += "\"";
|
||||
|
||||
buffer +=
|
||||
" />"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" <tr>"
|
||||
" <td colspan=\"2\">"
|
||||
" <button type=\"submit\">Save</button>"
|
||||
" </td>"
|
||||
" </tr>"
|
||||
" </table>"
|
||||
" </form>"
|
||||
" </body>"
|
||||
"</html>";
|
||||
|
||||
webServer.send(200, "text/html", buffer);
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.println("indexHtml request served");
|
||||
#endif
|
||||
}
|
||||
|
||||
void configServeGetConfiguration() {
|
||||
if (! checkAuthentication()) {
|
||||
return webServer.requestAuthentication();
|
||||
}
|
||||
|
||||
String arg;
|
||||
|
||||
arg = webServer.arg("confUser");
|
||||
strcpy(configBlock.confUser, arg.c_str());
|
||||
arg = webServer.arg("confPasswd");
|
||||
strcpy(configBlock.confPasswd, arg.c_str());
|
||||
arg = webServer.arg("wifiSsid");
|
||||
strcpy(configBlock.wifiSsid, arg.c_str());
|
||||
arg = webServer.arg("wifiKey");
|
||||
strcpy(configBlock.wifiKey, arg.c_str());
|
||||
arg = webServer.arg("mqttBroker");
|
||||
strcpy(configBlock.mqttBroker, arg.c_str());
|
||||
arg = webServer.arg("mqttUser");
|
||||
strcpy(configBlock.mqttUser, arg.c_str());
|
||||
arg = webServer.arg("mqttPass");
|
||||
strcpy(configBlock.mqttPass, arg.c_str());
|
||||
arg = webServer.arg("mqttClientId");
|
||||
strcpy(configBlock.mqttClientId, arg.c_str());
|
||||
arg = webServer.arg("mqttPort");
|
||||
configBlock.mqttPort = atoi(arg.c_str());
|
||||
arg = webServer.arg("mqttTopicColorCommand");
|
||||
strcpy(configBlock.mqttTopicColorCommand, arg.c_str());
|
||||
arg = webServer.arg("mqttTopicCommand");
|
||||
strcpy(configBlock.mqttTopicCommand, arg.c_str());
|
||||
arg = webServer.arg("mqttDebugTopic");
|
||||
strcpy(configBlock.mqttDebugTopic, arg.c_str());
|
||||
arg = webServer.arg("debugMode");
|
||||
configBlock.debugMode = atoi(arg.c_str());
|
||||
|
||||
configBlock.magic = MAGIC;
|
||||
|
||||
showConfiguration();
|
||||
|
||||
EEPROM.begin(512);
|
||||
EEPROM.put(EEPROM_ADDR, configBlock);
|
||||
EEPROM.commit();
|
||||
|
||||
Serial.println("EEPROM saved");
|
||||
|
||||
configSaved = true;
|
||||
webServer.sendHeader("Location", String("/"), true);
|
||||
webServer.send(302, "text/plain", "");
|
||||
//webServer.send(200, "text/html", "configuration saved");
|
||||
}
|
||||
|
||||
void showConfiguration() {
|
||||
Serial.println("Configuration is");
|
||||
|
||||
Serial.print("magic = <");
|
||||
Serial.print(configBlock.magic);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("confUser = <");
|
||||
Serial.print(configBlock.confUser);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("confPasswd = <");
|
||||
Serial.print(configBlock.confPasswd);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("wifiSsid = <");
|
||||
Serial.print(configBlock.wifiSsid);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("wifiKey = <");
|
||||
Serial.print(configBlock.wifiKey);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttBroker = <");
|
||||
Serial.print(configBlock.mqttBroker);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttUser = <");
|
||||
Serial.print(configBlock.mqttUser);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttPass = <");
|
||||
Serial.print(configBlock.mqttPass);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttClientId = <");
|
||||
Serial.print(configBlock.mqttClientId);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttPort = <");
|
||||
Serial.print(configBlock.mqttPort);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttTopicColorCommand = <");
|
||||
Serial.print(configBlock.mqttTopicColorCommand);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttTopicCommand = <");
|
||||
Serial.print(configBlock.mqttTopicCommand);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttDebugTopic = <");
|
||||
Serial.print(configBlock.mqttDebugTopic);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("debugMode = <");
|
||||
Serial.print(configBlock.debugMode);
|
||||
Serial.println(">");
|
||||
|
||||
|
||||
Serial.println("---");
|
||||
}
|
24
sketch/configuration.h
Normal file
24
sketch/configuration.h
Normal file
@ -0,0 +1,24 @@
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
char confUser[16];
|
||||
char confPasswd[16];
|
||||
char wifiSsid[32];
|
||||
char wifiKey[64];
|
||||
char mqttBroker[32];
|
||||
char mqttUser[32];
|
||||
char mqttPass[32];
|
||||
char mqttClientId[32];
|
||||
uint32_t mqttPort;
|
||||
char mqttTopicColorCommand[64];
|
||||
char mqttTopicCommand[64];
|
||||
char mqttDebugTopic[64];
|
||||
uint32_t debugMode;
|
||||
} tConfigBlock;
|
||||
|
||||
extern const uint32_t MAGIC;
|
||||
extern tConfigBlock configBlock;
|
||||
extern const char* CONFIG_SSID;
|
||||
|
||||
void configServeIndex();
|
||||
void configServeGetConfiguration();
|
||||
void showConfiguration();
|
22
sketch/rgbled.h
Normal file
22
sketch/rgbled.h
Normal file
@ -0,0 +1,22 @@
|
||||
// Only modify this file to include
|
||||
// - function definitions (prototypes)
|
||||
// - include files
|
||||
// - extern variable definitions
|
||||
// In the appropriate section
|
||||
|
||||
#ifndef _rgbled_H_
|
||||
#define _rgbled_H_
|
||||
#include "Arduino.h"
|
||||
//add your includes for the project rgbled here
|
||||
|
||||
|
||||
//end of add your includes here
|
||||
|
||||
|
||||
//add your function definitions for the project rgbled here
|
||||
|
||||
|
||||
|
||||
|
||||
//Do not add code below this line
|
||||
#endif /* _rgbled_H_ */
|
18
sketch/sketch.ino
Normal file
18
sketch/sketch.ino
Normal file
@ -0,0 +1,18 @@
|
||||
// Do not remove the include below
|
||||
#include "rgbled.h"
|
||||
|
||||
#include <main.h>
|
||||
|
||||
//The setup function is called once at startup of the sketch
|
||||
void setup()
|
||||
{
|
||||
// Add your initialization code here
|
||||
mainSetup();
|
||||
}
|
||||
|
||||
// The loop function is called in an endless loop
|
||||
void loop()
|
||||
{
|
||||
//Add your repeated code here
|
||||
mainLoop();
|
||||
}
|
BIN
sketch/snippet/snippet1
Executable file
BIN
sketch/snippet/snippet1
Executable file
Binary file not shown.
12
sketch/snippet/snippet1.c
Normal file
12
sketch/snippet/snippet1.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
char text1[15] = "Wolfgang/11";
|
||||
char text2[15] = "Wolfgang";
|
||||
|
||||
if (0 == strncmp(text1, text2, strlen(text2))) {
|
||||
printf("match\n");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user