Added support for GSP, DS003a, DS003c and added printIPAddress functionality

This commit is contained in:
Julian Metzler 2018-02-13 20:27:10 +01:00
parent 94c553f824
commit 25f5136013
4 changed files with 95 additions and 3 deletions

View File

@ -61,7 +61,7 @@ enum UpdateStatus {
*/ */
unsigned long HW_GROUP = 1; // Changes with hardware changes that require software changes unsigned long HW_GROUP = 1; // Changes with hardware changes that require software changes
unsigned long FW_VERSION = 1802120001; // Changes with each release; must always increase unsigned long FW_VERSION = 1802130009; // Changes with each release; must always increase
unsigned long SP_VERSION = 0; // Loaded from SPIFFS; changed with each SPIFFS build; must always increase (uses timestamp as version) unsigned long SP_VERSION = 0; // Loaded from SPIFFS; changed with each SPIFFS build; must always increase (uses timestamp as version)
// HTTPS update settings // HTTPS update settings
@ -357,7 +357,7 @@ void ISR_config() {
} }
/* /*
MAIN PROGRAM ROUTINES PROGRAM ROUTINES
*/ */
void doWiFiConfigViaWPS() { void doWiFiConfigViaWPS() {
@ -384,6 +384,24 @@ void doWiFiConfigViaAP() {
setLED(1); setLED(1);
} }
void printIPAddress() {
// TODO: Stops working after the first time
IPAddress addr = WiFi.localIP();
String addrStr;
addrStr += String(addr[0]);
addrStr += ".";
addrStr += String(addr[1]);
addrStr += ".";
addrStr += String(addr[2]);
addrStr += ".";
addrStr += String(addr[3]);
IBIS_DS009(addrStr);
}
/*
FIRMWARE & SPIFFS UPDATE
*/
UpdateStatus checkForFWUpdate() { UpdateStatus checkForFWUpdate() {
/*WiFiClientSecure httpsClient; /*WiFiClientSecure httpsClient;
if (!httpsClient.connect(UPDATE_HOST.c_str(), UPDATE_PORT)) { if (!httpsClient.connect(UPDATE_HOST.c_str(), UPDATE_PORT)) {
@ -451,6 +469,10 @@ void doSPUpdate() {
t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs(url); t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs(url);
} }
/*
MAIN PROGRAM
*/
void setup() { void setup() {
pinMode(PIN_STATUS, OUTPUT); pinMode(PIN_STATUS, OUTPUT);
pinMode(PIN_CONFIG, INPUT_PULLUP); pinMode(PIN_CONFIG, INPUT_PULLUP);
@ -567,6 +589,11 @@ void loop() {
doWiFiConfigViaAP(); doWiFiConfigViaAP();
break; break;
} }
case 3: {
// AP mode
printIPAddress();
break;
}
default: { default: {
break; break;
} }

Binary file not shown.

View File

@ -1 +1 @@
1802120001 1802130009

65
ibis.h
View File

@ -12,6 +12,18 @@ void IBIS_processSpecialCharacters(String* telegram) {
telegram->replace("Ü", "]"); telegram->replace("Ü", "]");
} }
String IBIS_vdvHex(byte value) {
String vdvHexCharacters = "0123456789:;<=>?";
String vdvHexValue;
byte highNibble = value >> 4;
byte lowNibble = value & 15;
if (highNibble > 0) {
vdvHexValue += vdvHexCharacters.charAt(highNibble);
}
vdvHexValue += vdvHexCharacters.charAt(lowNibble);
return vdvHexValue;
}
String IBIS_wrapTelegram(String telegram) { String IBIS_wrapTelegram(String telegram) {
telegram += '\x0d'; telegram += '\x0d';
unsigned char checksum = 0x7F; unsigned char checksum = 0x7F;
@ -30,8 +42,61 @@ void IBIS_sendTelegram(String telegram) {
Serial.print(telegram); Serial.print(telegram);
} }
void IBIS_DS003a(String text) {
String telegram;
byte numBlocks = ceil(text.length() / 16.0);
telegram = "zA";
telegram += IBIS_vdvHex(numBlocks);
telegram += text;
byte remainder = text.length() % 16;
if (remainder > 0) {
for (byte i = 16; i > remainder; i--) {
telegram += " ";
}
}
IBIS_sendTelegram(telegram);
}
void IBIS_DS003c(String text) {
String telegram;
byte numBlocks = ceil(text.length() / 4.0);
telegram = "zI";
telegram += IBIS_vdvHex(numBlocks);
telegram += text;
byte remainder = text.length() % 4;
if (remainder > 0) {
for (byte i = 4; i > remainder; i--) {
telegram += " ";
}
}
IBIS_sendTelegram(telegram);
}
void IBIS_DS009(String text) { void IBIS_DS009(String text) {
String telegram = "v" + text; String telegram = "v" + text;
IBIS_sendTelegram(telegram); IBIS_sendTelegram(telegram);
} }
void IBIS_GSP(byte address, String line1, String line2) {
String telegram;
String lines;
lines += line1;
if (line2.length() > 0) {
lines += "\x0a";
}
lines += line2;
lines += "\x0a\x0a";
byte numBlocks = ceil(lines.length() / 16.0);
byte remainder = lines.length() % 16;
if (remainder > 0) {
for (byte i = 16; i > remainder; i--) {
lines += " ";
}
}
telegram = "aA";
telegram += IBIS_vdvHex(address);
telegram += IBIS_vdvHex(numBlocks);
telegram += lines;
IBIS_sendTelegram(telegram);
}