diff --git a/WiFi_Shield.ino b/WiFi_Shield.ino index 778eaa9..d1bb26a 100644 --- a/WiFi_Shield.ino +++ b/WiFi_Shield.ino @@ -61,7 +61,7 @@ enum UpdateStatus { */ 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) // HTTPS update settings @@ -357,7 +357,7 @@ void ISR_config() { } /* - MAIN PROGRAM ROUTINES + PROGRAM ROUTINES */ void doWiFiConfigViaWPS() { @@ -384,6 +384,24 @@ void doWiFiConfigViaAP() { 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() { /*WiFiClientSecure httpsClient; if (!httpsClient.connect(UPDATE_HOST.c_str(), UPDATE_PORT)) { @@ -451,6 +469,10 @@ void doSPUpdate() { t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs(url); } +/* + MAIN PROGRAM +*/ + void setup() { pinMode(PIN_STATUS, OUTPUT); pinMode(PIN_CONFIG, INPUT_PULLUP); @@ -567,6 +589,11 @@ void loop() { doWiFiConfigViaAP(); break; } + case 3: { + // AP mode + printIPAddress(); + break; + } default: { break; } diff --git a/firmware.bin b/firmware.bin index 17fd249..eb757eb 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.version b/firmware.version index 6cbc7f9..23df24b 100644 --- a/firmware.version +++ b/firmware.version @@ -1 +1 @@ -1802120001 \ No newline at end of file +1802130009 \ No newline at end of file diff --git a/ibis.h b/ibis.h index fec5e95..b8a9831 100644 --- a/ibis.h +++ b/ibis.h @@ -12,6 +12,18 @@ void IBIS_processSpecialCharacters(String* telegram) { 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) { telegram += '\x0d'; unsigned char checksum = 0x7F; @@ -30,8 +42,61 @@ void IBIS_sendTelegram(String 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) { String telegram = "v" + text; 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); +} +