From 44ef6a8f84511b93088ec9b53c981c4ad387c870 Mon Sep 17 00:00:00 2001 From: cheetah Date: Sun, 30 Mar 2025 22:31:59 +0200 Subject: [PATCH] fixed RST pin and umaluts --- include/board.h | 2 +- src/main.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/include/board.h b/include/board.h index bfe6695..c823adb 100644 --- a/include/board.h +++ b/include/board.h @@ -8,4 +8,4 @@ #define LORA_DIO2 34 #undef LORA_RST -#define LORA_RST 14 \ No newline at end of file +#define LORA_RST 23 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index b0a14a9..f26ac56 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -269,6 +269,25 @@ UmlautMap umlautMapIntl[] = { {0xFC, 0x75}, {0xE4, 0x61}, {0xF6, 0x6F}, {0xDF, 0x73} }; +void printHex(const char* text) { + while (*text) { + if ((uint8_t)*text < 0x10) { + Serial.print("0"); // Ensure two-digit hex format + } + Serial.print((uint8_t)*text, HEX); + Serial.print(" "); + text++; + } + Serial.println(); +} +void replaceStringWithChar(String &input, const String &find, char replace) { + int index = input.indexOf(find); // Find the first occurrence + while (index != -1) { + input = input.substring(0, index) + replace + input.substring(index + find.length()); + index = input.indexOf(find, index + 1); // Find next occurrence + } +} + String txHandleUmlauts(String input) { bool useGermanMap = globcfg.pocsag_german; UmlautMap* map = useGermanMap ? umlautMapGermany : umlautMapIntl; @@ -277,6 +296,23 @@ String txHandleUmlauts(String input) { for (int i = 0; i < mapSize; i++) { input.replace(map[i].utf8, map[i].replacement); } + if (useGermanMap) { + replaceStringWithChar(input, "Ä", '['); + replaceStringWithChar(input, "Ö", '\\'); + replaceStringWithChar(input, "Ü", ']'); + replaceStringWithChar(input, "ä", '{'); + replaceStringWithChar(input, "ö", '|'); + replaceStringWithChar(input, "ü", '}'); + replaceStringWithChar(input, "ß", '~'); + } else { + replaceStringWithChar(input, "Ä", 'A'); + replaceStringWithChar(input, "Ö", 'O'); + replaceStringWithChar(input, "Ü", 'U'); + replaceStringWithChar(input, "ä", 'a'); + replaceStringWithChar(input, "ö", 'o'); + replaceStringWithChar(input, "ü", 'u'); + replaceStringWithChar(input, "ß", 's'); + } return input; } void txControllerInsert(uint32_t ric, uint8_t functionBit, char *text) @@ -307,7 +343,7 @@ Timezone localTime; bool time_beacon_first = true; unsigned long lastTimeBeaconTime = 0; - +String currentMessage; String formattedTime; char *idleBeaconText = new char[1]{}; bool idle_beacon_first = true; @@ -344,12 +380,16 @@ void broadcast_loop() dwdClient.loop(); if (dwdClient.isDirty()) { - dwdClient.currentMessage = txHandleUmlauts(dwdClient.currentMessage); - char *messageText = new char[dwdClient.currentMessage.length() + 1]{}; - dwdClient.currentMessage.toCharArray(messageText, dwdClient.currentMessage.length() + 1); + currentMessage = txHandleUmlauts(dwdClient.currentMessage); + Serial.print("Hex: "); + printHex(currentMessage.c_str()); + char *messageText = new char[currentMessage.length() + 1]{}; + currentMessage.toCharArray(messageText, currentMessage.length() + 1); Serial.println(F("[DWD] Transmitting Warning")); + Serial.println(messageText); transmitter.queuePage(globcfg.broadcast_ric, globcfg.dwd_fun + 0, messageText); delete []messageText; + currentMessage.clear(); transmitter.transmitBatch(); } } @@ -358,12 +398,14 @@ void broadcast_loop() mowasClient.loop(); if (mowasClient.isDirty()) { - mowasClient.currentMessage = txHandleUmlauts(mowasClient.currentMessage); - char *messageText = new char[mowasClient.currentMessage.length() + 1]{}; - mowasClient.currentMessage.toCharArray(messageText, mowasClient.currentMessage.length() + 1); + currentMessage = txHandleUmlauts(mowasClient.currentMessage); + char *messageText = new char[currentMessage.length() + 1]{}; + currentMessage.toCharArray(messageText, currentMessage.length() + 1); Serial.println(F("[MoWaS] Transmitting Warning")); + Serial.println(messageText); transmitter.queuePage(globcfg.broadcast_ric, globcfg.mowas_fun + 0, messageText); delete []messageText; + currentMessage.clear(); transmitter.transmitBatch(); } }