added LoraUartCommand Interpreter
This commit is contained in:
		| @@ -45,6 +45,7 @@ typedef struct Globals_s | |||||||
|   bool hasDTC; |   bool hasDTC; | ||||||
|   int loadvoltage_mV = 0; |   int loadvoltage_mV = 0; | ||||||
|   int battery_level = 0; |   int battery_level = 0; | ||||||
|  |   bool timer_disabled = false; | ||||||
| } Globals_t; | } Globals_t; | ||||||
|  |  | ||||||
| extern Globals_t globals; | extern Globals_t globals; | ||||||
|   | |||||||
| @@ -67,7 +67,7 @@ bool InitLoRa(void (*MPinHelper)(int, int)) | |||||||
|         MaintainDTC(DTC_NO_LORA_FOUND, DTC_WARN, true); |         MaintainDTC(DTC_NO_LORA_FOUND, DTC_WARN, true); | ||||||
|     } |     } | ||||||
| #elif defined(FEATURE_ENABLE_UARTLORA) | #elif defined(FEATURE_ENABLE_UARTLORA) | ||||||
|     // LORA UART Stuff here |     SerialLoRa.begin(9600); | ||||||
| #endif | #endif | ||||||
|     return returnval; |     return returnval; | ||||||
| } | } | ||||||
| @@ -151,8 +151,20 @@ void sendStatus_LoRa() | |||||||
|  |  | ||||||
|     ResponseStatus rs = e220ttl.sendFixedMessage(0xFF, 0xFF, 23, (byte *)&sendStatus, sizeof(sendStatus)); |     ResponseStatus rs = e220ttl.sendFixedMessage(0xFF, 0xFF, 23, (byte *)&sendStatus, sizeof(sendStatus)); | ||||||
|     Serial.println(rs.getResponseDescription()); |     Serial.println(rs.getResponseDescription()); | ||||||
|  |  | ||||||
| #elif defined(FEATURE_ENABLE_UARTLORA) | #elif defined(FEATURE_ENABLE_UARTLORA) | ||||||
| // LORA UART SEND STUFF HERE |  | ||||||
|  |     SerialLoRa.print(PersistenceData.faction_1_timer); | ||||||
|  |     SerialLoRa.write(";"); | ||||||
|  |     SerialLoRa.print(PersistenceData.faction_2_timer); | ||||||
|  |     SerialLoRa.write(";"); | ||||||
|  |     SerialLoRa.print(PersistenceData.faction_3_timer); | ||||||
|  |     SerialLoRa.write(";"); | ||||||
|  |     SerialLoRa.print(PersistenceData.activeFaction); | ||||||
|  |     SerialLoRa.write(";"); | ||||||
|  |     SerialLoRa.print(globals.battery_level); | ||||||
|  |     SerialLoRa.write('\n'); | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -245,5 +257,49 @@ void Parse_LoRa_UartCommand(char input[], int size) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     Debug_pushMessage("Parsed LoRa UART Command:  %s Value: %s\n", command, value); |     Debug_pushMessage("Parsed LoRa UART Command:  %s Value: %s\n", command, value); | ||||||
|  |  | ||||||
|  |     if (!strcmp(command, "ENABLE")) | ||||||
|  |     { | ||||||
|  |         globals.timer_disabled = false; | ||||||
|  |     } | ||||||
|  |     else if (!strcmp(command, "DISABLE")) | ||||||
|  |     { | ||||||
|  |         globals.timer_disabled = false; | ||||||
|  |     } | ||||||
|  |     else if (!strcmp(command, "RESET")) | ||||||
|  |     { | ||||||
|  |         PersistenceData.activeFaction = NONE; | ||||||
|  |         PersistenceData.faction_1_timer = 0; | ||||||
|  |         PersistenceData.faction_2_timer = 0; | ||||||
|  |         PersistenceData.faction_3_timer = 0; | ||||||
|  |     } | ||||||
|  |     else if (!strcmp(command, "TMRSTP")) | ||||||
|  |     { | ||||||
|  |         PersistenceData.activeFaction = NONE; | ||||||
|  |     } | ||||||
|  |     else if (!strcmp(command, "TMR1")) | ||||||
|  |     { | ||||||
|  |         PersistenceData.faction_1_timer = atol(value); | ||||||
|  |     } | ||||||
|  |     else if (!strcmp(command, "TMR2")) | ||||||
|  |     { | ||||||
|  |         PersistenceData.faction_2_timer = atol(value); | ||||||
|  |     } | ||||||
|  |     else if (!strcmp(command, "TMR3")) | ||||||
|  |     { | ||||||
|  |         PersistenceData.faction_3_timer = atol(value); | ||||||
|  |     } | ||||||
|  |     else if (!strcmp(command, "EFAC1")) | ||||||
|  |     { | ||||||
|  |         PersistenceData.activeFaction = FACTION_1; | ||||||
|  |     } | ||||||
|  |     else if (!strcmp(command, "EFAC2")) | ||||||
|  |     { | ||||||
|  |         PersistenceData.activeFaction = FACTION_2; | ||||||
|  |     } | ||||||
|  |     else if (!strcmp(command, "EFAC3")) | ||||||
|  |     { | ||||||
|  |         PersistenceData.activeFaction = FACTION_3; | ||||||
|  |     } | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| @@ -308,6 +308,9 @@ void SevenSeg_Output() | |||||||
|  |  | ||||||
| void tmrCallback_FactionTicker() | void tmrCallback_FactionTicker() | ||||||
| { | { | ||||||
|  | 	if (globals.timer_disabled == true) | ||||||
|  | 		PersistenceData.activeFaction = NONE; | ||||||
|  |  | ||||||
| 	switch (PersistenceData.activeFaction) | 	switch (PersistenceData.activeFaction) | ||||||
| 	{ | 	{ | ||||||
| 	case FACTION_1: | 	case FACTION_1: | ||||||
| @@ -349,7 +352,7 @@ void tmrCallback_InputGetter() | |||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (btnState[0] == FAC_1_TRG_PRESSED) | 	if (btnState[0] == FAC_1_TRG_PRESSED && globals.timer_disabled == false) | ||||||
| 	{ | 	{ | ||||||
| 		if (PersistenceData.activeFaction != FACTION_1) | 		if (PersistenceData.activeFaction != FACTION_1) | ||||||
| 		{ | 		{ | ||||||
| @@ -359,7 +362,7 @@ void tmrCallback_InputGetter() | |||||||
| 		PersistenceData.activeFaction = FACTION_1; | 		PersistenceData.activeFaction = FACTION_1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (btnState[1] == FAC_2_TRG_PRESSED) | 	if (btnState[1] == FAC_2_TRG_PRESSED && globals.timer_disabled == false) | ||||||
| 	{ | 	{ | ||||||
| 		if (PersistenceData.activeFaction != FACTION_2) | 		if (PersistenceData.activeFaction != FACTION_2) | ||||||
| 		{ | 		{ | ||||||
| @@ -369,7 +372,7 @@ void tmrCallback_InputGetter() | |||||||
| 		PersistenceData.activeFaction = FACTION_2; | 		PersistenceData.activeFaction = FACTION_2; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (btnState[2] == FAC_3_TRG_PRESSED) | 	if (btnState[2] == FAC_3_TRG_PRESSED && globals.timer_disabled == false) | ||||||
| 	{ | 	{ | ||||||
| 		if (PersistenceData.activeFaction != FACTION_3) | 		if (PersistenceData.activeFaction != FACTION_3) | ||||||
| 		{ | 		{ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user