Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
softwarecrash committed Sep 1, 2022
1 parent cd36535 commit cc85688
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions src/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
#include <Arduino.h>
#include <EEPROM.h>

//#define SERIALDEBUG //enable Serial Output for debug
#define MQTTDEBUG //enable debug / RAW Messages from iverter to MQTT

class Settings
{
public:
bool _valid = false;
//MQTT Settings
bool _mqttJson = false;
//String _deviceType = "PIP"; //PIP | PCM | MPI
String _deviceName = ""; //name of the device
String _mqttServer = ""; //host or ip from the mqtt server
String _mqttUser = ""; //mqtt username to login
Expand Down Expand Up @@ -57,31 +53,13 @@ class Settings
maxLen--;
if ((int)s.length() < maxLen - 1)
maxLen = s.length();
#ifdef SERIALDEBUG
Serial1.print("Writing ");
Serial1.print(maxLen);
Serial1.print(" ");
Serial1.print(offset);
Serial1.print(" ");
Serial1.println(s);
#endif

for (i = 0; i < maxLen; ++i)
{
EEPROM.write(offset + i, s[i]);
#ifdef SERIALDEBUG
Serial1.print(" ");
Serial1.print(offset + i);
Serial1.print("=");
Serial1.print(s[i]);
Serial1.print(",");
#endif
}
//null terminate the string
EEPROM.write(offset + i, 0);
#ifdef SERIALDEBUG
Serial1.print(offset + i);
#endif
}

void load()
Expand All @@ -98,9 +76,8 @@ class Settings
{
_mqttRefresh = readShort(0x20);
readString(_mqttTopic, 0x20, 0x40);
if(readShort(0x60) == 10) _mqttJson = true; //remove when rework
if(readShort(0x60) == 00) _mqttJson = false; //remove when rework
//_mqttJson = readShort(0x60/*, 0x60*/)?true:false;//testing
if(readShort(0x60) == 10) _mqttJson = true;
if(readShort(0x60) == 00) _mqttJson = false;
readString(_deviceName, 0x20, 0x80);
readString(_mqttServer, 0x20, 0xA0);
readString(_mqttPassword, 0x20, 0xC0);
Expand All @@ -122,9 +99,8 @@ class Settings

writeShort(_mqttRefresh, 0x20);
writeString(_mqttTopic, 0x20, 0x40);
if(_mqttJson == true) writeShort((10), 0x60); //remove when rework
if(_mqttJson == false) writeShort((00), 0x60); //remove when rework
//writeShort((_mqttJson?1:0), 0x60/*, 0x60*/);//testing
if(_mqttJson == true) writeShort((10), 0x60);
if(_mqttJson == false) writeShort((00), 0x60);
writeString(_deviceName, 0x20, 0x80);
writeString(_mqttServer, 0x20, 0xA0);
writeString(_mqttPassword, 0x20, 0xC0);
Expand Down

0 comments on commit cc85688

Please sign in to comment.