diff --git a/README.md b/README.md index 8382513..6bbbedc 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,11 @@ Ein flexibles Framework für Modelleisenbahnen-Decoder, auf Basis eines ESP8266. Der Funktionsumfang lässt sich leicht durch weitere Klassen erweitern. -Weitere Informationen befinden sich im [Wiki](https://github.com/littleyoda/littleyoda-DCC-Decoder/wiki) +Weitere Informationen befinden sich im [Dokumentation](https://littleyoda.github.io/littleyoda-DCC-Decoder-DOC/) ## Status - * in Entwicklung, wird von mehreren Dekodern genutzt + * wird von mehreren Personen produktiv genutzt für verschiedene Arten von + Dekodern Die folgenden Dekoder nutzen diese Software: * [Weichendekoder](http://spurg.open4me.de/wordpress/784/Weichendecoder) diff --git a/decoder/ActionDCCGeneration.cpp b/decoder/ActionDCCGeneration.cpp index 31d109e..2348b38 100644 --- a/decoder/ActionDCCGeneration.cpp +++ b/decoder/ActionDCCGeneration.cpp @@ -4,6 +4,8 @@ * Based on the work of Juian Zimmermann * http://www.spassbahn.de/forum/index.php?thread/11462-spa%C3%9Flan-topfschlagen-im-minenfeld/&postID=119804&highlight=julian%2Bdcc#post119804 */ +#ifdef ESP8266 + #include #include "Consts.h" #include "ActionDCCGeneration.h" @@ -18,18 +20,18 @@ ActionDCCGeneration::ActionDCCGeneration(Pin* gpio, int locoaddr, int dccoutput) LOCO_ADR = locoaddr; enableGpio = gpio; Logger::getInstance()->addToLog("Starting DCC Generator"); - Logger::getInstance()->addToLog("DCC-Output:" + GPIO.gpio2string(SPI.getUsedPin()) + Logger::getInstance()->addToLog("DCC-Output:" + GPIOobj.gpio2string(SPI.getUsedPin()) + " Enabled: " + enableGpio->toString() + " Loko-Adresse: " + String(LOCO_ADR) + " genutzte DCC Adresse: " + String(DCC_ADRESSE) ); - SPISettings spi = SPISettings(17241, LSBFIRST, SPI_MODE3, false) ; + SPISettings spi = SPISettings(17241, LSBFIRST, my_SPI_MODE3, false) ; SPI.begin(spi, "DCC"); SPI.beginTransaction(spi); if (enableGpio->getPin() != Consts::DISABLE) { - GPIO.pinMode(enableGpio, OUTPUT, "DCC Generation"); - GPIO.digitalWrite(enableGpio, 0); + GPIOobj.pinMode(enableGpio, OUTPUT, "DCC Generation"); + GPIOobj.digitalWrite(enableGpio, 0); } else { // Keine Enable-Pin => also immer aktiv trackenabled = true; @@ -87,10 +89,10 @@ void ActionDCCGeneration::DCCSpeed(int id, int speed, int direction, int SpeedSt Serial.println("Emergency? " + String(speed == Consts::SPEED_EMERGENCY)); if (speed == Consts::SPEED_EMERGENCY) { trackenabled = false; - GPIO.digitalWrite(enableGpio, 0); // disable Track + GPIOobj.digitalWrite(enableGpio, 0); // disable Track } else { trackenabled = true; - GPIO.digitalWrite(enableGpio, 1); // Enable Track + GPIOobj.digitalWrite(enableGpio, 1); // Enable Track } } else { trackenabled = true; // Always tre @@ -295,3 +297,5 @@ void ActionDCCGeneration::send() { SPI.send(SPIBuf, SPIBufUsed); SPIBufUsed = 0; } + +#endif diff --git a/decoder/ActionDCCGeneration.h b/decoder/ActionDCCGeneration.h index df52158..14225b7 100644 --- a/decoder/ActionDCCGeneration.h +++ b/decoder/ActionDCCGeneration.h @@ -8,6 +8,7 @@ #ifndef ACTIONDCCGENERATION_H_ #define ACTIONDCCGENERATION_H_ +#ifdef ESP8266 #include "INotify.h" #include "ILoop.h" @@ -61,4 +62,6 @@ class ActionDCCGeneration: public INotify, public ILoop { requestInfo* r; }; +#endif + #endif /* ACTIONDCCGENERATION_H_ */ diff --git a/decoder/ActionDFPlayerMP3.cpp b/decoder/ActionDFPlayerMP3.cpp index 7d61fb2..b876486 100644 --- a/decoder/ActionDFPlayerMP3.cpp +++ b/decoder/ActionDFPlayerMP3.cpp @@ -4,6 +4,7 @@ * Created on: 21.08.2016 * Author: sven */ +#ifdef ESP8266 #include "ActionDFPlayerMP3.h" #include @@ -176,3 +177,4 @@ void ActionDFPlayerMP3::checkReceiveBuffer() { Serial.println("Finish playing! " + String(ansbuf[4] << 16 | ansbuf[5] << 8 | ansbuf[6])); } } +#endif diff --git a/decoder/ActionDFPlayerMP3.h b/decoder/ActionDFPlayerMP3.h index 6d0db3c..bff9c00 100644 --- a/decoder/ActionDFPlayerMP3.h +++ b/decoder/ActionDFPlayerMP3.h @@ -8,6 +8,8 @@ #ifndef ACTIONDFPLAYERMP3_H_ #define ACTIONDFPLAYERMP3_H_ +#ifdef ESP8266 + #include #include "INotify.h" @@ -40,4 +42,6 @@ class ActionDFPlayerMP3: public INotify { }; ; +#endif + #endif /* ACTIONDFPLAYERMP3_H_ */ diff --git a/decoder/ActionLed.cpp b/decoder/ActionLed.cpp index 11d5129..0547912 100644 --- a/decoder/ActionLed.cpp +++ b/decoder/ActionLed.cpp @@ -14,7 +14,7 @@ ActionLed::ActionLed(Pin* g) { gpio = g; Logger::getInstance()->addToLog("Starting LED " + g->toString()); - GPIO.pinMode(gpio, OUTPUT, "LED"); + GPIOobj.pinMode(gpio, OUTPUT, "LED"); } ActionLed::~ActionLed() { @@ -51,10 +51,10 @@ void ActionLed::setSettings(int status) { } Logger::getInstance()->addToLog("Led " + gpio->toString() + " changed to " + String(status)); if (status == 0) { - GPIO.digitalWrite(gpio, 0); + GPIOobj.digitalWrite(gpio, 0); currentStatus = 0; } else if (status == 1) { - GPIO.digitalWrite(gpio, 1); + GPIOobj.digitalWrite(gpio, 1); currentStatus = 1; } } diff --git a/decoder/ActionPWMOutput.cpp b/decoder/ActionPWMOutput.cpp index 93d2644..ee0c6bd 100644 --- a/decoder/ActionPWMOutput.cpp +++ b/decoder/ActionPWMOutput.cpp @@ -14,21 +14,21 @@ ActionPWMOutput::ActionPWMOutput(uint8_t pwm, uint8_t forward, uint8_t reverse) { Logger::getInstance()->addToLog("Starting PWM..."); Logger::getInstance()->addToLog("PWM-Pin: " - + GPIO.gpio2string(pwm) + " Forward-Pin: " - + GPIO.gpio2string(forward) + " Reverse-Pin: " - + GPIO.gpio2string(reverse) + + GPIOobj.gpio2string(pwm) + " Forward-Pin: " + + GPIOobj.gpio2string(forward) + " Reverse-Pin: " + + GPIOobj.gpio2string(reverse) ); - GPIO.analogWriteFreq(100); + GPIOobj.analogWriteFreq(100); gpioPWM = pwm; gpioForward = forward; gpioReverse = reverse; String fctname = " PWM Signal"; if (gpioPWM != Consts::DISABLE) { - GPIO.pinMode(gpioPWM, OUTPUT, "PWM: PWM Signal"); GPIO.digitalWrite(gpioPWM, LOW); // PWM Signal + GPIOobj.pinMode(gpioPWM, OUTPUT, "PWM: PWM Signal"); GPIOobj.digitalWrite(gpioPWM, LOW); // PWM Signal fctname = ""; } - GPIO.pinMode(gpioForward, OUTPUT, "PWM: Forward" + fctname); GPIO.digitalWrite(gpioForward, LOW); // Forward - GPIO.pinMode(gpioReverse, OUTPUT, "PWM: Reverse" + fctname); GPIO.digitalWrite(gpioReverse, LOW); // Reverse + GPIOobj.pinMode(gpioForward, OUTPUT, "PWM: Forward" + fctname); GPIOobj.digitalWrite(gpioForward, LOW); // Forward + GPIOobj.pinMode(gpioReverse, OUTPUT, "PWM: Reverse" + fctname); GPIOobj.digitalWrite(gpioReverse, LOW); // Reverse setDirection(1); } @@ -76,7 +76,7 @@ void ActionPWMOutput::setSettings(String key, String value) { setSpeedInProcent(s); } else if (key.equals("freq")) { Serial.println("Freq"); - GPIO.analogWriteFreq(value.toInt()); + GPIOobj.analogWriteFreq(value.toInt()); } } @@ -86,17 +86,17 @@ void ActionPWMOutput::setDirection(int dir) { return; } if (dir == 1) { - GPIO.digitalWrite(gpioForward, HIGH); - GPIO.digitalWrite(gpioReverse, LOW); + GPIOobj.digitalWrite(gpioForward, HIGH); + GPIOobj.digitalWrite(gpioReverse, LOW); direction = 1; } else if (dir == -1) { - GPIO.digitalWrite(gpioForward, LOW); - GPIO.digitalWrite(gpioReverse, HIGH); + GPIOobj.digitalWrite(gpioForward, LOW); + GPIOobj.digitalWrite(gpioReverse, HIGH); direction = -1; } else { Serial.println("Error: Direction " + String(dir)); - GPIO.digitalWrite(gpioForward, LOW); - GPIO.digitalWrite(gpioReverse, LOW); + GPIOobj.digitalWrite(gpioForward, LOW); + GPIOobj.digitalWrite(gpioReverse, LOW); direction = 0; } } @@ -117,23 +117,23 @@ void ActionPWMOutput::setSpeedInProcent(int speedProc) { handleSpeedandDirectionWithoutPWMPin(direction, speedProc); return; } - GPIO.analogWrite(gpioPWM, speedProc); + GPIOobj.analogWrite(gpioPWM, speedProc); } void ActionPWMOutput::handleSpeedandDirectionWithoutPWMPin(int dir, int speed) { currentSpeed = speed; if (dir == 1) { - GPIO.analogWrite(gpioForward, currentSpeed); - GPIO.analogWrite(gpioReverse, 0); + GPIOobj.analogWrite(gpioForward, currentSpeed); + GPIOobj.analogWrite(gpioReverse, 0); direction = 1; } else if (dir == -1) { - GPIO.analogWrite(gpioForward, 0); - GPIO.analogWrite(gpioReverse, currentSpeed); + GPIOobj.analogWrite(gpioForward, 0); + GPIOobj.analogWrite(gpioReverse, currentSpeed); direction = -1; } else { Serial.println("Error: Direction " + String(dir)); - GPIO.digitalWrite(gpioForward, LOW); - GPIO.digitalWrite(gpioReverse, LOW); + GPIOobj.digitalWrite(gpioForward, LOW); + GPIOobj.digitalWrite(gpioReverse, LOW); direction = 0; } } diff --git a/decoder/ActionPWMOutput.h b/decoder/ActionPWMOutput.h index 1c76d58..4a39119 100644 --- a/decoder/ActionPWMOutput.h +++ b/decoder/ActionPWMOutput.h @@ -12,6 +12,13 @@ #include "ISettings.h" +#ifndef ESP8266 + +// HACK +#define PWMRANGE 1024 + +#endif + class ActionPWMOutput: public ISettings { public: ActionPWMOutput(uint8_t pwm, uint8_t forward, uint8_t reverse); diff --git a/decoder/ActionSUSIGeneration.cpp b/decoder/ActionSUSIGeneration.cpp index 00712c7..a76f5aa 100644 --- a/decoder/ActionSUSIGeneration.cpp +++ b/decoder/ActionSUSIGeneration.cpp @@ -9,6 +9,8 @@ * falsch! * */ +#ifdef ESP8266 + #include #include "Consts.h" #include "ActionSUSIGeneration.h" @@ -20,12 +22,12 @@ ActionSUSIGeneration::ActionSUSIGeneration(int locoaddr) { LOCO_ADR = locoaddr; Logger::getInstance()->addToLog("Starting Susi Generator"); - Logger::getInstance()->addToLog("SUSI-Output:" + GPIO.gpio2string(SPI.getUsedPin()) + Logger::getInstance()->addToLog("SUSI-Output:" + GPIOobj.gpio2string(SPI.getUsedPin()) + " Loko-Adresse: " + String(LOCO_ADR) ); // TODO Negieren oder nicht negieren - SPISettings spiS = SPISettings(17241, LSBFIRST, SPI_MODE3, true); + SPISettings spiS = SPISettings(17241, LSBFIRST, my_SPI_MODE3, true); SPI.begin(spiS, "SUSI"); SPI.beginTransaction(spiS); @@ -120,3 +122,4 @@ void ActionSUSIGeneration::send() { SPI.send(SPIBuf, SPIBufUsed); SPIBufUsed = 0; } +#endif diff --git a/decoder/ActionSUSIGeneration.h b/decoder/ActionSUSIGeneration.h index 9dbff59..b2f308b 100644 --- a/decoder/ActionSUSIGeneration.h +++ b/decoder/ActionSUSIGeneration.h @@ -7,6 +7,7 @@ #ifndef ACTIONSUSIGENERATION_H_ #define ACTIONSUSIGENERATION_H_ +#ifdef ESP8266 #include "INotify.h" @@ -34,5 +35,5 @@ class ActionSUSIGeneration: public INotify, public ILoop { uint8_t SPEED_STATE = 0; }; - +#endif #endif /* ACTIONSUSIGENERATION_H_ */ diff --git a/decoder/ActionSendTurnoutCommand.h b/decoder/ActionSendTurnoutCommand.h index 4fccb7f..a19249f 100644 --- a/decoder/ActionSendTurnoutCommand.h +++ b/decoder/ActionSendTurnoutCommand.h @@ -20,8 +20,8 @@ class ActionSendTurnoutCommand : public ISettings, public INotify { virtual void TurnoutCmd(int id, int direction, int source); private: Controller* controller; - sint16 id; - uint8 richtung; + int16_t id; + uint8_t richtung; }; #endif /* ACTIONSENDTURNOUTCOMMAND_H_ */ diff --git a/decoder/ActionServo.cpp b/decoder/ActionServo.cpp index 2de18db..c0bebb6 100644 --- a/decoder/ActionServo.cpp +++ b/decoder/ActionServo.cpp @@ -9,10 +9,12 @@ #include "Logger.h" #include "GPIO.h" +#ifdef ESP8266 + ActionServo::ActionServo(int pin) { Logger::getInstance()->addToLog( "Starting Servo GPIO: " + String(pin)); - GPIO.pinMode(pin, OUTPUT, "Servo"); + GPIOobj.pinMode(pin, OUTPUT, "Servo"); this->pin = pin; } @@ -89,3 +91,4 @@ void ActionServo::detach() { isAttach = false; } +#endif diff --git a/decoder/ActionServo.h b/decoder/ActionServo.h index 8a5829b..3be06dc 100644 --- a/decoder/ActionServo.h +++ b/decoder/ActionServo.h @@ -8,6 +8,8 @@ #ifndef ACTIONSERVO_H_ #define ACTIONSERVO_H_ +#ifdef ESP8266 + #include #include "INotify.h" @@ -33,4 +35,5 @@ class ActionServo: public ILoop, public ISettings { }; +#endif #endif /* ACTIONSERVO_H_ */ diff --git a/decoder/ActionStepperOutput.cpp b/decoder/ActionStepperOutput.cpp index d35f8c4..6389baf 100644 --- a/decoder/ActionStepperOutput.cpp +++ b/decoder/ActionStepperOutput.cpp @@ -14,7 +14,7 @@ ActionStepperOutput::ActionStepperOutput(Pin* p1, Pin* p2, Pin* p3, Pin* p4) { pins[2] = p3; pins[3] = p4; for (int i = 0; i < 4; i++) { - GPIO.pinMode(pins[i], OUTPUT, "Stepper"); + GPIOobj.pinMode(pins[i], OUTPUT, "Stepper"); } } @@ -25,7 +25,7 @@ ActionStepperOutput::~ActionStepperOutput() { int ActionStepperOutput::loop() { if (current == target) { for (int i = 0; i < 4; i++) { - GPIO.digitalWrite(pins[i], 0); + GPIOobj.digitalWrite(pins[i], 0); } return 50; } @@ -43,7 +43,7 @@ int ActionStepperOutput::loop() { } } for (int i = 0; i < 4; i++) { - GPIO.digitalWrite(pins[i], steps[state][i]); + GPIOobj.digitalWrite(pins[i], steps[state][i]); } return 1; } diff --git a/decoder/ActionTurnOut.cpp b/decoder/ActionTurnOut.cpp index 35f45f4..63582a7 100644 --- a/decoder/ActionTurnOut.cpp +++ b/decoder/ActionTurnOut.cpp @@ -17,10 +17,10 @@ ActionTurnOut::ActionTurnOut(int dir1, int dir2, int enable) { this->enable = enable; int i; for (i = 0; i < 2; i++) { - GPIO.pinMode(dirPin[i], OUTPUT, "Weiche Richtung " + String(0)); - GPIO.digitalWrite(dirPin[i], 0); + GPIOobj.pinMode(dirPin[i], OUTPUT, "Weiche Richtung " + String(0)); + GPIOobj.digitalWrite(dirPin[i], 0); } - GPIO.pinMode(enable, OUTPUT, "Weiche Enable"); + GPIOobj.pinMode(enable, OUTPUT, "Weiche Enable"); off(); } @@ -47,9 +47,9 @@ String ActionTurnOut::getHTMLController(String urlprefix) { } void ActionTurnOut::off() { - GPIO.digitalWrite(enable, 0); + GPIOobj.digitalWrite(enable, 0); for (int i = 0; i < 2; i++) { - GPIO.digitalWrite(dirPin[i], 0); + GPIOobj.digitalWrite(dirPin[i], 0); } } @@ -64,13 +64,13 @@ ActionTurnOut::~ActionTurnOut() { void ActionTurnOut::setSettings(String key, String value) { int status = value.toInt(); if (status == 1) { - GPIO.digitalWrite(dirPin[0], 0); - GPIO.digitalWrite(dirPin[1], 1); + GPIOobj.digitalWrite(dirPin[0], 0); + GPIOobj.digitalWrite(dirPin[1], 1); } else { - GPIO.digitalWrite(dirPin[0], 1); - GPIO.digitalWrite(dirPin[1], 0); + GPIOobj.digitalWrite(dirPin[0], 1); + GPIOobj.digitalWrite(dirPin[1], 0); } - GPIO.digitalWrite(enable, 1); + GPIOobj.digitalWrite(enable, 1); delay(200); off(); } diff --git a/decoder/CmdReceiverRocnetOverMQTT.cpp b/decoder/CmdReceiverRocnetOverMQTT.cpp index 40b701d..1d0b92f 100644 --- a/decoder/CmdReceiverRocnetOverMQTT.cpp +++ b/decoder/CmdReceiverRocnetOverMQTT.cpp @@ -86,7 +86,13 @@ int CmdReceiverRocnetOverMQTT::loop() { } } Udp.beginPacket("224.0.0.1", 8051); - Udp.write("BROKER-GET"); + #ifdef ESP8266 + Udp.write("BROKER-GET"); + #elif ESP32 + Udp.write((const uint8_t *) "BROKER-GET", 10); + #else + #error "This Arch is not supported" + #endif Udp.endPacket(); return 200; } diff --git a/decoder/CmdReceiverRocnetOverMQTT.h b/decoder/CmdReceiverRocnetOverMQTT.h index 54d933b..ab422d0 100644 --- a/decoder/CmdReceiverRocnetOverMQTT.h +++ b/decoder/CmdReceiverRocnetOverMQTT.h @@ -5,7 +5,15 @@ * Author: sven */ -#include + +#ifdef ESP8266 + #include +#elif ESP32 + #include +#else + #error "This Arch is not supported" +#endif + #include #include "PubSubClient.h" #include "CmdReceiverBase.h" diff --git a/decoder/CmdZentraleZ21.cpp b/decoder/CmdZentraleZ21.cpp index 0093777..1a18a12 100644 --- a/decoder/CmdZentraleZ21.cpp +++ b/decoder/CmdZentraleZ21.cpp @@ -461,7 +461,12 @@ void CmdZentraleZ21::printPacketBuffer(int size) { Serial.print(" ["); Serial.print(udp->remoteIP()); Serial.print(" => "); +#ifdef defined(udp->destinationIP()) Serial.print(udp->destinationIP()); +#else + Serial.print("???.???.???.??? "); +#endif + Serial.println("]"); } diff --git a/decoder/Config.cpp b/decoder/Config.cpp index ff19d2e..cc94540 100644 --- a/decoder/Config.cpp +++ b/decoder/Config.cpp @@ -43,7 +43,10 @@ #include "ISettings.h" - +#ifdef ESP32 + #include "FS.h" + #include "SPIFFS.h" +#endif Config::Config() { @@ -96,6 +99,8 @@ void Config::parseOut(Controller* controller, Webserver* web, String n) { } String m = parser->getValueByKey(idx, "m"); Serial.println("MEM " + String(ESP.getFreeHeap()) + " " + m); + #ifdef ESP8266 + if (m.equals("dccout")) { Pin* gpioenable = new Pin(parser->getValueByKey(idx, "enable")); int locoaddr = parser->getValueByKey(idx, "addr").toInt(); @@ -116,6 +121,8 @@ void Config::parseOut(Controller* controller, Webserver* web, String n) { continue; } + #endif + String id = parser->getValueByKey(idx, "id"); if (id.length() == 0) { Logger::getInstance()->addToLog("ID is null"); @@ -129,26 +136,29 @@ void Config::parseOut(Controller* controller, Webserver* web, String n) { controller->registerSettings(l); } else if (m.equals("pwm")) { - int gpiopwm = GPIO.string2gpio(parser->getValueByKey(idx, "pwm")); - int gpiof = GPIO.string2gpio(parser->getValueByKey(idx, "forward")); - int gpior = GPIO.string2gpio(parser->getValueByKey(idx, "reverse")); + int gpiopwm = GPIOobj.string2gpio(parser->getValueByKey(idx, "pwm")); + int gpiof = GPIOobj.string2gpio(parser->getValueByKey(idx, "forward")); + int gpior = GPIOobj.string2gpio(parser->getValueByKey(idx, "reverse")); ISettings* a = new ActionPWMOutput(gpiopwm, gpiof, gpior); a->setName(id); controller->registerSettings(a); } else if (m.equals("servo")) { - int gpioservo = GPIO.string2gpio(parser->getValueByKey(idx, "gpio")); + #ifdef ESP8266 + + int gpioservo = GPIOobj.string2gpio(parser->getValueByKey(idx, "gpio")); ActionServo* a = new ActionServo(gpioservo); a->setName(id); controller->registerSettings(a); controller->registerLoop(a); + #endif } else if (m.equals("turnout")) { ActionTurnOut* a = new ActionTurnOut( - GPIO.string2gpio(parser->getValueByKey(idx, "dir1")), - GPIO.string2gpio(parser->getValueByKey(idx, "dir2")), - GPIO.string2gpio(parser->getValueByKey(idx, "enable"))); + GPIOobj.string2gpio(parser->getValueByKey(idx, "dir1")), + GPIOobj.string2gpio(parser->getValueByKey(idx, "dir2")), + GPIOobj.string2gpio(parser->getValueByKey(idx, "enable"))); a->setName(id); controller->registerSettings(a); controller->registerLoop(a); @@ -207,7 +217,7 @@ void Config::parseCfg(Controller* controller, Webserver* web, String n) { } else if (m.equals("dcc")) { - int gpio = GPIO.string2gpio(parser->getValueByKey(idx, "gpio")); + int gpio = GPIOobj.string2gpio(parser->getValueByKey(idx, "gpio")); controller->registerCmdReceiver(new CmdReceiverDCC(controller, gpio, gpio)); @@ -239,8 +249,8 @@ void Config::parseCfg(Controller* controller, Webserver* web, String n) { } else if (m.equals("mp3")) { // int addr = value["addr").toInt(); - // int tx = GPIO.string2gpio(value["tx"].as()); - // int rx = GPIO.string2gpio(value["rx"].as()); + // int tx = GPIOobj.string2gpio(value["tx"].as()); + // int rx = GPIOobj.string2gpio(value["rx"].as()); // controller->registerNotify(new ActionDFPlayerMP3(addr, tx, rx)); } else if (m.equals("wlan")) { @@ -293,8 +303,8 @@ void Config::parseCfg(Controller* controller, Webserver* web, String n) { } else if (m.equals("i2c")) { - int sda = GPIO.string2gpio(parser->getValueByKey(idx, "sda")); - int scl = GPIO.string2gpio(parser->getValueByKey(idx, "scl")); + int sda = GPIOobj.string2gpio(parser->getValueByKey(idx, "sda")); + int scl = GPIOobj.string2gpio(parser->getValueByKey(idx, "scl")); Wire.begin(sda, scl); @@ -320,7 +330,7 @@ void Config::parseCfg(Controller* controller, Webserver* web, String n) { } Logger::getInstance()->addToLog("Test MCP23017 auf I2c/" + String(addr + 0x20) + ": " + tret); if (ret == 0) { - GPIO.addMCP23017(addr); + GPIOobj.addMCP23017(addr); } child = parser->getNextSiblings(child); } diff --git a/decoder/ConnectorGPIO.cpp b/decoder/ConnectorGPIO.cpp index 9c5e938..16649cc 100644 --- a/decoder/ConnectorGPIO.cpp +++ b/decoder/ConnectorGPIO.cpp @@ -1,5 +1,5 @@ /* - * ConnectorGPIO.cpp + * ConnectorGPIOobj.cpp * * Created on: 03.01.2018 * Author: sven @@ -11,7 +11,7 @@ ConnectorGPIO::ConnectorGPIO(ISettings* a, Pin* gpio) { action = a; pin = gpio; - GPIO.pinMode(gpio, INPUT_PULLUP, "GPIO"); + GPIOobj.pinMode(gpio, INPUT_PULLUP, "GPIO"); } ConnectorGPIO::~ConnectorGPIO() { diff --git a/decoder/Controller.cpp b/decoder/Controller.cpp index 6a0544e..209d927 100644 --- a/decoder/Controller.cpp +++ b/decoder/Controller.cpp @@ -6,7 +6,10 @@ */ #include -#include +#include "FS.h" +#ifdef ESP32 + #include "SPIFFS.h" +#endif #include "Controller.h" #include "Utils.h" #include "Logger.h" diff --git a/decoder/Controller.h b/decoder/Controller.h index cfae3dc..5ad0e43 100644 --- a/decoder/Controller.h +++ b/decoder/Controller.h @@ -8,7 +8,12 @@ #ifndef CONTROLLER_H_ #define CONTROLLER_H_ -#include +#ifdef ESP8266 + #include +#else + #include +#endif + #include #include #include @@ -22,14 +27,14 @@ #include "WebserviceDCCSniffer.h" struct LocData { - sint16 speed; - int8 direction; - int8 speedsteps; + int16_t speed; + int8_t direction; + int8_t speedsteps; unsigned long int status; } __attribute__ ((packed)); struct TurnOutData { - int8 direction; + int8_t direction; }; class CmdReceiverBase; diff --git a/decoder/DoubleBootDetection.cpp b/decoder/DoubleBootDetection.cpp index 07c1793..91534e8 100644 --- a/decoder/DoubleBootDetection.cpp +++ b/decoder/DoubleBootDetection.cpp @@ -7,6 +7,9 @@ #include "DoubleBootDetection.h" #include +#ifdef ESP32 + #include "SPIFFS.h" +#endif DoubleBootDetection::DoubleBootDetection(Controller* c) { controll = c; diff --git a/decoder/GPIO.cpp b/decoder/GPIO.cpp index c5939dc..df42ce6 100644 --- a/decoder/GPIO.cpp +++ b/decoder/GPIO.cpp @@ -9,9 +9,9 @@ GPIOClass::GPIOClass() { mcps = new LinkedList(); - data = new DataContainerSimpleList(16* 6 + 12, "", -1); - valueinputpins = new DataContainerSimpleList(16* 6 + 12, -1, -1); - pinusage = new DataContainer(-1, ""); + data = new DataContainerSimpleList(16* 6 + 12, "", -1); + valueinputpins = new DataContainerSimpleList(16* 6 + 12, -1, -1); + pinusage = new DataContainer(-1, ""); cacheEnabled = false; cachedValue = NULL; #ifdef ARDUINO_ESP8266_ESP01 @@ -170,11 +170,20 @@ void GPIOClass::analogWrite(uint16_t pin, int val) { "Analog Write not possible for Pin: " + String(pin)); return; } - ::analogWrite(pin, val); + #ifdef ESP8266 + ::analogWrite(pin, val); + #elif ESP32 + // Hack + #endif + } void GPIOClass::analogWriteFreq(uint32_t freq) { - ::analogWriteFreq(freq); + #ifdef ESP8266 + ::analogWriteFreq(freq); + #elif ESP32 + // Hack + #endif } /** @@ -193,7 +202,7 @@ void GPIOClass::addMCP23017(uint8_t addr) { mcps->add(m); } -GPIOClass GPIO; +GPIOClass GPIOobj; int GPIOClass::digitalRead(uint16_t pin) { if (pin >= 100) { diff --git a/decoder/GPIO.h b/decoder/GPIO.h index f1fb0f8..69e1930 100644 --- a/decoder/GPIO.h +++ b/decoder/GPIO.h @@ -25,9 +25,9 @@ class GPIOClass : public ILoop { public: - DataContainer* pinusage; + DataContainer* pinusage; // All GPIO in Modus INPUT or INPUT_PULLUP (will update every 30 ms) - DataContainerSimpleList* valueinputpins; + DataContainerSimpleList* valueinputpins; @@ -57,7 +57,7 @@ class GPIOClass : public ILoop { private: - DataContainerSimpleList* data; + DataContainerSimpleList* data; void addUsage(uint16_t pin, String usage); Controller* controller; LinkedList* mcps; @@ -65,7 +65,7 @@ class GPIOClass : public ILoop { uint16_t* cachedValue; }; -extern GPIOClass GPIO; +extern GPIOClass GPIOobj; #endif /* GPIO_H_ */ diff --git a/decoder/INotify.h b/decoder/INotify.h index baa93e4..fd10db5 100644 --- a/decoder/INotify.h +++ b/decoder/INotify.h @@ -33,7 +33,7 @@ class INotify { struct requestInfo { enum ART {TURNOUT, LOCO } __attribute__ ((packed)) art; - uint16 id; + uint16_t id; } __attribute__ ((packed)); virtual void getRequestList(LinkedList* list); protected: diff --git a/decoder/Logger.cpp b/decoder/Logger.cpp index 5b9de43..ba23b33 100644 --- a/decoder/Logger.cpp +++ b/decoder/Logger.cpp @@ -66,7 +66,13 @@ int Logger::loop() { } logdata* log = logger.get(last); udp->beginPacket(*logserver, 514); - udp->write(log->msg.c_str(), log->msg.length()); + #ifdef ESP8266 + udp->write(log->msg.c_str(), log->msg.length()); + #elif ESP32 + udp->write((const uint8_t *)log->msg.c_str(), log->msg.length()); + #else + #error "This Arch is not supported" + #endif if (udp->endPacket() == 1) { log->send = true; } else { diff --git a/decoder/NmraDcc2.h b/decoder/NmraDcc2.h index 6a1dcbb..d1c0503 100644 --- a/decoder/NmraDcc2.h +++ b/decoder/NmraDcc2.h @@ -91,6 +91,8 @@ typedef struct { #if defined(ESP8266) #define MAXCV 4096 +#elif defined(ESP32) +#define MAXCV 4096 #else #define MAXCV E2END // the upper limit of the CV value currently defined to max memory. #endif diff --git a/decoder/Pin.cpp b/decoder/Pin.cpp index fcbabbc..4fd6960 100644 --- a/decoder/Pin.cpp +++ b/decoder/Pin.cpp @@ -15,7 +15,7 @@ Pin::Pin(const char* pindefinition) { invert = true; pindef = pindef.substring(1); } - pin = GPIO.string2gpio(pindef.c_str()); + pin = GPIOobj.string2gpio(pindef.c_str()); } @@ -25,7 +25,7 @@ Pin::Pin(String pindef) { invert = true; pindef = pindef.substring(1); } - pin = GPIO.string2gpio(pindef.c_str()); + pin = GPIOobj.string2gpio(pindef.c_str()); } @@ -37,7 +37,7 @@ String Pin::toString() { if (invert) { s = "!"; } - s += GPIO.gpio2string(pin) + "/" + String(pin); + s += GPIOobj.gpio2string(pin) + "/" + String(pin); return s; } diff --git a/decoder/SPINonBlocking.cpp b/decoder/SPINonBlocking.cpp index d3fefc7..7d3de50 100644 --- a/decoder/SPINonBlocking.cpp +++ b/decoder/SPINonBlocking.cpp @@ -23,6 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef ESP8266 + #include "SPINonBlocking.h" #include "HardwareSerial.h" @@ -46,9 +48,9 @@ SPINonClockingClass::SPINonClockingClass() { void SPINonClockingClass::begin(SPISettings settings, String funktion) { - GPIO.pinMode(MOSI, SPECIAL, funktion + " SPI"); ///< GPIO13 + GPIOobj.pinMode(MOSI, SPECIAL, funktion + " SPI"); ///< GPIO13 if (settings._SCK) { - GPIO.pinMode(SCK, SPECIAL, funktion + " SPI/CLOCK"); ///< GPIO14 + GPIOobj.pinMode(SCK, SPECIAL, funktion + " SPI/CLOCK"); ///< GPIO14 } SPI1C = 0; setFrequency(1000000); ///< 1MHz @@ -58,7 +60,7 @@ void SPINonClockingClass::begin(SPISettings settings, String funktion) { } void SPINonClockingClass::end() { - GPIO.pinMode(MOSI, OUTPUT, "SPI"); + GPIOobj.pinMode(MOSI, OUTPUT, "SPI"); } @@ -278,3 +280,4 @@ int SPINonClockingClass::getSCKPin() { return SCK; } +#endif diff --git a/decoder/SPINonBlocking.h b/decoder/SPINonBlocking.h index d7cc4dd..2e376da 100644 --- a/decoder/SPINonBlocking.h +++ b/decoder/SPINonBlocking.h @@ -25,6 +25,8 @@ #ifndef SPINONBLOCKING_H_ #define SPINONBLOCKING_H_ +#ifdef ESP8266 + #include #include @@ -40,14 +42,15 @@ #define SPI_CLOCK_DIV64 0x027c1001 //250 KHz #define SPI_CLOCK_DIV128 0x04fc1001 //125 KHz -const uint8_t SPI_MODE0 = 0x00; ///< CPOL: 0 CPHA: 0 -const uint8_t SPI_MODE1 = 0x01; ///< CPOL: 0 CPHA: 1 -const uint8_t SPI_MODE2 = 0x10; ///< CPOL: 1 CPHA: 0 -const uint8_t SPI_MODE3 = 0x11; ///< CPOL: 1 CPHA: 1 +//const uint8_t SPI_MODE0 = 0x00; ///< CPOL: 0 CPHA: 0 +//const uint8_t SPI_MODE1 = 0x01; ///< CPOL: 0 CPHA: 1 +//const uint8_t SPI_MODE2 = 0x10; ///< CPOL: 1 CPHA: 0 +//const uint8_t SPI_MODE3 = 0x11; ///< CPOL: 1 CPHA: 1 +const uint8_t my_SPI_MODE3 = 0x11; ///< CPOL: 0 CPHA: 0 class SPISettings { public: - SPISettings() :_clock(1000000), _bitOrder(LSBFIRST), _dataMode(SPI_MODE0), _SCK(false){} + SPISettings() :_clock(1000000), _bitOrder(LSBFIRST), _dataMode(my_SPI_MODE3), _SCK(false){} SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode, bool useSCK) :_clock(clock), _bitOrder(bitOrder), _dataMode(dataMode), _SCK(useSCK) {} uint32_t _clock; uint8_t _bitOrder; @@ -77,5 +80,6 @@ class SPINonClockingClass { extern SPINonClockingClass SPI; +#endif #endif /* SPINONBLOCKING_H_ */ diff --git a/decoder/Utils.h b/decoder/Utils.h index ea74959..7038cf9 100644 --- a/decoder/Utils.h +++ b/decoder/Utils.h @@ -8,7 +8,12 @@ #ifndef UTILS_H_ #define UTILS_H_ -#include +#ifdef ESP8266 + #include +#else + #include +#endif + #include "Consts.h" #include "Logger.h" #include "GPIO.h" diff --git a/decoder/Webserver.cpp b/decoder/Webserver.cpp index d8b6874..9c72cd7 100644 --- a/decoder/Webserver.cpp +++ b/decoder/Webserver.cpp @@ -6,26 +6,34 @@ */ #include -#include -#include #include -#include - +#ifdef ESP32 + #include + #include "SPIFFS.h" +#endif #include "Webserver.h" + #include "Controller.h" #include "Logger.h" #include "WebserviceLog.h" #include "Utils.h" #include "Config.h" +#ifdef ESP8266 ESP8266WebServer* Webserver::server = 0; ESP8266HTTPUpdateServer* Webserver::httpUpdater = 0; - +#elif ESP32 +WebServer* Webserver::server = 0; +#endif Webserver::Webserver(Controller* c) { controll = c; - +#ifdef ESP8266 server = new ESP8266WebServer(80); +#elif ESP32 + server = new WebServer(80); +#endif + server->onNotFound(std::bind(&Webserver::handleNotFound, this)); server->on("/", std::bind(&Webserver::handleRoot, this)); server->on("/version", std::bind(&Webserver::handleVersion, this)); @@ -40,9 +48,11 @@ Webserver::Webserver(Controller* c) { std::bind(&Webserver::handleUpload, this)); server->on("/del", std::bind(&Webserver::handleDel, this)); server->begin(); +#ifdef ESP8266 httpUpdater = new ESP8266HTTPUpdateServer(); const char* update_path = "/firmware"; httpUpdater->setup(server, update_path, "admin", "admin"); +#endif } @@ -101,9 +111,11 @@ void Webserver::handleDoFormat() { } void Webserver::handleFilelist() { + String output = "" + Utils::getHTMLHeader() + F(""); +#ifdef esp8266 + // TODO Dir dir = SPIFFS.openDir("/"); - String output = "" + Utils::getHTMLHeader() + F("
NameSize
"); while(dir.next()){ File entry = dir.openFile("r"); @@ -124,6 +136,7 @@ void Webserver::handleFilelist() { output += F("
"); output += F("
"); output += Utils::getHTMLFooter(); +#endif server->send(200, "text/html", output); } @@ -170,8 +183,11 @@ int Webserver::loop() { Serial.printf("Connection to: %s (Q:%d)\r\n", WiFi.BSSIDstr().c_str(), WiFi.RSSI()); lastWifiStatus = WiFi.status(); if (WiFi.status() == WL_CONNECTED) { + #ifdef esp8266 + // TODO MDNS.begin(controll->getHostname().c_str()); MDNS.addService("http", "tcp", 80); + #endif } } return 2; diff --git a/decoder/Webserver.h b/decoder/Webserver.h index d2a10ad..da2506e 100644 --- a/decoder/Webserver.h +++ b/decoder/Webserver.h @@ -10,11 +10,18 @@ #include #include -#include -#include +#ifdef ESP8266 + #include + #include + #include +#elif ESP32 + #include +#else + #error "This Arch is not supported" +#endif + #include #include "WebserviceBase.h" -#include #include "ILoop.h" @@ -25,7 +32,11 @@ class Webserver: public ILoop { Webserver(Controller* c); virtual int loop(); virtual ~Webserver(); +#ifdef ESP8266 static ESP8266WebServer* server; +#elif ESP32 + static WebServer* server; +#endif void registerWebServices(WebserviceBase* base); @@ -46,7 +57,9 @@ class Webserver: public ILoop { File fsUploadFile; Controller* controll; LinkedList services = LinkedList(); - static ESP8266HTTPUpdateServer* httpUpdater; + #ifdef ESP8266 + static ESP8266HTTPUpdateServer* httpUpdater; + #endif }; diff --git a/decoder/WebserviceBase.cpp b/decoder/WebserviceBase.cpp index ca2d158..d57819a 100644 --- a/decoder/WebserviceBase.cpp +++ b/decoder/WebserviceBase.cpp @@ -6,7 +6,12 @@ */ #include "Arduino.h" #include "WebserviceBase.h" -#include +#ifdef ESP8266 + #include +#elif ESP32 + #include +#endif + WebserviceBase::WebserviceBase() { @@ -16,9 +21,16 @@ WebserviceBase::WebserviceBase() { WebserviceBase::~WebserviceBase() { } +#ifdef ESP8266 void WebserviceBase::setServer(ESP8266WebServer* server) { this->server = server; } +#elif ESP32 +void WebserviceBase::setServer(WebServer* server) { + this->server = server; +} +#endif + String WebserviceBase::getLinkText() { return ""; diff --git a/decoder/WebserviceBase.h b/decoder/WebserviceBase.h index f14578f..67338ba 100644 --- a/decoder/WebserviceBase.h +++ b/decoder/WebserviceBase.h @@ -9,7 +9,18 @@ #define WEBSERVICEBASE_H_ #include "Arduino.h" -class ESP8266WebServer; +#ifdef ESP8266 + #include +#elif ESP32 + #include +#endif + +// +//#ifdef ESP8266 +// class ESP8266WebServer; +//#elif ESP32 +// class WebServer; +//#endif class WebserviceBase { public: @@ -17,12 +28,22 @@ class WebserviceBase { virtual ~WebserviceBase(); virtual char const* getUri() = 0; virtual void run() = 0; +#ifdef ESP8266 void setServer(ESP8266WebServer* server); +#elif ESP32 + void setServer(WebServer* server); +#endif + virtual String getLinkText(); protected: +#ifdef ESP8266 ESP8266WebServer* server; +#elif ESP32 + WebServer* server; +#endif + void sendBasicHeader(); void finishSend(); void send(const String& content); diff --git a/decoder/WebserviceCommandLogger.cpp b/decoder/WebserviceCommandLogger.cpp index 5473b29..5046668 100644 --- a/decoder/WebserviceCommandLogger.cpp +++ b/decoder/WebserviceCommandLogger.cpp @@ -7,7 +7,6 @@ #include "WebserviceCommandLogger.h" -#include #include "Arduino.h" #include "Utils.h" diff --git a/decoder/WebserviceLog.cpp b/decoder/WebserviceLog.cpp index 3a36911..495acd7 100644 --- a/decoder/WebserviceLog.cpp +++ b/decoder/WebserviceLog.cpp @@ -9,7 +9,6 @@ #include "Logger.h" #include "Webserver.h" #include -#include #include "Utils.h" WebserviceLog::WebserviceLog() { @@ -42,7 +41,7 @@ void WebserviceLog::run() { send(start + "IP (Access Point)\n"; } message += "
NameSize
" + WiFi.softAPIP().toString() + end); send(start + "IP (WLAN Client)" + WiFi.localIP().toString() + end); send(start + "Pins"); - send(GPIO.getUsage("
")); + send(GPIOobj.getUsage("
")); send(end); LinkedList* list = Logger::getInstance()->getLogs(); for (int i = 0; i < list->size(); i++) { diff --git a/decoder/WebserviceLog.h b/decoder/WebserviceLog.h index 59612a5..d754abf 100644 --- a/decoder/WebserviceLog.h +++ b/decoder/WebserviceLog.h @@ -11,7 +11,6 @@ #include "Arduino.h" #include "WebserviceBase.h" #include -#include class WebserviceLog: public WebserviceBase { public: diff --git a/decoder/WebserviceWifiScanner.cpp b/decoder/WebserviceWifiScanner.cpp index 3939ce4..134ef20 100644 --- a/decoder/WebserviceWifiScanner.cpp +++ b/decoder/WebserviceWifiScanner.cpp @@ -6,8 +6,12 @@ */ #include -#include + #ifdef ESP8266 #include + #elif ESP32 +#include + #endif + #include "WebserviceWifiScanner.h" @@ -43,7 +47,12 @@ void WebserviceWifiScanner::run() { message += "
"; message += dbm2qual(WiFi.RSSI(i)); message += "%"; - message += (WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "ENC"; + + #ifdef ESP8266 + message += (WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "ENC"; + #elif ESP32 + message += (WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? " " : "ENC"; + #endif message += "
"; diff --git a/decoder/WebserviceWifiScanner.h b/decoder/WebserviceWifiScanner.h index 32682ab..d1660ce 100644 --- a/decoder/WebserviceWifiScanner.h +++ b/decoder/WebserviceWifiScanner.h @@ -9,8 +9,6 @@ #define WEBSERVICEWIFISCANNER_H_ #include -#include - #include "WebserviceBase.h" class WebserviceWifiScanner: public WebserviceBase { diff --git a/decoder/decoder.cpp b/decoder/decoder.cpp index 52d7dde..2d6398b 100644 --- a/decoder/decoder.cpp +++ b/decoder/decoder.cpp @@ -21,12 +21,19 @@ Controller* controller; #include "ConnectorONOFF.h" #include "Connectors.h" #include "ConnectorTurnout.h" - +#include "FS.h" +#ifdef ESP32 + #include "SPIFFS.h" +#endif void initWifi() { Serial.println("Starting Wifi..."); WiFi.persistent(false); - WiFi.hostname(controller->getHostname()); + #ifdef ESP8266 + WiFi.hostname(controller->getHostname()); + #elif ESP32 + WiFi.setHostname(controller->getHostname().c_str()); + #endif WiFi.mode(WIFI_OFF); WiFi.disconnect(); } @@ -66,7 +73,7 @@ void loadCFG(Webserver* web) { controller->enableAPModus(); return; } - controller->registerLoop(&GPIO); + controller->registerLoop(&GPIOobj); controller->registerLoop(web); controller->registerLoop(Logger::getInstance()); controller->updateRequestList(); @@ -90,7 +97,10 @@ void handleSerial() { } } else if (chr == 'd') { // Taken from https://github.com/esp8266/Arduino/blob/master/libraries/esp8266/examples/CheckFlashConfig/CheckFlashConfig.ino - uint32_t realSize = ESP.getFlashChipRealSize(); + uint32_t realSize = -1; + #ifdef ESP8266 + realSize = ESP.getFlashChipRealSize(); + #endif uint32_t ideSize = ESP.getFlashChipSize(); FlashMode_t ideMode = ESP.getFlashChipMode(); @@ -180,7 +190,7 @@ void handleSerial() { Serial.printf("Pointer %d\r\n", sizeof(String*)); Serial.printf("String (without Buffer) %d\r\n", sizeof(String)); Serial.printf("int %d\r\n", sizeof(int)); - Serial.printf("sint16 %d\r\n", sizeof(sint16)); + Serial.printf("sint16 %d\r\n", sizeof(int16_t)); Serial.printf("bool %d\r\n", sizeof(bool)); Serial.println(); Serial.printf("RequestInfo %d\r\n", sizeof(INotify::requestInfo)); @@ -219,9 +229,14 @@ void handleSerial() { uint8_t sec_scan; uint8_t* BSSID_scan; int32_t chan_scan; - bool hidden_scan; + bool hidden_scan = false; + + #ifdef ESP8266 + WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan, hidden_scan); + #elif ESP32 + WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan); + #endif - WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan, hidden_scan); message +="["; for (int i = 0; i < 6; i++) { if (BSSID_scan[i] < 16) { @@ -239,7 +254,11 @@ void handleSerial() { } message += String(chan_scan); message += " "; - message += (WiFi.encryptionType(i) == ENC_TYPE_NONE) ? "OPEN" : "ENC "; + #ifdef ESP8266 + message += (WiFi.encryptionType(i) == ENC_TYPE_NONE) ? "OPEN" : "ENC "; + #elif ESP32 + message += (WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? "OPEN" : "ENC "; + #endif message += " Q:"; message += String(WiFi.RSSI(i)); message += " --- "; @@ -267,7 +286,7 @@ void setup() { Serial.println("MEM " + String(ESP.getFreeHeap()) + " / Controller"); controller = new Controller(); controller->registerLoop(new DoubleBootDetection(controller)); - GPIO.setController(controller); + GPIOobj.setController(controller); Serial.println("MEM " + String(ESP.getFreeHeap()) + " / Wifi"); initWifi(); Serial.println("MEM " + String(ESP.getFreeHeap()) + " / Webserver"); @@ -277,7 +296,7 @@ void setup() { Serial.println("MEM " + String(ESP.getFreeHeap()) + " / Cfg"); loadCFG(web); Serial.println("MEM " + String(ESP.getFreeHeap()) + " / Setup Finish"); - Serial.println(GPIO.getUsage("\r\n")); + Serial.println(GPIOobj.getUsage("\r\n")); Logger::getInstance()->addToLog("Setup finish!"); controller->longestLoop = 0; diff --git a/decoder/jsmn.h b/decoder/jsmn.h index a19e648..b61a2b7 100644 --- a/decoder/jsmn.h +++ b/decoder/jsmn.h @@ -84,10 +84,10 @@ enum jsmnerr { */ typedef struct { jsmntype_t type; - sint16 start; - sint16 end; - sint16 skip; - sint16 parent; + int16_t start; + int16_t end; + int16_t skip; + int16_t parent; } __attribute__ ((packed)) jsmntok_t; /** diff --git a/platformio.ini b/platformio.ini index 7cc05d2..e4accf6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -104,3 +104,7 @@ upload_resetmethod = nodemcu upload_speed = 921600 +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = arduino