Compare commits
19 Commits
22a62e3d1e
...
1.05
Author | SHA1 | Date | |
---|---|---|---|
1cf0560957 | |||
b66d175948 | |||
0967b6aa65 | |||
498d813624 | |||
268c204957 | |||
65d51f13aa | |||
f727bb3247 | |||
cd1379f90c | |||
0363b1eebc | |||
e6f1283aae | |||
a92b1edfd9 | |||
4cce7c1c86 | |||
0a1625e9b8 | |||
c24829ed70 | |||
a102405596 | |||
1b7157dbdc | |||
cad34d6b84 | |||
701bf9f457 | |||
0a895a00b9 |
BIN
Documentation/Pinout_UART_LoRa.png
Normal file
BIN
Documentation/Pinout_UART_LoRa.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
@@ -77,31 +77,28 @@
|
|||||||
<hr />
|
<hr />
|
||||||
<p>
|
<p>
|
||||||
<h4>aktueller Punktestand</h4>
|
<h4>aktueller Punktestand</h4>
|
||||||
<div class="table-responsive">
|
<div class="container-fluid">
|
||||||
<table class="table table-borderless table-dark">
|
<div class="row">
|
||||||
<thead>
|
<div class="col text-center %FACTION_1_ACTIVE% text-white p-3">%NAME_FAC_1%</div>
|
||||||
<tr>
|
<div class="col text-center %FACTION_2_ACTIVE% text-white p-3">%NAME_FAC_2%</div>
|
||||||
<th class="text-center" scope="col">%NAME_FAC_1%</th>
|
<div class="col text-center %FACTION_3_ACTIVE% text-white p-3">%NAME_FAC_3%</div>
|
||||||
<th class="text-center" scope="col">%NAME_FAC_2%</th>
|
</div>
|
||||||
<th class="text-center" scope="col">%NAME_FAC_3%</th>
|
<div class="row">
|
||||||
</tr>
|
<div class="col bg-dark text-white p-3"><img src="static/img/logo_fac1.png"
|
||||||
</thead>
|
class="rounded mx-auto img-fluid d-block" alt="...">
|
||||||
<tbody>
|
</div>
|
||||||
<tr>
|
<div class="col bg-dark text-white p-3"><img src="static/img/logo_fac2.png"
|
||||||
<td class="mx-auto"><img src="static/img/logo_fac1.png" class="rounded mx-auto img-fluid d-block"
|
class="rounded mx-auto img-fluid d-block" alt="...">
|
||||||
alt="..."></td>
|
</div>
|
||||||
<td class="mx-auto"><img src="static/img/logo_fac2.png" class="rounded mx-auto img-fluid d-block"
|
<div class="col bg-dark text-white p-3"><img src="static/img/logo_fac3.png"
|
||||||
alt="..."></td>
|
class="rounded mx-auto img-fluid d-block" alt="...">
|
||||||
<td class="mx-auto"><img src="static/img/logo_fac3.png" class="rounded mx-auto img-fluid d-block"
|
</div>
|
||||||
alt="..."></td>
|
</div>
|
||||||
</tr>
|
<div class="row">
|
||||||
<tr>
|
<div class="col text-center bg-secondary text-white p-3">%POINTS_FAC_1%</div>
|
||||||
<td class="text-center">%POINTS_FAC_1%</td>
|
<div class="col text-center bg-secondary text-white p-3">%POINTS_FAC_2%</div>
|
||||||
<td class="text-center">%POINTS_FAC_2%</td>
|
<div class="col text-center bg-secondary text-white p-3">%POINTS_FAC_3%</div>
|
||||||
<td class="text-center">%POINTS_FAC_3%</td>
|
</div>
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
<!-- Div GroupFaction Points -->
|
<!-- Div GroupFaction Points -->
|
||||||
@@ -219,13 +216,55 @@
|
|||||||
<label for="factionreboot_cont" class="control-label col-4">active Faction Recovery</label>
|
<label for="factionreboot_cont" class="control-label col-4">active Faction Recovery</label>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="checkbox" name="factionreboot_cont" id="factionreboot_cont" %FACTIONREBOOT_CHECKED%>
|
<input class="form-check-input" type="checkbox" name="factionreboot_cont" id="factionreboot_cont"
|
||||||
|
%FACTIONREBOOT_CHECKED%>
|
||||||
<label class="form-check-label" for="factionreboot_cont">
|
<label class="form-check-label" for="factionreboot_cont">
|
||||||
aktive Faktion beim booten wiederherstellen ?
|
aktive Faktion beim booten wiederherstellen ?
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<h4>Faktionsbezeichnungen</h4>
|
||||||
|
<div class="alert alert-primary alert-dismissable show fade" role="alert">
|
||||||
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
<strong>Achtung!</strong><br>
|
||||||
|
Faktionsbezeichnungen können nur aus ASCII-Zeichen bestehen, also A-Z, a-z und 0-9
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="faction_1_name" class="control-label col-4">Faktion 1</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="faction_1_name" name="faction_1_name" value="%NAME_FAC_1%" type="text" class="form-control" pattern="[A-Za-z0-9 _-]{1,32}">
|
||||||
|
<div class="input-group-append">
|
||||||
|
<span class="input-group-text">max 32 Zeichen</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="faction_2_name" class="control-label col-4">Faktion 2</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="faction_2_name" name="faction_2_name" value="%NAME_FAC_2%" type="text" class="form-control" pattern="[A-Za-z0-9 _-]{1,32}">
|
||||||
|
<div class="input-group-append">
|
||||||
|
<span class="input-group-text">max 32 Zeichen</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label for="faction_3_name" class="control-label col-4">Faktion 3</label>
|
||||||
|
<div class="col-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="faction_3_name" name="faction_3_name" value="%NAME_FAC_3%" type="text" class="form-control" pattern="[A-Za-z0-9 _-]{1,32}">
|
||||||
|
<div class="input-group-append">
|
||||||
|
<span class="input-group-text">max 32 Zeichen</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col text-center">
|
<div class="col text-center">
|
||||||
<button name="settingssave" type="submit" class="btn btn-outline-primary">Übernehmen</button>
|
<button name="settingssave" type="submit" class="btn btn-outline-primary">Übernehmen</button>
|
||||||
@@ -254,6 +293,10 @@
|
|||||||
<td>Hostname</td>
|
<td>Hostname</td>
|
||||||
<td>%HOSTNAME%</td>
|
<td>%HOSTNAME%</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Device-ID</td>
|
||||||
|
<td>%DEVICENAME_ID%</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Battery Voltage</td>
|
<td>Battery Voltage</td>
|
||||||
<td>%BAT_VOLTAGE%V</td>
|
<td>%BAT_VOLTAGE%V</td>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 34 KiB |
Binary file not shown.
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 37 KiB |
@@ -1 +1 @@
|
|||||||
1.02
|
1.04
|
@@ -10,6 +10,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
|
|
||||||
|
#define I2C_EE_ADDRESS 0x50
|
||||||
#define EEPROM_SIZE_BYTES I2C_DEVICESIZE_24LC64
|
#define EEPROM_SIZE_BYTES I2C_DEVICESIZE_24LC64
|
||||||
#define EEPROM_ENDURANCE 1000000
|
#define EEPROM_ENDURANCE 1000000
|
||||||
|
|
||||||
@@ -51,9 +52,9 @@ typedef struct
|
|||||||
uint8_t EEPROM_Version;
|
uint8_t EEPROM_Version;
|
||||||
batteryType_t batteryType;
|
batteryType_t batteryType;
|
||||||
bool active_faction_on_reboot;
|
bool active_faction_on_reboot;
|
||||||
char Faction_1_Name[32];
|
char Faction_1_Name[33];
|
||||||
char Faction_2_Name[32];
|
char Faction_2_Name[33];
|
||||||
char Faction_3_Name[32];
|
char Faction_3_Name[33];
|
||||||
uint32_t checksum;
|
uint32_t checksum;
|
||||||
} configData_t;
|
} configData_t;
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
@@ -58,8 +59,8 @@ typedef struct Constants_s
|
|||||||
} Constants_t;
|
} Constants_t;
|
||||||
|
|
||||||
const Constants_t constants PROGMEM = {
|
const Constants_t constants PROGMEM = {
|
||||||
1,2, // Firmware_Version
|
1,5, // Firmware_Version
|
||||||
1,2, // Required Flash Version
|
1,4, // Required Flash Version
|
||||||
GIT_REV // Git-Hash-String
|
GIT_REV // Git-Hash-String
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -2,10 +2,16 @@
|
|||||||
#define _LORA_NET_H_
|
#define _LORA_NET_H_
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#ifdef LORA_FEATURE_ENABLED
|
||||||
#include <LoRa_E220.h>
|
#include <LoRa_E220.h>
|
||||||
|
#elif defined(FEATURE_ENABLE_UARTLORA)
|
||||||
|
#include <SoftwareSerial.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "lora_messages.h"
|
#include "lora_messages.h"
|
||||||
|
#include "debugger.h"
|
||||||
#include "defaults.h"
|
#include "defaults.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
@@ -14,6 +14,9 @@
|
|||||||
#error "You must define an WIFI_AP_PASSWORD for Standalone AP-Mode"
|
#error "You must define an WIFI_AP_PASSWORD for Standalone AP-Mode"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(FEATURE_ENABLE_UARTLORA) && defined(FEATURE_ENABLE_LORA)
|
||||||
|
#error "You cannot enable LoRa and UART-Protocol at the same time!"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_WIFI_CLIENT
|
#ifdef FEATURE_ENABLE_WIFI_CLIENT
|
||||||
#ifndef WIFI_CLIENT_PASSWORD
|
#ifndef WIFI_CLIENT_PASSWORD
|
||||||
|
@@ -22,24 +22,22 @@ upload_speed = 921600
|
|||||||
;upload_port = 10.0.1.48
|
;upload_port = 10.0.1.48
|
||||||
;upload_protocol = espota
|
;upload_protocol = espota
|
||||||
;upload_flags =
|
;upload_flags =
|
||||||
; --auth=${wifi_cred.admin_password}
|
; --auth=${wifi_cred.ota_password}
|
||||||
|
|
||||||
build_flags=
|
build_flags=
|
||||||
!python git_rev_macro.py
|
!python git_rev_macro.py
|
||||||
-DATOMIC_FS_UPDATE
|
-DATOMIC_FS_UPDATE
|
||||||
-DFEATURE_ENABLE_WIFI_CLIENT
|
;-DFEATURE_ENABLE_WIFI_CLIENT
|
||||||
-DFEATURE_ENABLE_LORA
|
;-DFEATURE_ENABLE_LORA
|
||||||
;-DCAPTIVE
|
;-DCAPTIVE
|
||||||
|
-DFEATURE_ENABLE_UARTLORA
|
||||||
-DWIFI_AP_IP_GW=10,0,0,1
|
-DWIFI_AP_IP_GW=10,0,0,1
|
||||||
-DADMIN_PASSWORD=${wifi_cred.admin_password}
|
-DADMIN_PASSWORD=${wifi_cred.ota_password}
|
||||||
-DWIFI_CLIENT_SSID=${wifi_cred.wifi_client_ssid}
|
-DWIFI_CLIENT_SSID=${wifi_cred.wifi_client_ssid}
|
||||||
-DWIFI_CLIENT_PASSWORD=${wifi_cred.wifi_client_password}
|
-DWIFI_CLIENT_PASSWORD=${wifi_cred.wifi_client_password}
|
||||||
-DWIFI_AP_SSID=${wifi_cred.wifi_ap_ssid}
|
-DWIFI_AP_SSID=${wifi_cred.wifi_ap_ssid}
|
||||||
-DWIFI_AP_PASSWORD=${wifi_cred.wifi_ap_password}
|
-DWIFI_AP_PASSWORD=${wifi_cred.wifi_ap_password}
|
||||||
-DDEVICE_NAME='"Dark Emergency Timer"'
|
-DDEVICE_NAME='"Dark Emergency Timer"'
|
||||||
-DFACTION_1_NAME='"GOF"'
|
|
||||||
-DFACTION_2_NAME='"KGG"'
|
|
||||||
-DFACTION_3_NAME='"MILIZ"'
|
|
||||||
|
|
||||||
;build_type = debug
|
;build_type = debug
|
||||||
|
|
||||||
|
@@ -293,7 +293,7 @@ void Debug_printHelp()
|
|||||||
{
|
{
|
||||||
char buff[64];
|
char buff[64];
|
||||||
|
|
||||||
for (int i = sizeof(helpCmd) / 63; i < sizeof(helpCmd) / 63; i++)
|
for (unsigned int i = sizeof(helpCmd) / 63; i < sizeof(helpCmd) / 63; i++)
|
||||||
{
|
{
|
||||||
memcpy_P(buff, (helpCmd + (i * 63)), 63);
|
memcpy_P(buff, (helpCmd + (i * 63)), 63);
|
||||||
buff[63] = 0;
|
buff[63] = 0;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
|
|
||||||
I2C_eeprom ee(0x50, EEPROM_SIZE_BYTES);
|
I2C_eeprom ee(I2C_EE_ADDRESS, EEPROM_SIZE_BYTES);
|
||||||
|
|
||||||
configData_t ConfigData;
|
configData_t ConfigData;
|
||||||
persistenceData_t PersistenceData;
|
persistenceData_t PersistenceData;
|
||||||
@@ -15,6 +15,7 @@ void InitEEPROM()
|
|||||||
ee.begin();
|
ee.begin();
|
||||||
eeAvailable = checkEEPROMavailable();
|
eeAvailable = checkEEPROMavailable();
|
||||||
eeAvailable = ValidateEEPROM_Version();
|
eeAvailable = ValidateEEPROM_Version();
|
||||||
|
Serial.printf("Initialized EEPROM at Address 0x%02X\n", I2C_EE_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EEPROM_Process()
|
void EEPROM_Process()
|
||||||
@@ -75,12 +76,12 @@ void EEPROM_Process()
|
|||||||
|
|
||||||
void StoreConfig_EEPROM()
|
void StoreConfig_EEPROM()
|
||||||
{
|
{
|
||||||
ConfigData.checksum = 0;
|
|
||||||
ConfigData.checksum = Checksum_EEPROM((uint8_t *)&ConfigData, sizeof(ConfigData));
|
|
||||||
|
|
||||||
if (eeAvailable == false)
|
if (eeAvailable == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ConfigData.checksum = 0;
|
||||||
|
ConfigData.checksum = Checksum_EEPROM((uint8_t *)&ConfigData, sizeof(ConfigData));
|
||||||
|
|
||||||
ee.updateBlock(startofConfigData, (uint8_t *)&ConfigData, sizeof(ConfigData));
|
ee.updateBlock(startofConfigData, (uint8_t *)&ConfigData, sizeof(ConfigData));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,9 +112,6 @@ void GetConfig_EEPROM()
|
|||||||
|
|
||||||
void StorePersistence_EEPROM()
|
void StorePersistence_EEPROM()
|
||||||
{
|
{
|
||||||
PersistenceData.checksum = 0;
|
|
||||||
PersistenceData.checksum = Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData));
|
|
||||||
|
|
||||||
if (eeAvailable == false)
|
if (eeAvailable == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -122,6 +120,9 @@ void StorePersistence_EEPROM()
|
|||||||
else
|
else
|
||||||
PersistenceData.writeCycleCounter++;
|
PersistenceData.writeCycleCounter++;
|
||||||
|
|
||||||
|
PersistenceData.checksum = 0;
|
||||||
|
PersistenceData.checksum = Checksum_EEPROM((uint8_t *)&PersistenceData, sizeof(PersistenceData));
|
||||||
|
|
||||||
ee.updateBlock(globals.eePersistanceAdress, (uint8_t *)&PersistenceData, sizeof(PersistenceData));
|
ee.updateBlock(globals.eePersistanceAdress, (uint8_t *)&PersistenceData, sizeof(PersistenceData));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,6 +163,7 @@ void FormatConfig_EEPROM()
|
|||||||
Serial.println("Formatting Config-Partition");
|
Serial.println("Formatting Config-Partition");
|
||||||
ConfigData = ConfigData_defaults;
|
ConfigData = ConfigData_defaults;
|
||||||
StoreConfig_EEPROM();
|
StoreConfig_EEPROM();
|
||||||
|
GetConfig_EEPROM();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormatPersistence_EEPROM()
|
void FormatPersistence_EEPROM()
|
||||||
@@ -170,8 +172,9 @@ void FormatPersistence_EEPROM()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Serial.println("Formatting Persistance-Partition");
|
Serial.println("Formatting Persistance-Partition");
|
||||||
memset(&PersistenceData, 0, sizeof(PersistenceData));
|
PersistenceData = {0};
|
||||||
StorePersistence_EEPROM();
|
StorePersistence_EEPROM();
|
||||||
|
GetPersistence_EEPROM();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovePersistencePage_EEPROM(boolean reset)
|
void MovePersistencePage_EEPROM(boolean reset)
|
||||||
@@ -277,7 +280,7 @@ bool ValidateEEPROM_Version()
|
|||||||
|
|
||||||
if (EEPROMVersionOnChip < ConfigData_defaults.EEPROM_Version)
|
if (EEPROMVersionOnChip < ConfigData_defaults.EEPROM_Version)
|
||||||
{
|
{
|
||||||
Serial.printf("EEPROM Image Version is %d, but %d expected - trying to migrate\n");
|
Serial.printf("EEPROM Image Version is %d, but %d expected - trying to migrate\n", EEPROMVersionOnChip, ConfigData_defaults.EEPROM_Version);
|
||||||
if (!MigrateEEPROM(EEPROMVersionOnChip))
|
if (!MigrateEEPROM(EEPROMVersionOnChip))
|
||||||
{
|
{
|
||||||
Serial.print("Error\n");
|
Serial.print("Error\n");
|
||||||
@@ -322,26 +325,28 @@ bool MigrateEEPROM(uint8_t fromVersion)
|
|||||||
// } persistenceData_t;
|
// } persistenceData_t;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
// Migrate Persistance-Data
|
||||||
|
ee.readBlock(0, (uint8_t *)&persistanceMarker_onChip, sizeof(uint16_t));
|
||||||
|
if (persistanceMarker_onChip < startofPersistence)
|
||||||
|
{
|
||||||
|
ee.readBlock(persistanceMarker_onChip + 0, (uint8_t *)&PersistenceData.writeCycleCounter, 4);
|
||||||
|
ee.readBlock(persistanceMarker_onChip + 4, (uint8_t *)&PersistenceData.faction_1_timer, 4);
|
||||||
|
ee.readBlock(persistanceMarker_onChip + 8, (uint8_t *)&PersistenceData.faction_2_timer, 4);
|
||||||
|
ee.readBlock(persistanceMarker_onChip + 12, (uint8_t *)&PersistenceData.faction_3_timer, 4);
|
||||||
|
ee.readBlock(persistanceMarker_onChip + 16, (uint8_t *)&PersistenceData.activeFaction, 4);
|
||||||
|
ee.readBlock(persistanceMarker_onChip + 20, (uint8_t *)&PersistenceData.checksum, 4);
|
||||||
|
MovePersistencePage_EEPROM(true);
|
||||||
|
StorePersistence_EEPROM();
|
||||||
|
}
|
||||||
|
|
||||||
// Migrate Config-Data and set defaults for Values which doesn't exists in this earlier Version
|
// Migrate Config-Data and set defaults for Values which doesn't exists in this earlier Version
|
||||||
ConfigData.EEPROM_Version = ConfigData_defaults.EEPROM_Version;
|
ConfigData.EEPROM_Version = ConfigData_defaults.EEPROM_Version;
|
||||||
strncpy(ConfigData.Faction_1_Name, ConfigData_defaults.Faction_1_Name, sizeof(ConfigData.Faction_1_Name));
|
strncpy(ConfigData.Faction_1_Name, ConfigData_defaults.Faction_1_Name, sizeof(ConfigData.Faction_1_Name));
|
||||||
strncpy(ConfigData.Faction_2_Name, ConfigData_defaults.Faction_2_Name, sizeof(ConfigData.Faction_2_Name));
|
strncpy(ConfigData.Faction_2_Name, ConfigData_defaults.Faction_2_Name, sizeof(ConfigData.Faction_2_Name));
|
||||||
strncpy(ConfigData.Faction_3_Name, ConfigData_defaults.Faction_3_Name, sizeof(ConfigData.Faction_3_Name));
|
strncpy(ConfigData.Faction_3_Name, ConfigData_defaults.Faction_3_Name, sizeof(ConfigData.Faction_3_Name));
|
||||||
ee.readBlock(17, (uint8_t *)&ConfigData.batteryType, 4);
|
ee.readBlock(17, (uint8_t *)&ConfigData.batteryType, 4);
|
||||||
ee.readBlock(21, (uint8_t *)ConfigData.active_faction_on_reboot, 1);
|
ee.readBlock(21, (uint8_t *)&ConfigData.active_faction_on_reboot, 1);
|
||||||
|
StoreConfig_EEPROM();
|
||||||
// Migrate Persistance-Data
|
|
||||||
ee.readBlock(0, (uint8_t *)&persistanceMarker_onChip, sizeof(uint16_t));
|
|
||||||
if (persistanceMarker_onChip < startofPersistence)
|
|
||||||
{
|
|
||||||
ee.readBlock(persistanceMarker_onChip + 0, (uint8_t *)PersistenceData.writeCycleCounter, 4);
|
|
||||||
ee.readBlock(persistanceMarker_onChip + 4, (uint8_t *)PersistenceData.faction_1_timer, 4);
|
|
||||||
ee.readBlock(persistanceMarker_onChip + 8, (uint8_t *)PersistenceData.faction_2_timer, 4);
|
|
||||||
ee.readBlock(persistanceMarker_onChip + 12, (uint8_t *)PersistenceData.faction_3_timer, 4);
|
|
||||||
ee.readBlock(persistanceMarker_onChip + 16, (uint8_t *)PersistenceData.activeFaction, 4);
|
|
||||||
ee.readBlock(persistanceMarker_onChip + 20, (uint8_t *)PersistenceData.checksum, 4);
|
|
||||||
MovePersistencePage_EEPROM(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
|
@@ -1,13 +1,19 @@
|
|||||||
#include "lora_net.h"
|
#include "lora_net.h"
|
||||||
|
|
||||||
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
LoRa_E220 e220ttl(GPIO_LORA_TX, GPIO_LORA_RX, GPIO_LORA_AUX, 3, 4); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
LoRa_E220 e220ttl(GPIO_LORA_TX, GPIO_LORA_RX, GPIO_LORA_AUX, 3, 4); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||||
|
|
||||||
void printParameters(struct Configuration configuration);
|
void printParameters(struct Configuration configuration);
|
||||||
void printModuleInformation(struct ModuleInformation moduleInformation);
|
void printModuleInformation(struct ModuleInformation moduleInformation);
|
||||||
|
#elif defined(FEATURE_ENABLE_UARTLORA)
|
||||||
|
SoftwareSerial SerialLoRa(GPIO_LORA_RX, GPIO_LORA_TX); // RX, TX
|
||||||
|
void Parse_LoRa_UartCommand(char input[], int size);
|
||||||
|
#endif
|
||||||
|
|
||||||
bool InitLoRa(void (*MPinHelper)(int, int))
|
bool InitLoRa(void (*MPinHelper)(int, int))
|
||||||
{
|
{
|
||||||
bool returnval;
|
bool returnval = false;
|
||||||
|
|
||||||
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
|
|
||||||
e220ttl.setMPins = MPinHelper;
|
e220ttl.setMPins = MPinHelper;
|
||||||
returnval = e220ttl.begin();
|
returnval = e220ttl.begin();
|
||||||
@@ -60,11 +66,16 @@ 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)
|
||||||
|
SerialLoRa.begin(9600);
|
||||||
|
returnval = true;
|
||||||
|
#endif
|
||||||
return returnval;
|
return returnval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoRa_Process()
|
void LoRa_Process()
|
||||||
{
|
{
|
||||||
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
if (e220ttl.available() > 1)
|
if (e220ttl.available() > 1)
|
||||||
{
|
{
|
||||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||||
@@ -82,10 +93,45 @@ void LoRa_Process()
|
|||||||
Serial.println(rc.rssi, DEC);
|
Serial.println(rc.rssi, DEC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif defined(FEATURE_ENABLE_UARTLORA)
|
||||||
|
|
||||||
|
static char packageInput[32];
|
||||||
|
static bool packageRecieved = false;
|
||||||
|
static unsigned int bufferPtr = 0;
|
||||||
|
int recievedSize = 0;
|
||||||
|
|
||||||
|
while (SerialLoRa.available() && packageRecieved == false)
|
||||||
|
{
|
||||||
|
if (bufferPtr < sizeof(packageInput) - 1)
|
||||||
|
{
|
||||||
|
packageInput[bufferPtr] = SerialLoRa.read();
|
||||||
|
packageInput[bufferPtr + 1] = 0; // always terminate String
|
||||||
|
|
||||||
|
if (packageInput[bufferPtr] == '\n')
|
||||||
|
{
|
||||||
|
packageRecieved = true;
|
||||||
|
recievedSize = bufferPtr;
|
||||||
|
bufferPtr = 0;
|
||||||
|
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
|
||||||
|
{
|
||||||
|
bufferPtr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packageRecieved) {
|
||||||
|
Parse_LoRa_UartCommand(packageInput, recievedSize);
|
||||||
|
packageRecieved = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendStatus_LoRa()
|
void sendStatus_LoRa()
|
||||||
{
|
{
|
||||||
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
MessageType_t type = "STATUS";
|
MessageType_t type = "STATUS";
|
||||||
@@ -101,8 +147,25 @@ 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)
|
||||||
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FEATURE_ENABLE_LORA
|
||||||
|
|
||||||
void printParameters(struct Configuration configuration)
|
void printParameters(struct Configuration configuration)
|
||||||
{
|
{
|
||||||
Serial.println("----------------------------------------");
|
Serial.println("----------------------------------------");
|
||||||
@@ -168,4 +231,92 @@ void printParameters(struct Configuration configuration)
|
|||||||
Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
||||||
|
|
||||||
Serial.println("----------------------------------------");
|
Serial.println("----------------------------------------");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FEATURE_ENABLE_UARTLORA
|
||||||
|
void Parse_LoRa_UartCommand(char input[], int size)
|
||||||
|
{
|
||||||
|
|
||||||
|
Debug_pushMessage("Start parsing, size: %d", size);
|
||||||
|
char delimiter[] = ";";
|
||||||
|
char *ptr;
|
||||||
|
char command[8];
|
||||||
|
char value[8];
|
||||||
|
|
||||||
|
ptr = strtok(input, delimiter);
|
||||||
|
|
||||||
|
ptr = strtok(input, delimiter);
|
||||||
|
|
||||||
|
while (ptr != NULL)
|
||||||
|
{
|
||||||
|
strncpy(command, ptr, sizeof(command) - 1); // Platz für Nullterminator lassen
|
||||||
|
command[sizeof(command) - 1] = '\0'; // Nullterminator setzen
|
||||||
|
|
||||||
|
ptr = strtok(NULL, delimiter);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (!strcmp(command, "ENABLE"))
|
||||||
|
{
|
||||||
|
globals.timer_disabled = false;
|
||||||
|
Debug_pushMessage("Enabled by LoRa");
|
||||||
|
}
|
||||||
|
else if (!strcmp(command, "DISABLE"))
|
||||||
|
{
|
||||||
|
globals.timer_disabled = true;
|
||||||
|
Debug_pushMessage("Disabled by LoRa");
|
||||||
|
}
|
||||||
|
else if (!strcmp(command, "RESET"))
|
||||||
|
{
|
||||||
|
PersistenceData.activeFaction = NONE;
|
||||||
|
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"))
|
||||||
|
{
|
||||||
|
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
|
@@ -19,7 +19,7 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "dtc.h"
|
#include "dtc.h"
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
#if defined(FEATURE_ENABLE_LORA) || defined(FEATURE_ENABLE_UARTLORA)
|
||||||
#include "lora_net.h"
|
#include "lora_net.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ void OverrideDisplay(uint32_t time, const char *message1, const char *message2,
|
|||||||
void initGlobals();
|
void initGlobals();
|
||||||
void maintainSysStat();
|
void maintainSysStat();
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
#if defined(FEATURE_ENABLE_UARTLORA) || defined(FEATURE_ENABLE_LORA)
|
||||||
void setMPins_Helper(int pin, int status);
|
void setMPins_Helper(int pin, int status);
|
||||||
void tmrCallback_StatusSender();
|
void tmrCallback_StatusSender();
|
||||||
Ticker tmrStatusSender(tmrCallback_StatusSender, 30000, 0, MILLIS);
|
Ticker tmrStatusSender(tmrCallback_StatusSender, 30000, 0, MILLIS);
|
||||||
@@ -72,7 +72,7 @@ Ticker tmrWiFiMaintainConnection(tmrCallback_WiFiMaintainConnection, 1000, 0, MI
|
|||||||
uint32_t DisplayOverrideFlag = 0;
|
uint32_t DisplayOverrideFlag = 0;
|
||||||
char DisplayOverrideValue[3][5] = {0};
|
char DisplayOverrideValue[3][5] = {0};
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
#if defined(FEATURE_ENABLE_UARTLORA) || defined(FEATURE_ENABLE_LORA)
|
||||||
void setMPins_Helper(int pin, int status)
|
void setMPins_Helper(int pin, int status)
|
||||||
{
|
{
|
||||||
i2c_io.write(pin, status);
|
i2c_io.write(pin, status);
|
||||||
@@ -99,7 +99,6 @@ void setup()
|
|||||||
InitEEPROM();
|
InitEEPROM();
|
||||||
GetConfig_EEPROM();
|
GetConfig_EEPROM();
|
||||||
GetPersistence_EEPROM();
|
GetPersistence_EEPROM();
|
||||||
Serial.print("EE-Init done\n");
|
|
||||||
|
|
||||||
if (i2c_io.begin())
|
if (i2c_io.begin())
|
||||||
{
|
{
|
||||||
@@ -120,7 +119,7 @@ void setup()
|
|||||||
Serial.print("INA219 not Initialized\n");
|
Serial.print("INA219 not Initialized\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
#if defined(FEATURE_ENABLE_UARTLORA) || defined(FEATURE_ENABLE_LORA)
|
||||||
if (InitLoRa(&setMPins_Helper))
|
if (InitLoRa(&setMPins_Helper))
|
||||||
{
|
{
|
||||||
Serial.print("Initialized LoRa_Transceiver\n");
|
Serial.print("Initialized LoRa_Transceiver\n");
|
||||||
@@ -230,9 +229,9 @@ void loop()
|
|||||||
DTC_Process();
|
DTC_Process();
|
||||||
Debug_Process();
|
Debug_Process();
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
#if defined(FEATURE_ENABLE_LORA) || defined(FEATURE_ENABLE_UARTLORA)
|
||||||
tmrStatusSender.update();
|
|
||||||
LoRa_Process();
|
LoRa_Process();
|
||||||
|
tmrStatusSender.update();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CAPTIVE
|
#ifdef CAPTIVE
|
||||||
@@ -290,25 +289,28 @@ void SevenSeg_Output()
|
|||||||
disp_FAC_1.refresh();
|
disp_FAC_1.refresh();
|
||||||
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4d", PersistenceData.faction_1_timer / 60);
|
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4d", PersistenceData.faction_1_timer / 60);
|
||||||
disp_FAC_1.display(String(sevenSegBuff), false, false);
|
disp_FAC_1.display(String(sevenSegBuff), false, false);
|
||||||
disp_FAC_1.setDp((PersistenceData.activeFaction == FACTION_1) && (millis() % 1000 > 500));
|
disp_FAC_1.setDp((PersistenceData.activeFaction == FACTION_1) && (millis() % 1000 > 500) ? 0x08 : 0x00);
|
||||||
|
|
||||||
disp_FAC_2.setBrightness(PersistenceData.activeFaction == FACTION_2 ? 5 : 1);
|
disp_FAC_2.setBrightness(PersistenceData.activeFaction == FACTION_2 ? 5 : 1);
|
||||||
disp_FAC_2.refresh();
|
disp_FAC_2.refresh();
|
||||||
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4d", PersistenceData.faction_2_timer / 60);
|
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4d", PersistenceData.faction_2_timer / 60);
|
||||||
disp_FAC_2.display(String(sevenSegBuff), false, false);
|
disp_FAC_2.display(String(sevenSegBuff), false, false);
|
||||||
disp_FAC_2.setDp((PersistenceData.activeFaction == FACTION_2) && (millis() % 1000 > 500));
|
disp_FAC_2.setDp((PersistenceData.activeFaction == FACTION_2) && (millis() % 1000 > 500) ? 0x08 : 0x00);
|
||||||
|
|
||||||
disp_FAC_3.setBrightness(PersistenceData.activeFaction == FACTION_3 ? 5 : 1);
|
disp_FAC_3.setBrightness(PersistenceData.activeFaction == FACTION_3 ? 5 : 1);
|
||||||
disp_FAC_3.refresh();
|
disp_FAC_3.refresh();
|
||||||
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4d", PersistenceData.faction_3_timer / 60);
|
snprintf(sevenSegBuff, sizeof(sevenSegBuff), "%4d", PersistenceData.faction_3_timer / 60);
|
||||||
disp_FAC_3.display(String(sevenSegBuff), false, false);
|
disp_FAC_3.display(String(sevenSegBuff), false, false);
|
||||||
disp_FAC_3.setDp((PersistenceData.activeFaction == FACTION_3) && (millis() % 1000 > 500));
|
disp_FAC_3.setDp((PersistenceData.activeFaction == FACTION_3) && (millis() % 1000 > 500) ? 0x08 : 0x00);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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:
|
||||||
@@ -345,43 +347,43 @@ void tmrCallback_InputGetter()
|
|||||||
|
|
||||||
if (keysPressed > 1)
|
if (keysPressed > 1)
|
||||||
{
|
{
|
||||||
Serial.println("ERROR: More than one Flag active - setting no Faction active");
|
Debug_pushMessage("ERROR: More than one Flag active - setting no Faction active");
|
||||||
PersistenceData.activeFaction = NONE;
|
PersistenceData.activeFaction = NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btnState[0] == FAC_1_TRG_PRESSED)
|
if (btnState[0] == FAC_1_TRG_PRESSED && globals.timer_disabled != true)
|
||||||
{
|
{
|
||||||
if (PersistenceData.activeFaction != FACTION_1)
|
if (PersistenceData.activeFaction != FACTION_1)
|
||||||
{
|
{
|
||||||
Serial.println("Faction 1 captured !");
|
Debug_pushMessage("Faction 1 captured !");
|
||||||
globals.requestEEAction = EE_PDS_SAVE;
|
globals.requestEEAction = EE_PDS_SAVE;
|
||||||
}
|
}
|
||||||
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 != true)
|
||||||
{
|
{
|
||||||
if (PersistenceData.activeFaction != FACTION_2)
|
if (PersistenceData.activeFaction != FACTION_2)
|
||||||
{
|
{
|
||||||
Serial.println("Faction 2 captured !");
|
Debug_pushMessage("Faction 2 captured !");
|
||||||
globals.requestEEAction = EE_PDS_SAVE;
|
globals.requestEEAction = EE_PDS_SAVE;
|
||||||
}
|
}
|
||||||
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 != true)
|
||||||
{
|
{
|
||||||
if (PersistenceData.activeFaction != FACTION_3)
|
if (PersistenceData.activeFaction != FACTION_3)
|
||||||
{
|
{
|
||||||
Serial.println("Faction 3 captured !");
|
Debug_pushMessage("Faction 3 captured !");
|
||||||
globals.requestEEAction = EE_PDS_SAVE;
|
globals.requestEEAction = EE_PDS_SAVE;
|
||||||
}
|
}
|
||||||
PersistenceData.activeFaction = FACTION_3;
|
PersistenceData.activeFaction = FACTION_3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FEATURE_ENABLE_LORA
|
#if defined(FEATURE_ENABLE_LORA) || defined(FEATURE_ENABLE_UARTLORA)
|
||||||
void tmrCallback_StatusSender()
|
void tmrCallback_StatusSender()
|
||||||
{
|
{
|
||||||
sendStatus_LoRa();
|
sendStatus_LoRa();
|
||||||
@@ -565,17 +567,17 @@ void ProcessKeyCombos(bool *btnState)
|
|||||||
if (btnState[0] != FAC_1_TRG_PRESSED && keyStatus_Fac1 == KEY_PRESSED)
|
if (btnState[0] != FAC_1_TRG_PRESSED && keyStatus_Fac1 == KEY_PRESSED)
|
||||||
{
|
{
|
||||||
if (keyCount_Fac2 > 0 || keyCount_Fac3 > 0)
|
if (keyCount_Fac2 > 0 || keyCount_Fac3 > 0)
|
||||||
Serial.printf("KeyCombo 2: %d | 3: %d\n", keyCount_Fac2, keyCount_Fac3);
|
Debug_pushMessage("KeyCombo 2: %d | 3: %d\n", keyCount_Fac2, keyCount_Fac3);
|
||||||
|
|
||||||
if (keyCount_Fac2 == 2 && keyCount_Fac3 == 0)
|
if (keyCount_Fac2 == 2 && keyCount_Fac3 == 0)
|
||||||
{
|
{
|
||||||
Serial.println("KeyCombo: WiFi AP ON");
|
Debug_pushMessage("KeyCombo: WiFi AP ON");
|
||||||
OverrideDisplay(5000, "NET ", " ", " ");
|
OverrideDisplay(5000, "NET ", " ", " ");
|
||||||
toggleWiFiAP(false);
|
toggleWiFiAP(false);
|
||||||
}
|
}
|
||||||
else if (keyCount_Fac2 == 4 && keyCount_Fac3 == 0)
|
else if (keyCount_Fac2 == 4 && keyCount_Fac3 == 0)
|
||||||
{
|
{
|
||||||
Serial.printf("KeyCombo: Reset Timer\n");
|
Debug_pushMessage("KeyCombo: Reset Timer\n");
|
||||||
if (globals.systemStatus == sysStat_Startup)
|
if (globals.systemStatus == sysStat_Startup)
|
||||||
{
|
{
|
||||||
OverrideDisplay(5000, "RST ", " ", " ");
|
OverrideDisplay(5000, "RST ", " ", " ");
|
||||||
@@ -588,7 +590,7 @@ void ProcessKeyCombos(bool *btnState)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
OverrideDisplay(5000, "ERR ", " ", " ");
|
OverrideDisplay(5000, "ERR ", " ", " ");
|
||||||
Serial.printf("ERROR: only %d seconds after Startup!\n", STARTUP_DELAY_MS / 1000);
|
Debug_pushMessage("ERROR: only %d seconds after Startup!\n", STARTUP_DELAY_MS / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,10 +33,10 @@ void OLED_Process()
|
|||||||
display.setCursor(0, 0);
|
display.setCursor(0, 0);
|
||||||
display.printf("LiPo: %d%%\n", globals.battery_level);
|
display.printf("LiPo: %d%%\n", globals.battery_level);
|
||||||
display.print(PersistenceData.activeFaction == FACTION_1 ? "> " : " ");
|
display.print(PersistenceData.activeFaction == FACTION_1 ? "> " : " ");
|
||||||
display.printf("%-5s: %02d:%02d:%02d\n", FACTION_1_NAME, PersistenceData.faction_1_timer / 3600, (PersistenceData.faction_1_timer / 60) % 60, PersistenceData.faction_1_timer % 60);
|
display.printf("%-5s: %02d:%02d:%02d\n", PersistenceData.faction_1_timer, PersistenceData.faction_1_timer / 3600, (PersistenceData.faction_1_timer / 60) % 60, PersistenceData.faction_1_timer % 60);
|
||||||
display.print(PersistenceData.activeFaction == FACTION_2 ? "> " : " ");
|
display.print(PersistenceData.activeFaction == FACTION_2 ? "> " : " ");
|
||||||
display.printf("%-5s: %02d:%02d:%02d\n", FACTION_2_NAME, PersistenceData.faction_2_timer / 3600, (PersistenceData.faction_2_timer / 60) % 60, PersistenceData.faction_2_timer % 60);
|
display.printf("%-5s: %02d:%02d:%02d\n", PersistenceData.faction_2_timer, PersistenceData.faction_2_timer / 3600, (PersistenceData.faction_2_timer / 60) % 60, PersistenceData.faction_2_timer % 60);
|
||||||
display.print(PersistenceData.activeFaction == FACTION_3 ? "> " : " ");
|
display.print(PersistenceData.activeFaction == FACTION_3 ? "> " : " ");
|
||||||
display.printf("%-5s: %02d:%02d:%02d\n", FACTION_3_NAME, PersistenceData.faction_3_timer / 3600, (PersistenceData.faction_3_timer / 60) % 60, PersistenceData.faction_3_timer % 60);
|
display.printf("%-5s: %02d:%02d:%02d\n", PersistenceData.faction_3_timer, PersistenceData.faction_3_timer / 3600, (PersistenceData.faction_3_timer / 60) % 60, PersistenceData.faction_3_timer % 60);
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
@@ -84,6 +84,8 @@ String processor(const String &var)
|
|||||||
return String(globals.battery_level);
|
return String(globals.battery_level);
|
||||||
if (var == "DEVICENAME")
|
if (var == "DEVICENAME")
|
||||||
return String(globals.DeviceName);
|
return String(globals.DeviceName);
|
||||||
|
if (var == "DEVICENAME_ID")
|
||||||
|
return String(globals.DeviceName_ID);
|
||||||
if (var == "BATTERY_TYPE")
|
if (var == "BATTERY_TYPE")
|
||||||
return String(ConfigData.batteryType);
|
return String(ConfigData.batteryType);
|
||||||
if (var == "BAT_VOLTAGE")
|
if (var == "BAT_VOLTAGE")
|
||||||
@@ -180,14 +182,21 @@ String processor(const String &var)
|
|||||||
if (var == "ACTIVE_FACTION")
|
if (var == "ACTIVE_FACTION")
|
||||||
return String(PersistenceData.activeFaction);
|
return String(PersistenceData.activeFaction);
|
||||||
|
|
||||||
|
if (var == "FACTION_1_ACTIVE")
|
||||||
|
return String(PersistenceData.activeFaction == FACTION_1 ? "bg-primary" : "bg-secondary");
|
||||||
|
if (var == "FACTION_2_ACTIVE")
|
||||||
|
return String(PersistenceData.activeFaction == FACTION_2 ? "bg-primary" : "bg-secondary");
|
||||||
|
if (var == "FACTION_3_ACTIVE")
|
||||||
|
return String(PersistenceData.activeFaction == FACTION_3 ? "bg-primary" : "bg-secondary");
|
||||||
|
|
||||||
if (var == "NAME_FAC_1")
|
if (var == "NAME_FAC_1")
|
||||||
return FACTION_1_NAME;
|
return String(ConfigData.Faction_1_Name);
|
||||||
|
|
||||||
if (var == "NAME_FAC_2")
|
if (var == "NAME_FAC_2")
|
||||||
return FACTION_2_NAME;
|
return String(ConfigData.Faction_2_Name);
|
||||||
|
|
||||||
if (var == "NAME_FAC_3")
|
if (var == "NAME_FAC_3")
|
||||||
return FACTION_3_NAME;
|
return String(ConfigData.Faction_3_Name);
|
||||||
|
|
||||||
if (var == "BATTERY_SELECT_OPTIONS")
|
if (var == "BATTERY_SELECT_OPTIONS")
|
||||||
{
|
{
|
||||||
@@ -273,6 +282,19 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
|
|||||||
ConfigData.active_faction_on_reboot = false;
|
ConfigData.active_faction_on_reboot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p->name() == "faction_1_name")
|
||||||
|
{
|
||||||
|
strncpy(ConfigData.Faction_1_Name, p->value().c_str(), sizeof(ConfigData.Faction_1_Name));
|
||||||
|
}
|
||||||
|
if (p->name() == "faction_2_name")
|
||||||
|
{
|
||||||
|
strncpy(ConfigData.Faction_2_Name, p->value().c_str(), sizeof(ConfigData.Faction_2_Name));
|
||||||
|
}
|
||||||
|
if (p->name() == "faction_3_name")
|
||||||
|
{
|
||||||
|
strncpy(ConfigData.Faction_3_Name, p->value().c_str(), sizeof(ConfigData.Faction_3_Name));
|
||||||
|
}
|
||||||
|
|
||||||
if (p->name() == "settingssave")
|
if (p->name() == "settingssave")
|
||||||
globals.requestEEAction = EE_CFG_SAVE;
|
globals.requestEEAction = EE_CFG_SAVE;
|
||||||
// end: POST Form Settings
|
// end: POST Form Settings
|
||||||
@@ -385,6 +407,9 @@ void WebserverEERestore_Callback(AsyncWebServerRequest *request, const String &f
|
|||||||
|
|
||||||
ConfigData.batteryType = (batteryType_t)doc["config"]["batteryType"].as<uint32_t>();
|
ConfigData.batteryType = (batteryType_t)doc["config"]["batteryType"].as<uint32_t>();
|
||||||
ConfigData.EEPROM_Version = doc["config"]["EEPROM_Version"].as<uint32_t>();
|
ConfigData.EEPROM_Version = doc["config"]["EEPROM_Version"].as<uint32_t>();
|
||||||
|
strncpy(ConfigData.Faction_1_Name, doc["config"]["Faction_1_Name"].as<String>().c_str(), sizeof(ConfigData.Faction_1_Name));
|
||||||
|
strncpy(ConfigData.Faction_2_Name, doc["config"]["Faction_2_Name"].as<String>().c_str(), sizeof(ConfigData.Faction_2_Name));
|
||||||
|
strncpy(ConfigData.Faction_3_Name, doc["config"]["Faction_3_Name"].as<String>().c_str(), sizeof(ConfigData.Faction_3_Name));
|
||||||
|
|
||||||
PersistenceData.writeCycleCounter = doc["persis"]["writeCycleCounter"].as<uint16_t>();
|
PersistenceData.writeCycleCounter = doc["persis"]["writeCycleCounter"].as<uint16_t>();
|
||||||
PersistenceData.activeFaction = (factions_t)doc["persis"]["activeFaction"].as<uint32_t>();
|
PersistenceData.activeFaction = (factions_t)doc["persis"]["activeFaction"].as<uint32_t>();
|
||||||
@@ -434,6 +459,9 @@ void WebServerEEJSON_Callback(AsyncWebServerRequest *request)
|
|||||||
|
|
||||||
config["EEPROM_Version"] = ConfigData.EEPROM_Version;
|
config["EEPROM_Version"] = ConfigData.EEPROM_Version;
|
||||||
config["batteryType"] = ConfigData.batteryType;
|
config["batteryType"] = ConfigData.batteryType;
|
||||||
|
config["Faction_1_Name"] = ConfigData.Faction_1_Name;
|
||||||
|
config["Faction_2_Name"] = ConfigData.Faction_2_Name;
|
||||||
|
config["Faction_3_Name"] = ConfigData.Faction_3_Name;
|
||||||
sprintf(buffer, "0x%08X", ConfigData.checksum);
|
sprintf(buffer, "0x%08X", ConfigData.checksum);
|
||||||
config["checksum"] = buffer;
|
config["checksum"] = buffer;
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[wifi_cred]
|
[wifi_cred]
|
||||||
wifi_ap_ssid = wifi-ap-ssid
|
wifi_ap_ssid = wifi-ap-ssid
|
||||||
wifi_ap_password = wifiappass
|
wifi_ap_password = wifiappass
|
||||||
wifi_ssid = wifi-ssid
|
wifi_client_ssid = wifi-ssid
|
||||||
wifi_password = wifi-pass
|
wifi_client_password = wifi-pass
|
||||||
admin_password = ota-password
|
ota_password = ota-password
|
Reference in New Issue
Block a user