Compare commits
	
		
			10 Commits
		
	
	
		
			1.06
			...
			cbcdc34e6c
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| cbcdc34e6c | |||
| 48774a42f4 | |||
| 73c486be73 | |||
| 6574947a80 | |||
| 956cc49e6f | |||
| b1da9449ad | |||
| e54cadcc7c | |||
| 0b2245d7f6 | |||
| 3ceab44a96 | |||
| 91de9f0785 | 
							
								
								
									
										1
									
								
								Software/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								Software/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,4 +1,5 @@ | |||||||
| data/ | data/ | ||||||
|  | data_src/version | ||||||
| .pio | .pio | ||||||
| .vscode/.browse.c_cpp.db* | .vscode/.browse.c_cpp.db* | ||||||
| .vscode/c_cpp_properties.json | .vscode/c_cpp_properties.json | ||||||
|   | |||||||
| @@ -215,30 +215,36 @@ | |||||||
|             <div class="form-group row"> |             <div class="form-group row"> | ||||||
|               <label for="name_faction1" class="control-label col-4">Faktion 1</label> |               <label for="name_faction1" class="control-label col-4">Faktion 1</label> | ||||||
|               <div class="col-8"> |               <div class="col-8"> | ||||||
|  |                 <div class="input-group"> | ||||||
|                   <input id="name_faction1" type="text" class="set-wsevent data-name_faction1 form-control" required="required"> |                   <input id="name_faction1" type="text" class="set-wsevent data-name_faction1 form-control" required="required"> | ||||||
|                   <div class="input-group-append"> |                   <div class="input-group-append"> | ||||||
|                     <span class="input-group-text">max. 32 Zeichen</span> |                     <span class="input-group-text">max. 32 Zeichen</span> | ||||||
|                   </div> |                   </div> | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
|  |             </div> | ||||||
|             <div class="form-group row"> |             <div class="form-group row"> | ||||||
|               <label for="name_faction2" class="control-label col-4">Faktion 2</label> |               <label for="name_faction2" class="control-label col-4">Faktion 2</label> | ||||||
|               <div class="col-8"> |               <div class="col-8"> | ||||||
|  |                 <div class="input-group"> | ||||||
|                   <input id="name_faction2" type="text" class="set-wsevent data-name_faction2 form-control" required="required"> |                   <input id="name_faction2" type="text" class="set-wsevent data-name_faction2 form-control" required="required"> | ||||||
|                   <div class="input-group-append"> |                   <div class="input-group-append"> | ||||||
|                     <span class="input-group-text">max. 32 Zeichen</span> |                     <span class="input-group-text">max. 32 Zeichen</span> | ||||||
|                   </div> |                   </div> | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
|  |             </div> | ||||||
|             <div class="form-group row"> |             <div class="form-group row"> | ||||||
|               <label for="name_faction3" class="control-label col-4">Faktion 3</label> |               <label for="name_faction3" class="control-label col-4">Faktion 3</label> | ||||||
|               <div class="col-8"> |               <div class="col-8"> | ||||||
|  |                 <div class="input-group"> | ||||||
|                   <input id="name_faction3" type="text" class="set-wsevent data-name_faction3 form-control" required="required"> |                   <input id="name_faction3" type="text" class="set-wsevent data-name_faction3 form-control" required="required"> | ||||||
|                   <div class="input-group-append"> |                   <div class="input-group-append"> | ||||||
|                     <span class="input-group-text">max. 32 Zeichen</span> |                     <span class="input-group-text">max. 32 Zeichen</span> | ||||||
|                   </div> |                   </div> | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
|  |             </div> | ||||||
|           <!-- Div Group Timer Settings --> |           <!-- Div Group Timer Settings --> | ||||||
|         <!-- Div Group Save Button--> |         <!-- Div Group Save Button--> | ||||||
|         <hr /> |         <hr /> | ||||||
| @@ -267,15 +273,15 @@ | |||||||
|           </tr> |           </tr> | ||||||
|           <tr> |           <tr> | ||||||
|             <td>Firmware Version</td> |             <td>Firmware Version</td> | ||||||
|             <td>%SW_VERSION%</td> |             <td><span class="data-fw-version"></span></td> | ||||||
|           </tr> |           </tr> | ||||||
|           <tr> |           <tr> | ||||||
|             <td>Flash Version</td> |             <td>Flash Version</td> | ||||||
|             <td>%FS_VERSION%</td> |             <td><span class="data-flash-version"></span></td> | ||||||
|           </tr> |           </tr> | ||||||
|           <tr> |           <tr> | ||||||
|             <td>Git Revision</td> |             <td>Git Revision</td> | ||||||
|             <td>%GIT_REV%</td> |             <td><span class="data-git-revision"></span></td> | ||||||
|           </tr> |           </tr> | ||||||
|       </table> |       </table> | ||||||
|       </p> |       </p> | ||||||
|   | |||||||
| @@ -1 +0,0 @@ | |||||||
| 1.06 |  | ||||||
| @@ -82,7 +82,7 @@ const configData_t ConfigData_defaults = { | |||||||
|     "FACTION 1",     // Faction_1_Name |     "FACTION 1",     // Faction_1_Name | ||||||
|     "FACTION 2",     // Faction_2_Name |     "FACTION 2",     // Faction_2_Name | ||||||
|     "FACTION 3",     // Faction_3_Name |     "FACTION 3",     // Faction_3_Name | ||||||
|     "ArisoftTimer", |     HOST_NAME, | ||||||
|     QUOTE(WIFI_AP_PASSWORD), |     QUOTE(WIFI_AP_PASSWORD), | ||||||
|     QUOTE(WIFI_SSID_CLIENT), |     QUOTE(WIFI_SSID_CLIENT), | ||||||
|     QUOTE(WIFI_PASSWORD_CLIENT), |     QUOTE(WIFI_PASSWORD_CLIENT), | ||||||
| @@ -102,7 +102,6 @@ uint32_t Checksum_EEPROM(uint8_t const *data, size_t len); | |||||||
| void dumpEEPROM(uint16_t memoryAddress, uint16_t length); | void dumpEEPROM(uint16_t memoryAddress, uint16_t length); | ||||||
| void MovePersistencePage_EEPROM(boolean reset); | void MovePersistencePage_EEPROM(boolean reset); | ||||||
| uint32_t ConfigSanityCheck(bool autocorrect = false); | uint32_t ConfigSanityCheck(bool autocorrect = false); | ||||||
| bool validateWiFiString(char *string, size_t size); |  | ||||||
| void writeSequentialToEEPROM(uint16_t memoryAddress, uint16_t length); | void writeSequentialToEEPROM(uint16_t memoryAddress, uint16_t length); | ||||||
| void writeZeroToEEPROM(uint16_t memoryAddress, uint16_t length); | void writeZeroToEEPROM(uint16_t memoryAddress, uint16_t length); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ typedef struct Globals_s | |||||||
|   tSystem_Status resumeStatus = sysStat_Startup; /**< Status to resume after rain mode */ |   tSystem_Status resumeStatus = sysStat_Startup; /**< Status to resume after rain mode */ | ||||||
|   char systemStatustxt[16] = "";                 /**< Text representation of system status */ |   char systemStatustxt[16] = "";                 /**< Text representation of system status */ | ||||||
|   EERequest_t requestEEAction = EE_IDLE;         /**< EEPROM-related request */ |   EERequest_t requestEEAction = EE_IDLE;         /**< EEPROM-related request */ | ||||||
|   char DeviceName[33];                           /**< Device name */ |   char DeviceName[25];                           /**< Device name */ | ||||||
|   char DeviceNameId[sizeof(DeviceName) + 8];     /**< Device name plus 8 chars chipID */ |   char DeviceNameId[sizeof(DeviceName) + 8];     /**< Device name plus 8 chars chipID */ | ||||||
|   char FlashVersion[10];                         /**< Flash version */ |   char FlashVersion[10];                         /**< Flash version */ | ||||||
|   uint16_t eePersistanceAdress;                  /**< EEPROM persistence address */ |   uint16_t eePersistanceAdress;                  /**< EEPROM persistence address */ | ||||||
|   | |||||||
							
								
								
									
										36
									
								
								Software/include/utilities.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								Software/include/utilities.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | |||||||
|  | #ifndef UTILITIES_H | ||||||
|  | #define UTILITIES_H | ||||||
|  |  | ||||||
|  | #include <Arduino.h> | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @brief Validates whether a given string contains only characters allowed in WiFi SSIDs and passwords. | ||||||
|  |  * | ||||||
|  |  * This function checks each character in the provided string to ensure | ||||||
|  |  * that it contains only characters allowed in WiFi SSIDs and passwords. | ||||||
|  |  * It considers characters from 'A' to 'Z', 'a' to 'z', '0' to '9', as well as | ||||||
|  |  * the following special characters: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ | ||||||
|  |  * | ||||||
|  |  * @param string Pointer to the string to be validated. | ||||||
|  |  * @param size Size of the string including the null-terminator. | ||||||
|  |  * @return true if the string contains only allowed characters or is NULL, | ||||||
|  |  *         false otherwise. | ||||||
|  |  */ | ||||||
|  | bool validateWiFiString(char *string, size_t size); | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @brief Copies a string to a buffer, replacing invalid WiFi SSID characters with a placeholder. | ||||||
|  |  * | ||||||
|  |  * This function checks each character in the provided input string to ensure | ||||||
|  |  * that it contains only characters allowed in WiFi SSIDs and passwords. If a character | ||||||
|  |  * is invalid, it replaces it with a placeholder character (e.g., '_'). | ||||||
|  |  * It considers characters from 'A' to 'Z', 'a' to 'z', '0' to '9', as well as | ||||||
|  |  * the following special characters: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ | ||||||
|  |  * | ||||||
|  |  * @param input Pointer to the input string to be validated and copied. | ||||||
|  |  * @param buffer Pointer to the buffer where the output string will be copied. | ||||||
|  |  * @param bufferSize Size of the buffer including the null-terminator. | ||||||
|  |  */ | ||||||
|  | void sanitizeWiFiString(const char *input, char *buffer, size_t bufferSize); | ||||||
|  |  | ||||||
|  | #endif // UTILITIES_H | ||||||
| @@ -17,8 +17,8 @@ platform = espressif8266 | |||||||
| framework = arduino | framework = arduino | ||||||
| board = d1_mini | board = d1_mini | ||||||
|  |  | ||||||
| custom_firmware_version = 1.06  | custom_firmware_version = 1.07 | ||||||
| custom_flash_version = 1.06 | custom_flash_version = 1.07 | ||||||
|  |  | ||||||
| upload_protocol = esptool | upload_protocol = esptool | ||||||
| upload_speed = 921600 | upload_speed = 921600 | ||||||
| @@ -29,7 +29,7 @@ upload_speed = 921600 | |||||||
|  |  | ||||||
| build_flags= | build_flags= | ||||||
|   -DATOMIC_FS_UPDATE |   -DATOMIC_FS_UPDATE | ||||||
|   -DFEATURE_ENABLE_WIFI_CLIENT |   ;-DFEATURE_ENABLE_WIFI_CLIENT | ||||||
|   ;-DFEATURE_ENABLE_LORA |   ;-DFEATURE_ENABLE_LORA | ||||||
|   -DFEATURE_ENABLE_UARTLORA |   -DFEATURE_ENABLE_UARTLORA | ||||||
|   -DWIFI_AP_IP_GW=10,0,0,1 |   -DWIFI_AP_IP_GW=10,0,0,1 | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ | |||||||
| const char *BatteryString[] = { | const char *BatteryString[] = { | ||||||
|     "Undefined", |     "Undefined", | ||||||
|     "LiPo 2S", |     "LiPo 2S", | ||||||
|     "LiPo 3S"}; |     "LiPo 3S" | ||||||
|  |     }; | ||||||
|  |  | ||||||
| const size_t BatteryString_Elements = sizeof(BatteryString) / sizeof(BatteryString[0]); | const size_t BatteryString_Elements = sizeof(BatteryString) / sizeof(BatteryString[0]); | ||||||
| @@ -15,7 +15,17 @@ | |||||||
|  |  | ||||||
| DebugStatus_t DebuggerStatus[dbg_cntElements]; | DebugStatus_t DebuggerStatus[dbg_cntElements]; | ||||||
|  |  | ||||||
| void processCmdDebug(String command); | // Funktionszeiger | ||||||
|  | typedef void (*CommandFunction)(); | ||||||
|  |  | ||||||
|  | // Struktur zur Zuordnung von Commands zu Funktionen | ||||||
|  | struct CommandMapping | ||||||
|  | { | ||||||
|  |     const char *command; | ||||||
|  |     CommandFunction function; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | void processCmdDebug(const char *command); | ||||||
| void Debug_formatCFG(); | void Debug_formatCFG(); | ||||||
| void Debug_formatPersistence(); | void Debug_formatPersistence(); | ||||||
| void Debug_printSystemInfo(); | void Debug_printSystemInfo(); | ||||||
| @@ -26,8 +36,97 @@ void Debug_dumpPersistance(); | |||||||
| void Debug_ShowDTCs(); | void Debug_ShowDTCs(); | ||||||
| void Debug_dumpGlobals(); | void Debug_dumpGlobals(); | ||||||
| void Debug_printHelp(); | void Debug_printHelp(); | ||||||
|  | void Debug_Reboot(); | ||||||
| const char *uint32_to_binary_string(uint32_t num); | const char *uint32_to_binary_string(uint32_t num); | ||||||
|  |  | ||||||
|  | // Adapter-Functions for Debug-Commands | ||||||
|  | void adapterCheckEEPOM() { Debug_CheckEEPOM(false); } | ||||||
|  | void adapterCheckEEPOMFix() { Debug_CheckEEPOM(true); } | ||||||
|  | void adapterDumpEEPROM1k() { dumpEEPROM(0, 1024); } | ||||||
|  | void adapterDumpEEPROMAll() { dumpEEPROM(0, EEPROM_SIZE_BYTES); } | ||||||
|  | void adapterKillEEPROM() { writeSequentialToEEPROM(0, 1024); } | ||||||
|  | void adapterZeroEEPROM() { writeZeroToEEPROM(0, 1024); } | ||||||
|  | void adapterResetPageEEPROM() { MovePersistencePage_EEPROM(true); } | ||||||
|  | void adapterSaveEEPROM() { globals.requestEEAction = EE_ALL_SAVE; } | ||||||
|  | void adapterSetDebugPort() { SetDebugportStatus(dbg_Serial, enabled); } | ||||||
|  | void adapterCritDTC() { MaintainDTC(DTC_FAKE_DTC_CRIT, true, millis()); } | ||||||
|  | void adapterWarnDTC() { MaintainDTC(DTC_FAKE_DTC_WARN, true, millis()); } | ||||||
|  | void adapterInfoDTC() { MaintainDTC(DTC_FAKE_DTC_INFO, true, millis()); } | ||||||
|  | void adapterNotifyError() { Websocket_PushNotification("Debug Error Notification", error); } | ||||||
|  | void adapterNotifyWarning() { Websocket_PushNotification("Debug Warning Notification", warning); } | ||||||
|  | void adapterNotifySuccess() { Websocket_PushNotification("Debug Success Notification", success); } | ||||||
|  | void adapterNotifyInfo() { Websocket_PushNotification("Debug Info Notification", info); } | ||||||
|  |  | ||||||
|  | // Definition der Command-Mapping-Tabelle | ||||||
|  | const CommandMapping commandMappings[] = { | ||||||
|  |     {"help", Debug_printHelp}, | ||||||
|  |     {"reboot", Debug_Reboot}, | ||||||
|  |     {"sysinfo", Debug_printSystemInfo}, | ||||||
|  |     {"netinfo", Debug_printWifiInfo}, | ||||||
|  |     {"formatCFG", Debug_formatCFG}, | ||||||
|  |     {"formatPDS", Debug_formatPersistence}, | ||||||
|  |     {"checkEE", adapterCheckEEPOM}, | ||||||
|  |     {"checkEEfix", adapterCheckEEPOMFix}, | ||||||
|  |     {"dumpEE1k", adapterDumpEEPROM1k}, | ||||||
|  |     {"dumpEE", adapterDumpEEPROMAll}, | ||||||
|  |     {"killEE", adapterKillEEPROM}, | ||||||
|  |     {"zeroEE", adapterZeroEEPROM}, | ||||||
|  |     {"resetPageEE", adapterResetPageEEPROM}, | ||||||
|  |     {"dumpCFG", Debug_dumpConfig}, | ||||||
|  |     {"dumpPDS", Debug_dumpPersistance}, | ||||||
|  |     {"saveEE", adapterSaveEEPROM}, | ||||||
|  |     {"dumpGlobals", Debug_dumpGlobals}, | ||||||
|  |     {"sdbg", adapterSetDebugPort}, | ||||||
|  |     {"dtc_show", Debug_ShowDTCs}, | ||||||
|  |     {"dtc_clear", ClearAllDTC}, | ||||||
|  |     {"dtc_crit", adapterCritDTC}, | ||||||
|  |     {"dtc_warn", adapterWarnDTC}, | ||||||
|  |     {"dtc_info", adapterInfoDTC}, | ||||||
|  |     {"notify_error", adapterNotifyError}, | ||||||
|  |     {"notify_warning", adapterNotifyWarning}, | ||||||
|  |     {"notify_success", adapterNotifySuccess}, | ||||||
|  |     {"notify_info", adapterNotifyInfo}, | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | const size_t NUM_COMMANDS = sizeof(commandMappings) / sizeof(commandMappings[0]); | ||||||
|  |  | ||||||
|  | const char helpText[][64] PROGMEM = { | ||||||
|  |     "help           - Print this help text", | ||||||
|  |     "sysinfo        - System Info", | ||||||
|  |     "reboot         - System Reboot", | ||||||
|  |     "netinfo        - WiFi Info", | ||||||
|  |     "formatPDS      - Format Persistence EEPROM Data", | ||||||
|  |     "formatCFG      - Format Configuration EEPROM Data", | ||||||
|  |     "checkEE        - Check EEPROM with checksum", | ||||||
|  |     "checkEEfix     - Check and fix EEPROM with checksum", | ||||||
|  |     "dumpEE1k       - Dump the first 1kb of EEPROM to Serial", | ||||||
|  |     "dumpEE         - Dump the whole EEPROM to Serial", | ||||||
|  |     "killEE         - Kill the first 1024 bytes of EEPROM", | ||||||
|  |     "zeroEE         - Zero the first 1024 bytes of EEPROM", | ||||||
|  |     "resetPageEE    - Reset the PersistenceData Page", | ||||||
|  |     "dumpCFG        - Print Config struct", | ||||||
|  |     "dumpPDS        - Print PersistenceStruct", | ||||||
|  |     "saveEE         - Save EE-Data", | ||||||
|  |     "dumpGlobals    - Print globals", | ||||||
|  |     "sdbg           - Set debug port status", | ||||||
|  |     "dtc_show       - Show all DTCs", | ||||||
|  |     "dtc_clear      - Clear all DTCs", | ||||||
|  |     "dtc_crit       - Maintain critical DTC", | ||||||
|  |     "dtc_warn       - Maintain warning DTC", | ||||||
|  |     "dtc_info       - Maintain info DTC", | ||||||
|  |     "notify_error   - Send error notification", | ||||||
|  |     "notify_warning - Send warning notification", | ||||||
|  |     "notify_success - Send success notification", | ||||||
|  |     "notify_info    - Send info notification" | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | const size_t NUM_HELP_LINES = sizeof(helpText) / sizeof(helpText[0]); | ||||||
|  |  | ||||||
|  | // Überprüfen, ob die Anzahl der Commands und Hilfetext-Zeilen übereinstimmen | ||||||
|  | static_assert(NUM_COMMANDS == NUM_HELP_LINES, "Number of commands and help text lines do not match!"); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * @brief Initializes the debugger by setting the initial status for different debug ports. |  * @brief Initializes the debugger by setting the initial status for different debug ports. | ||||||
|  *        Serial debug output is turned off. |  *        Serial debug output is turned off. | ||||||
| @@ -109,7 +208,7 @@ void Debug_Process() | |||||||
|         break; |         break; | ||||||
|  |  | ||||||
|     case CMD_COMPLETE: |     case CMD_COMPLETE: | ||||||
|         processCmdDebug(String(inputBuffer)); |         processCmdDebug(inputBuffer); | ||||||
|         break; |         break; | ||||||
|  |  | ||||||
|     case CMD_OVERFLOW: |     case CMD_OVERFLOW: | ||||||
| @@ -184,66 +283,23 @@ void Debug_pushMessage(const char *format, ...) | |||||||
|  * |  * | ||||||
|  * @param command The debug command to be processed. |  * @param command The debug command to be processed. | ||||||
|  */ |  */ | ||||||
| void processCmdDebug(String command) | void processCmdDebug(const char *command) | ||||||
|  | { | ||||||
|  |     bool commandFound = false; | ||||||
|  |     for (size_t i = 0; i < NUM_COMMANDS; ++i) | ||||||
|  |     { | ||||||
|  |         if (strcmp(command, commandMappings[i].command) == 0) | ||||||
|  |         { | ||||||
|  |             commandMappings[i].function(); | ||||||
|  |             commandFound = true; | ||||||
|  |             break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     if (!commandFound) | ||||||
|     { |     { | ||||||
|     // Check the received command and execute corresponding actions |  | ||||||
|     if (command == "help") |  | ||||||
|         Debug_printHelp(); |  | ||||||
|     else if (command == "reboot") |  | ||||||
|         globals.systemStatus = sysStat_Shutdown; |  | ||||||
|     else if (command == "sysinfo") |  | ||||||
|         Debug_printSystemInfo(); |  | ||||||
|     else if (command == "netinfo") |  | ||||||
|         Debug_printWifiInfo(); |  | ||||||
|     else if (command == "formatCFG") |  | ||||||
|         Debug_formatCFG(); |  | ||||||
|     else if (command == "formatPDS") |  | ||||||
|         Debug_formatPersistence(); |  | ||||||
|     else if (command == "checkEE") |  | ||||||
|         Debug_CheckEEPOM(false); |  | ||||||
|     else if (command == "checkEEfix") |  | ||||||
|         Debug_CheckEEPOM(true); |  | ||||||
|     else if (command == "dumpEE1k") |  | ||||||
|         dumpEEPROM(0, 1024); |  | ||||||
|     else if (command == "dumpEE") |  | ||||||
|         dumpEEPROM(0, EEPROM_SIZE_BYTES); |  | ||||||
|     else if (command == "killEE") |  | ||||||
|         writeSequentialToEEPROM(0, 1024); |  | ||||||
|     else if (command == "zeroEE") |  | ||||||
|         writeZeroToEEPROM(0, 1024); |  | ||||||
|     else if (command == "resetPageEE") |  | ||||||
|         MovePersistencePage_EEPROM(true); |  | ||||||
|     else if (command == "dumpCFG") |  | ||||||
|         Debug_dumpConfig(); |  | ||||||
|     else if (command == "dumpPDS") |  | ||||||
|         Debug_dumpPersistance(); |  | ||||||
|     else if (command == "saveEE") |  | ||||||
|         globals.requestEEAction = EE_ALL_SAVE; |  | ||||||
|     else if (command == "dumpGlobals") |  | ||||||
|         Debug_dumpGlobals(); |  | ||||||
|     else if (command == "sdbg") |  | ||||||
|         SetDebugportStatus(dbg_Serial, enabled); |  | ||||||
|     else if (command == "dtc_show") |  | ||||||
|         Debug_ShowDTCs(); |  | ||||||
|     else if (command == "dtc_clear") |  | ||||||
|         ClearAllDTC(); |  | ||||||
|     else if (command == "dtc_crit") |  | ||||||
|         MaintainDTC(DTC_FAKE_DTC_CRIT, true, millis()); |  | ||||||
|     else if (command == "dtc_warn") |  | ||||||
|         MaintainDTC(DTC_FAKE_DTC_WARN, true, millis()); |  | ||||||
|     else if (command == "dtc_info") |  | ||||||
|         MaintainDTC(DTC_FAKE_DTC_INFO, true, millis()); |  | ||||||
|     else if (command == "notify_error") |  | ||||||
|         Websocket_PushNotification("Debug Error Notification", error); |  | ||||||
|     else if (command == "notify_warning") |  | ||||||
|         Websocket_PushNotification("Debug Warning Notification", warning); |  | ||||||
|     else if (command == "notify_success") |  | ||||||
|         Websocket_PushNotification("Debug Success Notification", success); |  | ||||||
|     else if (command == "notify_info") |  | ||||||
|         Websocket_PushNotification("Debug Info Notification", info); |  | ||||||
|     else |  | ||||||
|         Debug_pushMessage("unknown Command\n"); |         Debug_pushMessage("unknown Command\n"); | ||||||
|     } |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * @brief Formats the Config-EEPROM and resets it to default values. |  * @brief Formats the Config-EEPROM and resets it to default values. | ||||||
| @@ -415,7 +471,7 @@ void Debug_ShowDTCs() | |||||||
|     char buff_active[9]; |     char buff_active[9]; | ||||||
|  |  | ||||||
|     // Header for the DTC display |     // Header for the DTC display | ||||||
|     Debug_pushMessage("\n      timestamp | DTC-Nr. |   status | severity\n"); |     Debug_pushMessage("\n      timestamp | DTC-Nr. |   status | debugval\n"); | ||||||
|  |  | ||||||
|     // Iterate through DTCStorage and display each entry |     // Iterate through DTCStorage and display each entry | ||||||
|     for (uint32_t i = 0; i < MAX_DTC_STORAGE; i++) |     for (uint32_t i = 0; i < MAX_DTC_STORAGE; i++) | ||||||
| @@ -439,31 +495,37 @@ void Debug_ShowDTCs() | |||||||
|                 strcpy(buff_active, "none"); |                 strcpy(buff_active, "none"); | ||||||
|  |  | ||||||
|             // Display DTC information |             // Display DTC information | ||||||
|             Debug_pushMessage("%s   %7d   %8s   %8d\n", buff_timestamp, DTCStorage[i].Number, buff_active); |             Debug_pushMessage("%s   %7d   %8s   %8d\n", buff_timestamp, DTCStorage[i].Number, buff_active, DTCStorage[i].debugVal); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * @brief Displays the help commands for debugging through Serial or WebUI. |  * @brief Prints the help information stored in PROGMEM. | ||||||
|  *        Each command is printed individually in a formatted manner. |  | ||||||
|  */ |  */ | ||||||
| void Debug_printHelp() | void Debug_printHelp() | ||||||
| { | { | ||||||
|     char buff[64]; |     char buffer[64]; | ||||||
|  |     for (size_t i = 0; i < NUM_HELP_LINES; ++i) | ||||||
|     // Iterate through helpCmd and display each command |  | ||||||
|     for (unsigned int i = 0; i < sizeof(helpCmd) / 63; i++) |  | ||||||
|     { |     { | ||||||
|         // Copy a portion of helpCmd to buff for display |         strcpy_P(buffer, (PGM_P)pgm_read_word(&(helpText[i]))); | ||||||
|         memcpy_P(buff, (helpCmd + (i * 63)), 63); |  | ||||||
|         buff[63] = 0; |  | ||||||
|  |  | ||||||
|         // Display the help command |         // Display the help command | ||||||
|         Debug_pushMessage(buff); |         Debug_pushMessage(buffer); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @brief Initiates a system reboot by setting the system status to shutdown. | ||||||
|  |  * | ||||||
|  |  * This function sets the global system status to `sysStat_Shutdown`, | ||||||
|  |  * which will trigger a system reboot sequence. | ||||||
|  |  */ | ||||||
|  | void Debug_Reboot() | ||||||
|  | { | ||||||
|  |     globals.systemStatus = sysStat_Shutdown; | ||||||
|  | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * @brief Convert a uint32_t value to a binary string with nibbles separated by a space. |  * @brief Convert a uint32_t value to a binary string with nibbles separated by a space. | ||||||
|  * |  * | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ | |||||||
| #include "eeprom.h" | #include "eeprom.h" | ||||||
| #include "debugger.h" | #include "debugger.h" | ||||||
| #include "globals.h" | #include "globals.h" | ||||||
|  | #include "utilities.h" | ||||||
|  |  | ||||||
| // Instance of I2C_eeprom for EEPROM access | // Instance of I2C_eeprom for EEPROM access | ||||||
| I2C_eeprom ee(I2C_EE_ADDRESS, EEPROM_SIZE_BYTES); | I2C_eeprom ee(I2C_EE_ADDRESS, EEPROM_SIZE_BYTES); | ||||||
| @@ -157,7 +158,7 @@ void GetConfig_EEPROM() | |||||||
|  |  | ||||||
|   ConfigData.checksum = checksum; |   ConfigData.checksum = checksum; | ||||||
|  |  | ||||||
|   uint32_t ConfigSanityCheckResult = ConfigSanityCheck(false); |   uint32_t ConfigSanityCheckResult = ConfigSanityCheck(true); | ||||||
|  |  | ||||||
|   MaintainDTC(DTC_EEPROM_CFG_SANITY, (ConfigSanityCheckResult > 0), ConfigSanityCheckResult); |   MaintainDTC(DTC_EEPROM_CFG_SANITY, (ConfigSanityCheckResult > 0), ConfigSanityCheckResult); | ||||||
| } | } | ||||||
| @@ -430,48 +431,6 @@ uint32_t ConfigSanityCheck(bool autocorrect) | |||||||
|   return setting_reset_bits; |   return setting_reset_bits; | ||||||
| } | } | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * @brief Validates whether a given string contains only characters allowed in WiFi SSIDs and passwords. |  | ||||||
|  * |  | ||||||
|  * This function checks each character in the provided string to ensure |  | ||||||
|  * that it contains only characters allowed in WiFi SSIDs and passwords. |  | ||||||
|  * It considers characters from 'A' to 'Z', 'a' to 'z', '0' to '9', as well as |  | ||||||
|  * the following special characters: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ |  | ||||||
|  * |  | ||||||
|  * @param string Pointer to the string to be validated. |  | ||||||
|  * @param size Size of the string including the null-terminator. |  | ||||||
|  * @return true if the string contains only allowed characters or is NULL, |  | ||||||
|  *         false otherwise. |  | ||||||
|  */ |  | ||||||
| bool validateWiFiString(char *string, size_t size) |  | ||||||
| { |  | ||||||
|   if (string == NULL) |  | ||||||
|     return false; |  | ||||||
|  |  | ||||||
|   for (size_t i = 0; i < size; i++) |  | ||||||
|   { |  | ||||||
|     char c = string[i]; |  | ||||||
|     if (c == '\0') |  | ||||||
|     { |  | ||||||
|       // Reached the end of the string, all characters were valid WiFi characters. |  | ||||||
|       return true; |  | ||||||
|     } |  | ||||||
|     if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || |  | ||||||
|           (c >= '0' && c <= '9') || c == '!' || c == '"' || c == '#' || |  | ||||||
|           c == '$' || c == '%' || c == '&' || c == '\'' || c == '(' || |  | ||||||
|           c == ')' || c == '*' || c == '+' || c == ',' || c == '-' || |  | ||||||
|           c == '.' || c == '/' || c == ':' || c == ';' || c == '<' || |  | ||||||
|           c == '=' || c == '>' || c == '?' || c == '@' || c == '[' || |  | ||||||
|           c == '\\' || c == ']' || c == '^' || c == '_' || c == '`' || |  | ||||||
|           c == '{' || c == '|' || c == '}' || c == '~')) |  | ||||||
|     { |  | ||||||
|       // Found a character that is not a valid WiFi character. |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|   // If the loop completes without finding a null terminator, the string is invalid. |  | ||||||
|   return false; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * @brief Write sequential numbers to a portion of EEPROM. |  * @brief Write sequential numbers to a portion of EEPROM. | ||||||
|   | |||||||
| @@ -249,7 +249,7 @@ void printParameters(struct Configuration configuration) | |||||||
| void Parse_LoRa_UartCommand(char input[], int size) | void Parse_LoRa_UartCommand(char input[], int size) | ||||||
| { | { | ||||||
|  |  | ||||||
|     Debug_pushMessage("Start parsing, size: %d", size); |     Debug_pushMessage("Start parsing, size: %d\n", size); | ||||||
|     char delimiter[] = ";"; |     char delimiter[] = ";"; | ||||||
|     char *ptr; |     char *ptr; | ||||||
|     char command[8]; |     char command[8]; | ||||||
| @@ -278,7 +278,7 @@ void Parse_LoRa_UartCommand(char input[], int size) | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Hier kannst du den Wert und das Kommando verarbeiten |         // Hier kannst du den Wert und das Kommando verarbeiten | ||||||
|         Debug_pushMessage("Command: %s, Value: %s", command, value); |         Debug_pushMessage("Command: %s, Value: %s\n", command, value); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     Debug_pushMessage("Parsed LoRa UART Command:  %s Value: %s\n", command, value); |     Debug_pushMessage("Parsed LoRa UART Command:  %s Value: %s\n", command, value); | ||||||
| @@ -286,12 +286,12 @@ void Parse_LoRa_UartCommand(char input[], int size) | |||||||
|     if (!strcmp(command, "ENABLE")) |     if (!strcmp(command, "ENABLE")) | ||||||
|     { |     { | ||||||
|         globals.timer_disabled = false; |         globals.timer_disabled = false; | ||||||
|         Debug_pushMessage("Enabled by LoRa"); |         Debug_pushMessage("Enabled by LoRa\n"); | ||||||
|     } |     } | ||||||
|     else if (!strcmp(command, "DISABLE")) |     else if (!strcmp(command, "DISABLE")) | ||||||
|     { |     { | ||||||
|         globals.timer_disabled = true; |         globals.timer_disabled = true; | ||||||
|         Debug_pushMessage("Disabled by LoRa"); |         Debug_pushMessage("Disabled by LoRa\n"); | ||||||
|     } |     } | ||||||
|     else if (!strcmp(command, "RESET")) |     else if (!strcmp(command, "RESET")) | ||||||
|     { |     { | ||||||
| @@ -299,7 +299,7 @@ void Parse_LoRa_UartCommand(char input[], int size) | |||||||
|         PersistenceData.faction_1_timer = 0; |         PersistenceData.faction_1_timer = 0; | ||||||
|         PersistenceData.faction_2_timer = 0; |         PersistenceData.faction_2_timer = 0; | ||||||
|         PersistenceData.faction_3_timer = 0; |         PersistenceData.faction_3_timer = 0; | ||||||
|         Debug_pushMessage("Reset by LoRa"); |         Debug_pushMessage("Reset by LoRa\n"); | ||||||
|     } |     } | ||||||
|     else if (!strcmp(command, "TMRSTP")) |     else if (!strcmp(command, "TMRSTP")) | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
| #include "globals.h" | #include "globals.h" | ||||||
| #include "dtc.h" | #include "dtc.h" | ||||||
| #include "debugger.h" | #include "debugger.h" | ||||||
|  | #include "utilities.h" | ||||||
| #if defined(FEATURE_ENABLE_LORA) || defined(FEATURE_ENABLE_UARTLORA) | #if defined(FEATURE_ENABLE_LORA) || defined(FEATURE_ENABLE_UARTLORA) | ||||||
| #include "lora_net.h" | #include "lora_net.h" | ||||||
| #endif | #endif | ||||||
| @@ -420,7 +421,7 @@ void tmrCallback_InputGetter() | |||||||
|  |  | ||||||
| 	if (keysPressed > 1) | 	if (keysPressed > 1) | ||||||
| 	{ | 	{ | ||||||
| 		Debug_pushMessage("ERROR: More than one Flag active - setting no Faction active"); | 		Debug_pushMessage("ERROR: More than one Flag active - setting no Faction active\n"); | ||||||
| 		PersistenceData.activeFaction = NONE; | 		PersistenceData.activeFaction = NONE; | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| @@ -429,7 +430,7 @@ void tmrCallback_InputGetter() | |||||||
| 	{ | 	{ | ||||||
| 		if (PersistenceData.activeFaction != FACTION_1) | 		if (PersistenceData.activeFaction != FACTION_1) | ||||||
| 		{ | 		{ | ||||||
| 			Debug_pushMessage("Faction 1 captured !"); | 			Debug_pushMessage("Faction 1 captured !\n"); | ||||||
| 			globals.requestEEAction = EE_PDS_SAVE; | 			globals.requestEEAction = EE_PDS_SAVE; | ||||||
| 		} | 		} | ||||||
| 		PersistenceData.activeFaction = FACTION_1; | 		PersistenceData.activeFaction = FACTION_1; | ||||||
| @@ -439,7 +440,7 @@ void tmrCallback_InputGetter() | |||||||
| 	{ | 	{ | ||||||
| 		if (PersistenceData.activeFaction != FACTION_2) | 		if (PersistenceData.activeFaction != FACTION_2) | ||||||
| 		{ | 		{ | ||||||
| 			Debug_pushMessage("Faction 2 captured !"); | 			Debug_pushMessage("Faction 2 captured !\n"); | ||||||
| 			globals.requestEEAction = EE_PDS_SAVE; | 			globals.requestEEAction = EE_PDS_SAVE; | ||||||
| 		} | 		} | ||||||
| 		PersistenceData.activeFaction = FACTION_2; | 		PersistenceData.activeFaction = FACTION_2; | ||||||
| @@ -449,7 +450,7 @@ void tmrCallback_InputGetter() | |||||||
| 	{ | 	{ | ||||||
| 		if (PersistenceData.activeFaction != FACTION_3) | 		if (PersistenceData.activeFaction != FACTION_3) | ||||||
| 		{ | 		{ | ||||||
| 			Debug_pushMessage("Faction 3 captured !"); | 			Debug_pushMessage("Faction 3 captured !\n"); | ||||||
| 			globals.requestEEAction = EE_PDS_SAVE; | 			globals.requestEEAction = EE_PDS_SAVE; | ||||||
| 		} | 		} | ||||||
| 		PersistenceData.activeFaction = FACTION_3; | 		PersistenceData.activeFaction = FACTION_3; | ||||||
| @@ -571,6 +572,7 @@ void wifiMaintainConnectionTicker_callback() | |||||||
|  */ |  */ | ||||||
| void toggleWiFiAP(bool shutdown) | void toggleWiFiAP(bool shutdown) | ||||||
| { | { | ||||||
|  | 	char buffer[33]; | ||||||
| 	// Check if WiFi is currently active | 	// Check if WiFi is currently active | ||||||
| 	if (WiFi.getMode() != WIFI_OFF) | 	if (WiFi.getMode() != WIFI_OFF) | ||||||
| 	{ | 	{ | ||||||
| @@ -588,7 +590,8 @@ void toggleWiFiAP(bool shutdown) | |||||||
| 		// Start WiFi in Access Point (AP) mode | 		// Start WiFi in Access Point (AP) mode | ||||||
| 		WiFi.mode(WIFI_AP); | 		WiFi.mode(WIFI_AP); | ||||||
| 		WiFi.softAPConfig(IPAddress(WIFI_AP_IP_GW), IPAddress(WIFI_AP_IP_GW), IPAddress(255, 255, 255, 0)); | 		WiFi.softAPConfig(IPAddress(WIFI_AP_IP_GW), IPAddress(WIFI_AP_IP_GW), IPAddress(255, 255, 255, 0)); | ||||||
| 		WiFi.softAP(globals.DeviceNameId, QUOTE(WIFI_AP_PASSWORD)); | 		sanitizeWiFiString(globals.DeviceNameId, buffer, sizeof(buffer)); | ||||||
|  | 		WiFi.softAP(buffer, QUOTE(WIFI_AP_PASSWORD)); | ||||||
|  |  | ||||||
| 		// Stop WiFi maintenance connection ticker if enabled and display debug messages | 		// Stop WiFi maintenance connection ticker if enabled and display debug messages | ||||||
| #ifdef FEATURE_ENABLE_WIFI_CLIENT | #ifdef FEATURE_ENABLE_WIFI_CLIENT | ||||||
| @@ -701,7 +704,7 @@ void ProcessKeyCombos(bool *btnState) | |||||||
|  |  | ||||||
| 		if (keyCount_Fac2 == 2 && keyCount_Fac3 == 0) | 		if (keyCount_Fac2 == 2 && keyCount_Fac3 == 0) | ||||||
| 		{ | 		{ | ||||||
| 			Debug_pushMessage("KeyCombo: WiFi AP ON"); | 			Debug_pushMessage("KeyCombo: WiFi AP ON\n"); | ||||||
| 			OverrideDisplay(5000, "NET ", "    ", "    "); | 			OverrideDisplay(5000, "NET ", "    ", "    "); | ||||||
| 			toggleWiFiAP(false); | 			toggleWiFiAP(false); | ||||||
| 		} | 		} | ||||||
|   | |||||||
							
								
								
									
										94
									
								
								Software/src/utilities.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								Software/src/utilities.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,94 @@ | |||||||
|  | #include "utilities.h" | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @brief Validates whether a given string contains only characters allowed in WiFi SSIDs and passwords. | ||||||
|  |  * | ||||||
|  |  * This function checks each character in the provided string to ensure | ||||||
|  |  * that it contains only characters allowed in WiFi SSIDs and passwords. | ||||||
|  |  * It considers characters from 'A' to 'Z', 'a' to 'z', '0' to '9', as well as | ||||||
|  |  * the following special characters: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ | ||||||
|  |  * | ||||||
|  |  * @param string Pointer to the string to be validated. | ||||||
|  |  * @param size Size of the string including the null-terminator. | ||||||
|  |  * @return true if the string contains only allowed characters or is NULL, | ||||||
|  |  *         false otherwise. | ||||||
|  |  */ | ||||||
|  | bool validateWiFiString(char *string, size_t size) | ||||||
|  | { | ||||||
|  |     if (string == NULL) | ||||||
|  |         return false; | ||||||
|  |  | ||||||
|  |     for (size_t i = 0; i < size; i++) | ||||||
|  |     { | ||||||
|  |         char c = string[i]; | ||||||
|  |         if (c == '\0') | ||||||
|  |         { | ||||||
|  |             // Reached the end of the string, all characters were valid WiFi characters. | ||||||
|  |             return true; | ||||||
|  |         } | ||||||
|  |         if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || | ||||||
|  |               (c >= '0' && c <= '9') || c == '!' || c == '"' || c == '#' || | ||||||
|  |               c == '$' || c == '%' || c == '&' || c == '\'' || c == '(' || | ||||||
|  |               c == ')' || c == '*' || c == '+' || c == ',' || c == '-' || | ||||||
|  |               c == '.' || c == '/' || c == ':' || c == ';' || c == '<' || | ||||||
|  |               c == '=' || c == '>' || c == '?' || c == '@' || c == '[' || | ||||||
|  |               c == '\\' || c == ']' || c == '^' || c == '_' || c == '`' || | ||||||
|  |               c == '{' || c == '|' || c == '}' || c == '~')) | ||||||
|  |         { | ||||||
|  |             // Found a character that is not a valid WiFi character. | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     // If the loop completes without finding a null terminator, the string is invalid. | ||||||
|  |     return false; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @brief Copies a string to a buffer, replacing invalid WiFi SSID characters with a placeholder. | ||||||
|  |  * | ||||||
|  |  * This function checks each character in the provided input string to ensure | ||||||
|  |  * that it contains only characters allowed in WiFi SSIDs and passwords. If a character | ||||||
|  |  * is invalid, it replaces it with a placeholder character (e.g., '_'). | ||||||
|  |  * It considers characters from 'A' to 'Z', 'a' to 'z', '0' to '9', as well as | ||||||
|  |  * the following special characters: ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ | ||||||
|  |  * | ||||||
|  |  * @param input Pointer to the input string to be validated and copied. | ||||||
|  |  * @param buffer Pointer to the buffer where the output string will be copied. | ||||||
|  |  * @param bufferSize Size of the buffer including the null-terminator. | ||||||
|  |  */ | ||||||
|  | void sanitizeWiFiString(const char *input, char *buffer, size_t bufferSize) | ||||||
|  | { | ||||||
|  |     if (input == NULL || buffer == NULL || bufferSize == 0) | ||||||
|  |         return; | ||||||
|  |  | ||||||
|  |     size_t i; | ||||||
|  |     for (i = 0; i < bufferSize - 1; i++) // Leave space for null-terminator | ||||||
|  |     { | ||||||
|  |         char c = input[i]; | ||||||
|  |         if (c == '\0') | ||||||
|  |         { | ||||||
|  |             // Reached the end of the input string, terminate the buffer | ||||||
|  |             buffer[i] = '\0'; | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || | ||||||
|  |               (c >= '0' && c <= '9') || c == '!' || c == '"' || c == '#' || | ||||||
|  |               c == '$' || c == '%' || c == '&' || c == '\'' || c == '(' || | ||||||
|  |               c == ')' || c == '*' || c == '+' || c == ',' || c == '-' || | ||||||
|  |               c == '.' || c == '/' || c == ':' || c == ';' || c == '<' || | ||||||
|  |               c == '=' || c == '>' || c == '?' || c == '@' || c == '[' || | ||||||
|  |               c == '\\' || c == ']' || c == '^' || c == '_' || c == '`' || | ||||||
|  |               c == '{' || c == '|' || c == '}' || c == '~')) | ||||||
|  |         { | ||||||
|  |             // Replace invalid character with placeholder | ||||||
|  |             buffer[i] = '_'; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             // Copy valid character to buffer | ||||||
|  |             buffer[i] = c; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     // Null-terminate the buffer | ||||||
|  |     buffer[i] = '\0'; | ||||||
|  | } | ||||||
| @@ -497,7 +497,6 @@ void Websocket_HandleSettings(uint8_t *data) | |||||||
|   { |   { | ||||||
|     ConfigData.active_faction_on_reboot = value[0] == '1' ? true : false; |     ConfigData.active_faction_on_reboot = value[0] == '1' ? true : false; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   else if (strcmp(identifier, "name_faction1") == 0) |   else if (strcmp(identifier, "name_faction1") == 0) | ||||||
|   { |   { | ||||||
|     strncpy(ConfigData.Faction_1_Name, value, sizeof(ConfigData.Faction_1_Name)); |     strncpy(ConfigData.Faction_1_Name, value, sizeof(ConfigData.Faction_1_Name)); | ||||||
| @@ -511,10 +510,6 @@ void Websocket_HandleSettings(uint8_t *data) | |||||||
|     strncpy(ConfigData.Faction_3_Name, value, sizeof(ConfigData.Faction_3_Name)); |     strncpy(ConfigData.Faction_3_Name, value, sizeof(ConfigData.Faction_3_Name)); | ||||||
|   } |   } | ||||||
|   else if (strcmp(identifier, "batterytype") == 0) |   else if (strcmp(identifier, "batterytype") == 0) | ||||||
|   { |  | ||||||
|     strncpy(ConfigData.wifi_client_ssid, value, sizeof(ConfigData.wifi_client_ssid)); |  | ||||||
|   } |  | ||||||
|   else if (strcmp(identifier, "batterytype") == 0) |  | ||||||
|   { |   { | ||||||
|     int index = findIndexByString(value, BatteryString, BatteryString_Elements); |     int index = findIndexByString(value, BatteryString, BatteryString_Elements); | ||||||
|     batterytypePreselect = (batteryType_t)index; |     batterytypePreselect = (batteryType_t)index; | ||||||
| @@ -599,7 +594,6 @@ void Websocket_RefreshClientData_DTCs(uint32_t client_id) | |||||||
|  */ |  */ | ||||||
| void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping) | void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping) | ||||||
| { | { | ||||||
|  |  | ||||||
|     if (send_mapping) |     if (send_mapping) | ||||||
|     { |     { | ||||||
|         const char mapping[] = "MAPPING_STATUS:" |         const char mapping[] = "MAPPING_STATUS:" | ||||||
| @@ -618,25 +612,27 @@ void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping) | |||||||
|         Debug_pushMessage("send MAPPING_STATUS WS-Client Data\n"); |         Debug_pushMessage("send MAPPING_STATUS WS-Client Data\n"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   String temp = "STATUS:"; |     char dataString[200] = {0}; // Maximal 200 Zeichen für den Data-String | ||||||
|  |  | ||||||
|   temp.concat(String(globals.battery_level) + ";"); |     sprintf(dataString, "STATUS:%d;%s;%d;%ld;%ld;%ld;", | ||||||
|   temp.concat(String(globals.systemStatustxt) + ";"); |             globals.battery_level, | ||||||
|   temp.concat(String(PersistenceData.activeFaction) + ";"); |             globals.systemStatustxt, | ||||||
|   temp.concat(String(PersistenceData.faction_1_timer) + ";"); |             PersistenceData.activeFaction, | ||||||
|   temp.concat(String(PersistenceData.faction_2_timer) + ";"); |             PersistenceData.faction_1_timer, | ||||||
|   temp.concat(String(PersistenceData.faction_3_timer) + ";"); |             PersistenceData.faction_2_timer, | ||||||
|  |             PersistenceData.faction_3_timer); | ||||||
|  |  | ||||||
|     if (client_id > 0) |     if (client_id > 0) | ||||||
|     { |     { | ||||||
|     webSocket.text(client_id, temp); |         webSocket.text(client_id, dataString); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|     webSocket.textAll(temp); |         webSocket.textAll(dataString); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * @brief Refreshes client data related to static configuration parameters on WebSocket clients. |  * @brief Refreshes client data related to static configuration parameters on WebSocket clients. | ||||||
|  * |  * | ||||||
| @@ -650,6 +646,7 @@ void Websocket_RefreshClientData_Status(uint32_t client_id, bool send_mapping) | |||||||
| void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping) | void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping) | ||||||
| { | { | ||||||
|  |  | ||||||
|  |   Debug_pushMessage("send STATIC WS-Client Data\n"); | ||||||
|   if (send_mapping) |   if (send_mapping) | ||||||
|   { |   { | ||||||
|     const char mapping[] = "MAPPING_STATIC:" |     const char mapping[] = "MAPPING_STATIC:" | ||||||
| @@ -660,32 +657,42 @@ void Websocket_RefreshClientData_Static(uint32_t client_id, bool send_mapping) | |||||||
|                            "name_faction2;" |                            "name_faction2;" | ||||||
|                            "name_faction3;" |                            "name_faction3;" | ||||||
|                            "wifi-ssid;" |                            "wifi-ssid;" | ||||||
|                            "wifi-pass;"; |                            "wifi-pass;" | ||||||
|  |                            "fw-version;" | ||||||
|  |                            "flash-version;" | ||||||
|  |                            "git-revison;"; | ||||||
|  |  | ||||||
|     if (client_id > 0) |     if (client_id > 0) | ||||||
|       webSocket.text(client_id, mapping); |       webSocket.text(client_id, mapping); | ||||||
|     else |     else | ||||||
|       webSocket.textAll(mapping); |       webSocket.textAll(mapping); | ||||||
|  |  | ||||||
|  |     Debug_pushMessage("send MAPPING_STATIC WS-Client Data\n"); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   String temp = "STATIC:"; |   char dataString[200] = {0}; // Maximal 200 Zeichen für den Data-String | ||||||
|  |  | ||||||
|   temp.concat(String(globals.DeviceName) + ";"); |   sprintf(dataString, "STATIC:%s;%d;%d;%s;%s;%s;%s;%s;%d.%02d;%s;%s;", | ||||||
|   temp.concat(String(ConfigData.active_faction_on_reboot) + ";"); |           globals.DeviceName, | ||||||
|   temp.concat(String(ConfigData.batteryType) + ";"); |           ConfigData.active_faction_on_reboot, | ||||||
|   temp.concat(String(ConfigData.Faction_1_Name) + ";"); |           ConfigData.batteryType, | ||||||
|   temp.concat(String(ConfigData.Faction_2_Name) + ";"); |           ConfigData.Faction_1_Name, | ||||||
|   temp.concat(String(ConfigData.Faction_3_Name) + ";"); |           ConfigData.Faction_2_Name, | ||||||
|   temp.concat(String(ConfigData.wifi_client_ssid) + ";"); |           ConfigData.Faction_3_Name, | ||||||
|   temp.concat(String(ConfigData.wifi_client_password) + ";"); |           ConfigData.wifi_client_ssid, | ||||||
|  |           ConfigData.wifi_client_password, | ||||||
|  |           constants.FW_Version_major, | ||||||
|  |           constants.FW_Version_minor, | ||||||
|  |           globals.FlashVersion, | ||||||
|  |           constants.GitHash); | ||||||
|  |  | ||||||
|   if (client_id > 0) |   if (client_id > 0) | ||||||
|   { |   { | ||||||
|     webSocket.text(client_id, temp); |     webSocket.text(client_id, dataString); | ||||||
|   } |   } | ||||||
|   else |   else | ||||||
|   { |   { | ||||||
|     webSocket.textAll(temp); |     webSocket.textAll(dataString); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user