Initial Commit V2 (Used code from OBWB8m Data Parser)
This commit is contained in:
60
HTMLExecuteFormConverter.cpp
Normal file
60
HTMLExecuteFormConverter.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
//
|
||||
//
|
||||
// This File was generated or modified by Jakob A. Oberbuchner's Generator/Intrepreter (2025)
|
||||
//
|
||||
//
|
||||
|
||||
#include "HTMLExecuteFormConverter.h"
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
void Execute_ParseFromHTML( const String argName, const String arg, execute_t* structure ) {
|
||||
|
||||
Serial.printf("'%s' with associated value '%s'\n", argName, arg);
|
||||
char key[sizeof(argName)];
|
||||
argName.toCharArray(key, sizeof(key));
|
||||
int32_t tempVar = -1;
|
||||
uint32_t value = 0;
|
||||
|
||||
if (sscanf(key, "%*[^_]_%d", &tempVar) <= 0) {
|
||||
return;
|
||||
} else {
|
||||
value = tempVar;
|
||||
}
|
||||
|
||||
switch (key[0]) {
|
||||
case 'v':
|
||||
switch (key[1]) {
|
||||
case '1':
|
||||
switch (key[2]) {
|
||||
case '_':
|
||||
switch (value) {
|
||||
case 1:
|
||||
structure->Command = (ExecuteCommand_t) arg.toInt(); // need to prevent overflows
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} //Execute_ParseFromHTML
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String Execute_ParseToHTML(execute_t* structure) {
|
||||
JsonDocument doc;
|
||||
|
||||
doc["v1_1"] = structure->Command;
|
||||
|
||||
|
||||
String output;
|
||||
|
||||
doc.shrinkToFit(); // optional, releases unused memory
|
||||
|
||||
serializeJson(doc, output);
|
||||
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user