Added RemoteDebug and a define to change debugging from serial to telnet depening on telnet define at top of .ino

This commit is contained in:
James 2018-10-28 14:03:44 +11:00
parent f3d6d8d6d2
commit 15a3b6d3ef
6 changed files with 225 additions and 79 deletions

View file

@ -1,19 +1,110 @@
#include "BTCWifi.h" #include "BTCWifi.h"
//this is for telnet only
// select which pin will trigger the configuration portal when set to LOW // select which pin will trigger the configuration portal when set to LOW
WiFiManager wm; WiFiManager wm;
// Time
RemoteDebug Debug;
uint32_t mLastTime = 0;
uint32_t mTimeSeconds = 0;
// Buildin Led ON ?
boolean mLedON = false;
unsigned int timeout = 120; // seconds to run for unsigned int timeout = 120; // seconds to run for
unsigned int startTime = millis(); unsigned int startTime = millis();
bool portalRunning = false; bool portalRunning = false;
bool startCP = false; // start AP and webserver if true, else start only webserver bool startCP = false; // start AP and webserver if true, else start only webserver
int TRIG_PIN; int TRIG_PIN;
bool res;
void inittelnetdebug(String HOST_NAME)
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
String hostNameWifi = HOST_NAME;
hostNameWifi.concat(".local");
Debug.begin(HOST_NAME);
Debug.setResetCmdEnabled(true); // Enable the reset command
Serial.println("* Arduino RemoteDebug Library");
Serial.println("*");
Serial.print("* WiFI connected. IP address: ");
Serial.println(WiFi.localIP());
Serial.println("*");
Serial.println("* Please use the telnet client (telnet for Mac/Unix or putty and others for Windows)");
Serial.println("*");
Serial.println("* This sample will send messages of debug in all levels.");
Serial.println("*");
Serial.println("* Please try change debug level in telnet, to see how it works");
Serial.println("*");
}
void DoDebug()
{
// Each second
if ((millis() - mLastTime) >= 1000) {
// Time
mLastTime = millis();
mTimeSeconds++;
// Blink the led
mLedON = !mLedON;
digitalWrite(LED_BUILTIN, (mLedON)?LOW:HIGH);
// Debug the time (verbose level)
rdebugVln("* Time: %u seconds (VERBOSE)", mTimeSeconds);
if (mTimeSeconds % 5 == 0) { // Each 5 seconds
Debug.handle();
}
}
}
void initWifi(int initpin) void initWifi(int initpin)
{ {
TRIG_PIN = initpin; TRIG_PIN = initpin;
pinMode(initpin, INPUT_PULLUP);
//reset settings - wipe credentials for testing
//wm.resetSettings();
// Automatically connect using saved credentials,
// if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
// if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect())
// then goes into a blocking loop awaiting configuration and will return success result
res = wm.autoConnect(); // auto generated AP name from chipid
if(!res) {
Serial.println("Failed to connect");
// ESP.restart();
}
else {
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
}
} }
void doWiFiManager(){ void doWiFiManager(){
@ -33,15 +124,17 @@ void doWiFiManager(){
} }
// is configuration portal requested? // is configuration portal requested?
if(digitalRead(TRIG_PIN) == LOW && (!portalRunning)) { if(TRIG_PIN == 1 && (!portalRunning)) {
if(startCP){ if(startCP){
Serial.println("Button Pressed, Starting Config Portal"); Serial.println("Button Pressed, Starting Config Portal");
wm.setConfigPortalBlocking(false); wm.setConfigPortalBlocking(false);
wm.startConfigPortal(); wm.startConfigPortal();
TRIG_PIN = 0; // reset the flag
} }
else{ else{
Serial.println("Button Pressed, Starting Web Portal"); Serial.println("Button Pressed, Starting Web Portal");
wm.startWebPortal(); wm.startWebPortal();
TRIG_PIN = 0; // reset the flag
} }
portalRunning = true; portalRunning = true;
startTime = millis(); startTime = millis();

View file

@ -1,8 +1,12 @@
#include <Arduino.h> #include <Arduino.h>
#include <WiFiManager.h> #include <WiFiManager.h>
#include "RemoteDebug.h" //https://github.com/JoaoLopesF/RemoteDebug
extern RemoteDebug Debug;
void doWiFiManager(); void doWiFiManager();
void initWifi(int initpin); void initWifi(int initpin);
void DoDebug();
void inittelnetdebug(String HOST_NAME);

View file

@ -3,6 +3,15 @@
#include "Protocol.h" #include "Protocol.h"
#include "debugport.h" #include "debugport.h"
#ifdef TELNET
#define PRNT Debug
#endif
#ifndef TELNET
#define PRNT Serial
#endif
#ifdef ESP32 #ifdef ESP32
#define ESP32_USE_HC05 #define ESP32_USE_HC05
@ -52,14 +61,14 @@ void Bluetooth_Init()
// Open Serial2, explicitly specify pins for pin multiplexer!); // Open Serial2, explicitly specify pins for pin multiplexer!);
Serial2.begin(9600, SERIAL_8N1, Rx2Pin, Tx2Pin); Serial2.begin(9600, SERIAL_8N1, Rx2Pin, Tx2Pin);
DebugPort.println("\r\n\r\nAttempting to detect HC-05 Bluetooth module..."); PRNT.println("\r\n\r\nAttempting to detect HC-05 Bluetooth module...");
int BTidx = 0; int BTidx = 0;
int maxTries = sizeof(BTRates)/sizeof(int); int maxTries = sizeof(BTRates)/sizeof(int);
for(BTidx = 0; BTidx < maxTries; BTidx++) { for(BTidx = 0; BTidx < maxTries; BTidx++) {
DebugPort.print(" @ "); PRNT.print(" @ ");
DebugPort.print(BTRates[BTidx]); PRNT.print(BTRates[BTidx]);
DebugPort.print(" baud... "); PRNT.print(" baud... ");
Serial2.begin(BTRates[BTidx], SERIAL_8N1, Rx2Pin, Tx2Pin); // open serial port at a std.baud rate Serial2.begin(BTRates[BTidx], SERIAL_8N1, Rx2Pin, Tx2Pin); // open serial port at a std.baud rate
delay(10); delay(10);
Serial2.print("\r\n"); // clear the throat! Serial2.print("\r\n"); // clear the throat!
@ -67,31 +76,31 @@ void Bluetooth_Init()
Serial2.setTimeout(100); Serial2.setTimeout(100);
if(Bluetooth_ATCommand("AT\r\n")) { // probe with a simple "AT" if(Bluetooth_ATCommand("AT\r\n")) { // probe with a simple "AT"
DebugPort.println(" OK."); // got a response - woo hoo found the module! PRNT.println(" OK."); // got a response - woo hoo found the module!
break; break;
} }
if(Bluetooth_ATCommand("AT\r\n")) { // sometimes a second try is good... if(Bluetooth_ATCommand("AT\r\n")) { // sometimes a second try is good...
DebugPort.println(" OK."); PRNT.println(" OK.");
break; break;
} }
// failed, try another baud rate // failed, try another baud rate
DebugPort.println(""); PRNT.println("");
Serial2.flush(); Serial2.flush();
Serial2.end(); Serial2.end();
delay(100); delay(100);
} }
DebugPort.println(""); PRNT.println("");
if(BTidx == maxTries) { if(BTidx == maxTries) {
// we could not get anywhere with teh AT commands, but maybe this is the other module // we could not get anywhere with teh AT commands, but maybe this is the other module
// plough on and assume 9600 baud, but at the mercy of whatever the module name is... // plough on and assume 9600 baud, but at the mercy of whatever the module name is...
DebugPort.println("FAILED to detect a HC-05 Bluetooth module :-("); PRNT.println("FAILED to detect a HC-05 Bluetooth module :-(");
// leave the EN pin high - if other style module keeps it powered! // leave the EN pin high - if other style module keeps it powered!
// assume it is 9600, and just (try to) use it like that... // assume it is 9600, and just (try to) use it like that...
// we will sense the STATE line to prove a client is hanging off the link... // we will sense the STATE line to prove a client is hanging off the link...
DebugPort.println("ASSUMING a HC-05 module @ 9600baud (Unknown name)"); PRNT.println("ASSUMING a HC-05 module @ 9600baud (Unknown name)");
Serial2.begin(9600, SERIAL_8N1, Rx2Pin, Tx2Pin); Serial2.begin(9600, SERIAL_8N1, Rx2Pin, Tx2Pin);
} }
else { else {
@ -99,22 +108,22 @@ void Bluetooth_Init()
// now program it's name and force a 9600 baud data interface. // now program it's name and force a 9600 baud data interface.
// this is the defacto standard as shipped! // this is the defacto standard as shipped!
DebugPort.println("HC-05 found"); PRNT.println("HC-05 found");
do { // so we can break! do { // so we can break!
DebugPort.print(" Setting Name to \"Diesel Heater\"... "); PRNT.print(" Setting Name to \"Diesel Heater\"... ");
if(!Bluetooth_ATCommand("AT+NAME=\"Diesel Heater\"\r\n")) { if(!Bluetooth_ATCommand("AT+NAME=\"Diesel Heater\"\r\n")) {
DebugPort.println("FAILED"); PRNT.println("FAILED");
break; break;
} }
DebugPort.println("OK"); PRNT.println("OK");
DebugPort.print(" Setting baud rate to 9600N81..."); PRNT.print(" Setting baud rate to 9600N81...");
if(!Bluetooth_ATCommand("AT+UART=9600,1,0\r\n")) { if(!Bluetooth_ATCommand("AT+UART=9600,1,0\r\n")) {
DebugPort.println("FAILED"); PRNT.println("FAILED");
break; break;
}; };
DebugPort.println("OK"); PRNT.println("OK");
Serial2.begin(9600, SERIAL_8N1, Rx2Pin, Tx2Pin); Serial2.begin(9600, SERIAL_8N1, Rx2Pin, Tx2Pin);
@ -125,7 +134,7 @@ void Bluetooth_Init()
delay(50); delay(50);
DebugPort.println(""); PRNT.println("");
} }
void Bluetooth_Check() void Bluetooth_Check()
@ -146,8 +155,8 @@ void Bluetooth_Check()
void Bluetooth_SendFrame(const char* pHdr, const CProtocol& Frame, bool lineterm) void Bluetooth_SendFrame(const char* pHdr, const CProtocol& Frame, bool lineterm)
{ {
DebugPort.print(millis()); PRNT.print(millis());
DebugPort.print("ms "); PRNT.print("ms ");
// DebugReportFrame(pHdr, Frame, lineterm ? "\r\n" : " "); // DebugReportFrame(pHdr, Frame, lineterm ? "\r\n" : " ");
DebugReportFrame(pHdr, Frame, " "); DebugReportFrame(pHdr, Frame, " ");
@ -160,16 +169,16 @@ void Bluetooth_SendFrame(const char* pHdr, const CProtocol& Frame, bool lineterm
digitalWrite(LED, !digitalRead(LED)); // toggle LED digitalWrite(LED, !digitalRead(LED)); // toggle LED
} }
else { else {
DebugPort.print("Bluetooth data not sent, CRC error "); PRNT.print("Bluetooth data not sent, CRC error ");
} }
} }
else { else {
DebugPort.print("No Bluetooth client"); PRNT.print("No Bluetooth client");
// force LED off // force LED off
digitalWrite(LED, 0); digitalWrite(LED, 0);
} }
if(lineterm) if(lineterm)
DebugPort.println(""); PRNT.println("");
} }
// local function, typically to perform Hayes commands with HC-05 // local function, typically to perform Hayes commands with HC-05
@ -204,7 +213,7 @@ void Bluetooth_Init()
pinMode(LED, OUTPUT); pinMode(LED, OUTPUT);
if(!SerialBT.begin("ESPHEATER")) { if(!SerialBT.begin("ESPHEATER")) {
DebugPort.println("An error occurred initialising Bluetooth"); PRNT.println("An error occurred initialising Bluetooth");
} }
} }
@ -226,7 +235,7 @@ void Bluetooth_SendFrame(const char* pHdr, const CProtocol& Frame, bool lineterm
{ {
char fullMsg[32]; char fullMsg[32];
DebugPort.print(millis()); PRNT.print(millis());
DebugReportFrame(pHdr, Frame, lineterm ? "\r\n" : " "); DebugReportFrame(pHdr, Frame, lineterm ? "\r\n" : " ");
delay(40); delay(40);
if(SerialBT.hasClient()) { if(SerialBT.hasClient()) {
@ -245,11 +254,11 @@ void Bluetooth_SendFrame(const char* pHdr, const CProtocol& Frame, bool lineterm
delay(10); delay(10);
} }
else { else {
DebugPort.println("Data not sent to Bluetooth, CRC error!"); PRNT.println("Data not sent to Bluetooth, CRC error!");
} }
} }
else { else {
DebugPort.println("No Bluetooth client"); PRNT.println("No Bluetooth client");
digitalWrite(LED, 0); digitalWrite(LED, 0);
} }
} }
@ -357,7 +366,7 @@ void Bluetooth_Init()
pService->start(); pService->start();
// start advertising // start advertising
pServer->getAdvertising()->start(); pServer->getAdvertising()->start();
DebugPort.println("Awaiting a client to notify..."); PRNT.println("Awaiting a client to notify...");
} }
void Bluetooth_Report(const char* pHdr, const CProtocol& Frame) void Bluetooth_Report(const char* pHdr, const CProtocol& Frame)
@ -380,7 +389,7 @@ void Bluetooth_Check()
if (!deviceConnected && oldDeviceConnected) { if (!deviceConnected && oldDeviceConnected) {
delay(500); // give the bluetooth stack the chance to get things ready delay(500); // give the bluetooth stack the chance to get things ready
pServer->startAdvertising(); // restart advertising pServer->startAdvertising(); // restart advertising
DebugPort.println("start advertising"); PRNT.println("start advertising");
oldDeviceConnected = deviceConnected; oldDeviceConnected = deviceConnected;
} }
// connecting // connecting

View file

@ -37,54 +37,54 @@ void Bluetooth_Init()
digitalWrite(KeyPin, HIGH); digitalWrite(KeyPin, HIGH);
delay(500); delay(500);
DebugPort.println("\r\n\r\nAttempting to detect HC-05 Bluetooth module..."); PRNT.println("\r\n\r\nAttempting to detect HC-05 Bluetooth module...");
int BTidx = 0; int BTidx = 0;
int maxTries = sizeof(BTRates)/sizeof(int); int maxTries = sizeof(BTRates)/sizeof(int);
for(BTidx = 0; BTidx < maxTries; BTidx++) { for(BTidx = 0; BTidx < maxTries; BTidx++) {
DebugPort.print(" @ "); PRNT.print(" @ ");
DebugPort.print(BTRates[BTidx]); PRNT.print(BTRates[BTidx]);
DebugPort.print(" baud... "); PRNT.print(" baud... ");
Bluetooth.end(); Bluetooth.end();
Bluetooth.begin(BTRates[BTidx]); // open serial port at a certain baud rate Bluetooth.begin(BTRates[BTidx]); // open serial port at a certain baud rate
Bluetooth.print("\r\n"); Bluetooth.print("\r\n");
Bluetooth.setTimeout(50); Bluetooth.setTimeout(50);
if(Bluetooth_ATCommand("AT\r\n")) { if(Bluetooth_ATCommand("AT\r\n")) {
DebugPort.println(" OK."); PRNT.println(" OK.");
break; break;
} }
// failed, try another baud rate // failed, try another baud rate
DebugPort.println(""); PRNT.println("");
Bluetooth.flush(); Bluetooth.flush();
} }
DebugPort.println(""); PRNT.println("");
if(BTidx == maxTries) { if(BTidx == maxTries) {
DebugPort.println("FAILED to detect HC-05 Bluetooth module :-("); PRNT.println("FAILED to detect HC-05 Bluetooth module :-(");
} }
else { else {
if(BTRates[BTidx] == 115200) { if(BTRates[BTidx] == 115200) {
DebugPort.println("HC-05 found and already set to 115200 baud, skipping Init."); PRNT.println("HC-05 found and already set to 115200 baud, skipping Init.");
bHC05Available = true; bHC05Available = true;
} }
else { else {
do { do {
DebugPort.println("HC-05 found"); PRNT.println("HC-05 found");
DebugPort.print(" Setting Name to \"DieselHeater\"... "); PRNT.print(" Setting Name to \"DieselHeater\"... ");
if(!Bluetooth_ATCommand("AT+NAME=\"DieselHeater\"\r\n")) { if(!Bluetooth_ATCommand("AT+NAME=\"DieselHeater\"\r\n")) {
DebugPort.println("FAILED"); PRNT.println("FAILED");
break; break;
} }
DebugPort.println("OK"); PRNT.println("OK");
DebugPort.print(" Setting baud rate to 115200N81..."); PRNT.print(" Setting baud rate to 115200N81...");
if(!Bluetooth_ATCommand("AT+UART=115200,1,0\r\n")) { if(!Bluetooth_ATCommand("AT+UART=115200,1,0\r\n")) {
DebugPort.println("FAILED"); PRNT.println("FAILED");
break; break;
}; };
DebugPort.println("OK"); PRNT.println("OK");
Bluetooth.end(); Bluetooth.end();
Bluetooth.begin(115200); Bluetooth.begin(115200);
@ -101,7 +101,7 @@ void Bluetooth_Init()
if(!bHC05Available) if(!bHC05Available)
Bluetooth.end(); // close serial port if no module found Bluetooth.end(); // close serial port if no module found
DebugPort.println(""); PRNT.println("");
} }
void Bluetooth_Check() void Bluetooth_Check()
@ -130,8 +130,8 @@ void Bluetooth_SendFrame(const char* pHdr, const CProtocol& Frame)
Bluetooth.write(Frame.Data, 24); Bluetooth.write(Frame.Data, 24);
} }
else { else {
DebugPort.print("Bluetooth data not sent, CRC error "); PRNT.print("Bluetooth data not sent, CRC error ");
DebugPort.println(pHdr); PRNT.println(pHdr);
} }
} }
} }

View file

@ -1,6 +1,15 @@
#include <Arduino.h> #include <Arduino.h>
#include "Protocol.h" #include "Protocol.h"
#include "debugport.h" #include "debugport.h"
#ifdef TELNET
#define PRNT Debug
#endif
#ifndef TELNET
#define PRNT Serial
#endif
unsigned short unsigned short
CProtocol::CalcCRC(int len) const CProtocol::CalcCRC(int len) const
@ -52,10 +61,10 @@ CProtocol::verifyCRC() const
unsigned short FrameCRC = getCRC(); unsigned short FrameCRC = getCRC();
bool bOK = (FrameCRC == CRC); bool bOK = (FrameCRC == CRC);
if(!bOK) { if(!bOK) {
DebugPort.print("verifyCRC FAILED: calc:"); PRNT.print("verifyCRC FAILED: calc:");
DebugPort.print(CRC, HEX); PRNT.print(CRC, HEX);
DebugPort.print(" data:"); PRNT.print(" data:");
DebugPort.println(FrameCRC, HEX); PRNT.println(FrameCRC, HEX);
} }
return bOK; // does it match the stored values? return bOK; // does it match the stored values?
} }

View file

@ -1,3 +1,17 @@
//comment this out to remove TELNET
#define TELNET
#ifdef TELNET
#define PRNT Debug
#endif
#ifndef TELNET
#define PRNT Serial
#endif
/* /*
Chinese Heater Half Duplex Serial Data Sending Tool Chinese Heater Half Duplex Serial Data Sending Tool
@ -68,8 +82,22 @@
#include "NVStorage.h" #include "NVStorage.h"
#include "debugport.h" #include "debugport.h"
#include "BTCWifi.h" #include "BTCWifi.h"
#define HOST_NAME "remotedebug-sample"
#define TRIGGER_PIN 0
#define TRIGGER_PIN 12
//comment this out to remove TELNET
#define TELNET
#ifdef TELNET
#define PRNT Debug
#endif
#ifndef TELNET
#define PRNT DebugPort
#endif
#define DEBUG_BTRX #define DEBUG_BTRX
#include "Bluetooth.h" #include "Bluetooth.h"
@ -155,6 +183,7 @@ void PrepareTxFrame(const CProtocol& basisFrame, CProtocol& TxFrame, bool isBTCm
void setup() void setup()
{ {
initWifi(TRIGGER_PIN); initWifi(TRIGGER_PIN);
inittelnetdebug(HOST_NAME);
// initialize serial port to interact with the "blue wire" // initialize serial port to interact with the "blue wire"
// 25000 baud, Tx and Rx channels of Chinese heater comms interface: // 25000 baud, Tx and Rx channels of Chinese heater comms interface:
// Tx/Rx data to/from heater, // Tx/Rx data to/from heater,
@ -212,7 +241,9 @@ void loop()
{ {
unsigned long timenow = millis(); unsigned long timenow = millis();
doWiFiManager(); doWiFiManager();
DoDebug();
// check for test commands received from PC Over USB // check for test commands received from PC Over USB
if(DebugPort.available()) { if(DebugPort.available()) {
char rxval = DebugPort.read(); char rxval = DebugPort.read();
if(rxval == '+') { if(rxval == '+') {
@ -266,9 +297,9 @@ void loop()
// This will be the first activity for considerable period on the blue wire // This will be the first activity for considerable period on the blue wire
// The heater always responds to a controller frame, but otherwise never by itself // The heater always responds to a controller frame, but otherwise never by itself
if(BlueWireData.available() && (RxTimeElapsed > 100)) { if(BlueWireData.available() && (RxTimeElapsed > 100)) {
DebugPort.print("Re-sync'd with OEM Controller. "); PRNT.print("Re-sync'd with OEM Controller. ");
DebugPort.print(RxTimeElapsed); PRNT.print(RxTimeElapsed);
DebugPort.println("ms Idle time."); PRNT.println("ms Idle time.");
hasOEMController = true; hasOEMController = true;
CommState.set(CommStates::OEMCtrlRx); // we must add this new byte! CommState.set(CommStates::OEMCtrlRx); // we must add this new byte!
} }
@ -364,13 +395,13 @@ void loop()
void DebugReportFrame(const char* hdr, const CProtocol& Frame, const char* ftr) void DebugReportFrame(const char* hdr, const CProtocol& Frame, const char* ftr)
{ {
DebugPort.print(hdr); // header PRNT.print(hdr); // header
for(int i=0; i<24; i++) { for(int i=0; i<24; i++) {
char str[16]; char str[16];
sprintf(str, " %02X", Frame.Data[i]); // build 2 dig hex values sprintf(str, " %02X", Frame.Data[i]); // build 2 dig hex values
DebugPort.print(str); // and print PRNT.print(str); // and print
} }
DebugPort.print(ftr); // footer PRNT.print(ftr); // footer
} }
@ -383,7 +414,7 @@ void Command_Interpret(const char* pLine)
return; return;
#ifdef DEBUG_BTRX #ifdef DEBUG_BTRX
DebugPort.println(pLine); PRNT.println(pLine);
#endif #endif
if(strncmp(pLine, "[CMD]", 5) == 0) { if(strncmp(pLine, "[CMD]", 5) == 0) {
@ -393,61 +424,61 @@ void Command_Interpret(const char* pLine)
pLine += 5; // skip past "[CMD]" header pLine += 5; // skip past "[CMD]" header
if(strncmp(pLine, "ON", 2) == 0) { if(strncmp(pLine, "ON", 2) == 0) {
TxManage.queueOnRequest(); TxManage.queueOnRequest();
DebugPort.println("Heater ON"); PRNT.println("Heater ON");
} }
else if(strncmp(pLine, "OFF", 3) == 0) { else if(strncmp(pLine, "OFF", 3) == 0) {
TxManage.queueOffRequest(); TxManage.queueOffRequest();
DebugPort.println("Heater OFF"); PRNT.println("Heater OFF");
} }
else if(strncmp(pLine, "Pmin", 4) == 0) { else if(strncmp(pLine, "Pmin", 4) == 0) {
pLine += 4; pLine += 4;
cVal = (unsigned char)((atof(pLine) * 10.0) + 0.5); cVal = (unsigned char)((atof(pLine) * 10.0) + 0.5);
pNVStorage->setPmin(cVal); pNVStorage->setPmin(cVal);
DebugPort.print("Pump min = "); PRNT.print("Pump min = ");
DebugPort.println(cVal); PRNT.println(cVal);
} }
else if(strncmp(pLine, "Pmax", 4) == 0) { else if(strncmp(pLine, "Pmax", 4) == 0) {
pLine += 4; pLine += 4;
cVal = (unsigned char)((atof(pLine) * 10.0) + 0.5); cVal = (unsigned char)((atof(pLine) * 10.0) + 0.5);
pNVStorage->setPmax(cVal); pNVStorage->setPmax(cVal);
DebugPort.print("Pump max = "); PRNT.print("Pump max = ");
DebugPort.println(cVal); PRNT.println(cVal);
} }
else if(strncmp(pLine, "Fmin", 4) == 0) { else if(strncmp(pLine, "Fmin", 4) == 0) {
pLine += 4; pLine += 4;
sVal = atoi(pLine); sVal = atoi(pLine);
pNVStorage->setFmin(sVal); pNVStorage->setFmin(sVal);
DebugPort.print("Fan min = "); PRNT.print("Fan min = ");
DebugPort.println(sVal); PRNT.println(sVal);
} }
else if(strncmp(pLine, "Fmax", 4) == 0) { else if(strncmp(pLine, "Fmax", 4) == 0) {
pLine += 4; pLine += 4;
sVal = atoi(pLine); sVal = atoi(pLine);
pNVStorage->setFmax(sVal); pNVStorage->setFmax(sVal);
DebugPort.print("Fan max = "); PRNT.print("Fan max = ");
DebugPort.println(int(sVal)); PRNT.println(int(sVal));
} }
else if(strncmp(pLine, "save", 4) == 0) { else if(strncmp(pLine, "save", 4) == 0) {
pNVStorage->save(); pNVStorage->save();
DebugPort.println("NV save"); PRNT.println("NV save");
} }
else if(strncmp(pLine, "degC", 4) == 0) { else if(strncmp(pLine, "degC", 4) == 0) {
pLine += 4; pLine += 4;
cVal = atoi(pLine); cVal = atoi(pLine);
pNVStorage->setTemperature(cVal); pNVStorage->setTemperature(cVal);
DebugPort.print("degC = "); PRNT.print("degC = ");
DebugPort.println(cVal); PRNT.println(cVal);
} }
else if(strncmp(pLine, "Mode", 4) == 0) { else if(strncmp(pLine, "Mode", 4) == 0) {
pLine += 4; pLine += 4;
cVal = !pNVStorage->getThermostatMode(); cVal = !pNVStorage->getThermostatMode();
pNVStorage->setThermostatMode(cVal); pNVStorage->setThermostatMode(cVal);
DebugPort.print("Mode now "); PRNT.print("Mode now ");
DebugPort.println(cVal ? "Thermostat" : "Fixed Hz"); PRNT.println(cVal ? "Thermostat" : "Fixed Hz");
} }
else { else {
DebugPort.print(pLine); PRNT.print(pLine);
DebugPort.println(" ????"); PRNT.println(" ????");
} }
} }