Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
1cf0560957 | |||
b66d175948 | |||
0967b6aa65 | |||
498d813624 |
@@ -1 +1 @@
|
||||
1.03
|
||||
1.04
|
@@ -59,8 +59,8 @@ typedef struct Constants_s
|
||||
} Constants_t;
|
||||
|
||||
const Constants_t constants PROGMEM = {
|
||||
1,3, // Firmware_Version
|
||||
1,3, // Required Flash Version
|
||||
1,5, // Firmware_Version
|
||||
1,4, // Required Flash Version
|
||||
GIT_REV // Git-Hash-String
|
||||
};
|
||||
|
||||
|
@@ -68,6 +68,7 @@ bool InitLoRa(void (*MPinHelper)(int, int))
|
||||
}
|
||||
#elif defined(FEATURE_ENABLE_UARTLORA)
|
||||
SerialLoRa.begin(9600);
|
||||
returnval = true;
|
||||
#endif
|
||||
return returnval;
|
||||
}
|
||||
@@ -94,41 +95,36 @@ void LoRa_Process()
|
||||
}
|
||||
#elif defined(FEATURE_ENABLE_UARTLORA)
|
||||
|
||||
char packageInput[16];
|
||||
bool packageRecieved = false;
|
||||
unsigned int bufferPtr = 0;
|
||||
static char packageInput[32];
|
||||
static bool packageRecieved = false;
|
||||
static unsigned int bufferPtr = 0;
|
||||
int recievedSize = 0;
|
||||
|
||||
if (SerialLoRa.available() && packageRecieved == false)
|
||||
while (SerialLoRa.available() && packageRecieved == false)
|
||||
{
|
||||
while (bufferPtr < sizeof(packageInput))
|
||||
if (bufferPtr < sizeof(packageInput) - 1)
|
||||
{
|
||||
packageInput[bufferPtr] = SerialLoRa.read();
|
||||
packageInput[bufferPtr + 1] = 0; // always terminate String
|
||||
|
||||
if (packageInput[bufferPtr] == '\n')
|
||||
{
|
||||
packageInput[bufferPtr] = 0; // terminate String
|
||||
packageRecieved = true;
|
||||
recievedSize = bufferPtr;
|
||||
bufferPtr = 0;
|
||||
Debug_pushMessage("Got LoRa UART: %s\n", packageInput);
|
||||
break;
|
||||
}
|
||||
else if ((packageInput[bufferPtr] >= 0x30) || (packageInput[bufferPtr] <= 0x5A)) // only accept Numbers, UpperCase-Letters and some special chars
|
||||
{
|
||||
if (bufferPtr < sizeof(packageInput) - 1)
|
||||
{
|
||||
bufferPtr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
packageInput[bufferPtr] = 0; // terminate String, bc Buffer is full (package to long)
|
||||
packageRecieved = true; // send it anyway to the parser
|
||||
Debug_pushMessage("Got LoRa UART: %s\n", packageInput);
|
||||
break;
|
||||
}
|
||||
bufferPtr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (packageRecieved)
|
||||
Parse_LoRa_UartCommand(packageInput, bufferPtr);
|
||||
if (packageRecieved) {
|
||||
Parse_LoRa_UartCommand(packageInput, recievedSize);
|
||||
packageRecieved = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -242,6 +238,7 @@ void printParameters(struct Configuration configuration)
|
||||
void Parse_LoRa_UartCommand(char input[], int size)
|
||||
{
|
||||
|
||||
Debug_pushMessage("Start parsing, size: %d", size);
|
||||
char delimiter[] = ";";
|
||||
char *ptr;
|
||||
char command[8];
|
||||
@@ -249,11 +246,28 @@ void Parse_LoRa_UartCommand(char input[], int size)
|
||||
|
||||
ptr = strtok(input, delimiter);
|
||||
|
||||
ptr = strtok(input, delimiter);
|
||||
|
||||
while (ptr != NULL)
|
||||
{
|
||||
strncpy(command, ptr, sizeof(command));
|
||||
strncpy(command, ptr, sizeof(command) - 1); // Platz für Nullterminator lassen
|
||||
command[sizeof(command) - 1] = '\0'; // Nullterminator setzen
|
||||
|
||||
ptr = strtok(NULL, delimiter);
|
||||
strncpy(value, ptr, sizeof(value));
|
||||
|
||||
if (ptr != NULL)
|
||||
{
|
||||
strncpy(value, ptr, sizeof(value) - 1); // Platz für Nullterminator lassen
|
||||
value[sizeof(value) - 1] = '\0'; // Nullterminator setzen
|
||||
}
|
||||
else
|
||||
{
|
||||
// Wenn ptr NULL ist, setze value auf leeren String
|
||||
value[0] = '\0';
|
||||
}
|
||||
|
||||
// Hier kannst du den Wert und das Kommando verarbeiten
|
||||
Debug_pushMessage("Command: %s, Value: %s", command, value);
|
||||
}
|
||||
|
||||
Debug_pushMessage("Parsed LoRa UART Command: %s Value: %s\n", command, value);
|
||||
@@ -261,10 +275,12 @@ void Parse_LoRa_UartCommand(char input[], int size)
|
||||
if (!strcmp(command, "ENABLE"))
|
||||
{
|
||||
globals.timer_disabled = false;
|
||||
Debug_pushMessage("Enabled by LoRa");
|
||||
}
|
||||
else if (!strcmp(command, "DISABLE"))
|
||||
{
|
||||
globals.timer_disabled = false;
|
||||
globals.timer_disabled = true;
|
||||
Debug_pushMessage("Disabled by LoRa");
|
||||
}
|
||||
else if (!strcmp(command, "RESET"))
|
||||
{
|
||||
@@ -272,6 +288,7 @@ void Parse_LoRa_UartCommand(char input[], int size)
|
||||
PersistenceData.faction_1_timer = 0;
|
||||
PersistenceData.faction_2_timer = 0;
|
||||
PersistenceData.faction_3_timer = 0;
|
||||
Debug_pushMessage("Reset by LoRa");
|
||||
}
|
||||
else if (!strcmp(command, "TMRSTP"))
|
||||
{
|
||||
|
@@ -352,7 +352,7 @@ void tmrCallback_InputGetter()
|
||||
return;
|
||||
}
|
||||
|
||||
if (btnState[0] == FAC_1_TRG_PRESSED && globals.timer_disabled == false)
|
||||
if (btnState[0] == FAC_1_TRG_PRESSED && globals.timer_disabled != true)
|
||||
{
|
||||
if (PersistenceData.activeFaction != FACTION_1)
|
||||
{
|
||||
@@ -362,7 +362,7 @@ void tmrCallback_InputGetter()
|
||||
PersistenceData.activeFaction = FACTION_1;
|
||||
}
|
||||
|
||||
if (btnState[1] == FAC_2_TRG_PRESSED && globals.timer_disabled == false)
|
||||
if (btnState[1] == FAC_2_TRG_PRESSED && globals.timer_disabled != true)
|
||||
{
|
||||
if (PersistenceData.activeFaction != FACTION_2)
|
||||
{
|
||||
@@ -372,7 +372,7 @@ void tmrCallback_InputGetter()
|
||||
PersistenceData.activeFaction = FACTION_2;
|
||||
}
|
||||
|
||||
if (btnState[2] == FAC_3_TRG_PRESSED && globals.timer_disabled == false)
|
||||
if (btnState[2] == FAC_3_TRG_PRESSED && globals.timer_disabled != true)
|
||||
{
|
||||
if (PersistenceData.activeFaction != FACTION_3)
|
||||
{
|
||||
|
Reference in New Issue
Block a user