Compare commits
2 Commits
a2aa302121
...
5ae054f314
Author | SHA1 | Date | |
---|---|---|---|
5ae054f314 | |||
3e571a515d |
@ -90,7 +90,7 @@ const configData_t ConfigData_defaults = {
|
|||||||
0 // checksum
|
0 // checksum
|
||||||
};
|
};
|
||||||
|
|
||||||
void InitEEPROM();
|
boolean InitEEPROM();
|
||||||
void EEPROM_Process();
|
void EEPROM_Process();
|
||||||
void StoreConfig_EEPROM();
|
void StoreConfig_EEPROM();
|
||||||
void GetConfig_EEPROM();
|
void GetConfig_EEPROM();
|
||||||
|
@ -35,12 +35,13 @@ boolean checkEEPROMavailable();
|
|||||||
*
|
*
|
||||||
* This function initializes the EEPROM using the I2C_eeprom instance and checks if it's available.
|
* This function initializes the EEPROM using the I2C_eeprom instance and checks if it's available.
|
||||||
*/
|
*/
|
||||||
void InitEEPROM()
|
boolean InitEEPROM()
|
||||||
{
|
{
|
||||||
|
Wire.begin();
|
||||||
ConfigData = ConfigData_defaults;
|
ConfigData = ConfigData_defaults;
|
||||||
PersistenceData = {0};
|
PersistenceData = {0};
|
||||||
ee.begin();
|
ee.begin();
|
||||||
checkEEPROMavailable();
|
return checkEEPROMavailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +79,7 @@ void LoRa_Process()
|
|||||||
if (e220ttl.available() > 1)
|
if (e220ttl.available() > 1)
|
||||||
{
|
{
|
||||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||||
// Is something goes wrong print error
|
// If something goes wrong, print error
|
||||||
if (rc.status.code != 1)
|
if (rc.status.code != 1)
|
||||||
{
|
{
|
||||||
Serial.println(rc.status.getResponseDescription());
|
Serial.println(rc.status.getResponseDescription());
|
||||||
@ -96,34 +96,45 @@ void LoRa_Process()
|
|||||||
#elif defined(FEATURE_ENABLE_UARTLORA)
|
#elif defined(FEATURE_ENABLE_UARTLORA)
|
||||||
|
|
||||||
static char packageInput[32];
|
static char packageInput[32];
|
||||||
static bool packageRecieved = false;
|
static bool packageReceived = false;
|
||||||
static unsigned int bufferPtr = 0;
|
static unsigned int bufferPtr = 0;
|
||||||
int recievedSize = 0;
|
int receivedSize = 0;
|
||||||
|
|
||||||
while (SerialLoRa.available() && packageRecieved == false)
|
while (SerialLoRa.available() && !packageReceived)
|
||||||
{
|
{
|
||||||
if (bufferPtr < sizeof(packageInput) - 1)
|
if (bufferPtr < sizeof(packageInput) - 1)
|
||||||
{
|
{
|
||||||
packageInput[bufferPtr] = SerialLoRa.read();
|
char c = SerialLoRa.read();
|
||||||
packageInput[bufferPtr + 1] = 0; // always terminate String
|
packageInput[bufferPtr] = c;
|
||||||
|
packageInput[bufferPtr + 1] = '\0'; // always terminate string
|
||||||
|
|
||||||
if (packageInput[bufferPtr] == '\n')
|
if (c == '\n')
|
||||||
{
|
{
|
||||||
packageRecieved = true;
|
packageReceived = true;
|
||||||
recievedSize = bufferPtr;
|
receivedSize = bufferPtr;
|
||||||
bufferPtr = 0;
|
bufferPtr = 0;
|
||||||
Debug_pushMessage("Got LoRa UART: %s\n", packageInput);
|
Debug_pushMessage("Got LoRa UART: %s\n", packageInput);
|
||||||
}
|
}
|
||||||
else if ((packageInput[bufferPtr] >= 0x30) || (packageInput[bufferPtr] <= 0x5A)) // only accept Numbers, UpperCase-Letters and some special chars
|
else if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c == ' ' || c == ',' || c == '.')) // Accept numbers, uppercase letters, and some special chars
|
||||||
{
|
{
|
||||||
bufferPtr++;
|
bufferPtr++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug_pushMessage("Invalid character received: %c\n", c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug_pushMessage("Buffer overflow. Resetting buffer.\n");
|
||||||
|
bufferPtr = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packageRecieved) {
|
if (packageReceived)
|
||||||
Parse_LoRa_UartCommand(packageInput, recievedSize);
|
{
|
||||||
packageRecieved = false;
|
Parse_LoRa_UartCommand(packageInput, receivedSize);
|
||||||
|
packageReceived = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -110,13 +110,19 @@ void setup()
|
|||||||
|
|
||||||
Serial.print("\n\n-------------------START-------------------\n");
|
Serial.print("\n\n-------------------START-------------------\n");
|
||||||
Serial.print(globals.DeviceNameId);
|
Serial.print(globals.DeviceNameId);
|
||||||
Serial.print("\nby Hiabuto Defense\n");
|
Serial.print("\nby Hiabuto Defense\n\n");
|
||||||
|
|
||||||
// Initialize EEPROM, load configuration, and persistence data from EEPROM
|
// Initialize EEPROM, load configuration, and persistence data from EEPROM
|
||||||
InitEEPROM();
|
if (InitEEPROM())
|
||||||
|
{
|
||||||
GetConfig_EEPROM();
|
GetConfig_EEPROM();
|
||||||
GetPersistence_EEPROM();
|
GetPersistence_EEPROM();
|
||||||
Serial.print("\nEE-Init done");
|
Serial.printf("Initialized EEPROM at Address 0x%02X\n", I2C_EE_ADDRESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.print("EEPROM not Initialized\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (i2c_io.begin())
|
if (i2c_io.begin())
|
||||||
{
|
{
|
||||||
@ -209,7 +215,6 @@ void setup()
|
|||||||
|
|
||||||
// Start cyclic EEPROM updates for Persistence Data Structure (PDS)
|
// Start cyclic EEPROM updates for Persistence Data Structure (PDS)
|
||||||
tmrEEPROMCyclicPDS.start();
|
tmrEEPROMCyclicPDS.start();
|
||||||
Serial.print("\nSetup Done\n");
|
|
||||||
|
|
||||||
disp_FAC_1.init();
|
disp_FAC_1.init();
|
||||||
disp_FAC_1.setBrightness(5);
|
disp_FAC_1.setBrightness(5);
|
||||||
@ -218,7 +223,6 @@ void setup()
|
|||||||
disp_FAC_3.init();
|
disp_FAC_3.init();
|
||||||
disp_FAC_3.setBrightness(5);
|
disp_FAC_3.setBrightness(5);
|
||||||
|
|
||||||
tmrEEPROMCyclicPDS.start();
|
|
||||||
tmrFactionTicker.start();
|
tmrFactionTicker.start();
|
||||||
tmrInputGetter.start();
|
tmrInputGetter.start();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user