Skip to content

Commit

Permalink
Merge pull request #107 from lora-aprs/release-21.35.0
Browse files Browse the repository at this point in the history
Version 21.35.0
  • Loading branch information
peterus authored Sep 1, 2021
2 parents bf7e833 + c4bb41f commit ebf89f0
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 6 deletions.
8 changes: 8 additions & 0 deletions data/is-cfg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"callsign": "NOCALL-10",
"network": {
"DHCP": true,
"staticIP": "192.0.2.100",
"subnet": "255.255.255.0",
"gateway": "192.0.2.1",
"dns1": "192.0.2.1",
"dns2": "192.0.2.2"
},
"wifi": {
"AP": [
{
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ check_skip_packages = yes

[env:lora_board]
board = esp32doit-devkit-v1
build_flags = -Werror -Wall -DCORE_DEBUG_LEVEL=5
build_flags = -Werror -Wall

[env:lora_board_debug]
board = esp32doit-devkit-v1
Expand Down
2 changes: 1 addition & 1 deletion src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "TaskWifi.h"
#include "project_configuration.h"

#define VERSION "21.25.0"
#define VERSION "21.35.0"

String create_lat_aprs(double lat);
String create_long_aprs(double lng);
Expand Down
19 changes: 17 additions & 2 deletions src/TaskEth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "Task.h"
#include "TaskEth.h"
#include "project_configuration.h"

volatile bool eth_connected = false;

Expand All @@ -19,7 +20,13 @@ void WiFiEvent(WiFiEvent_t event) {
logPrintI("WiFi MAC: ");
logPrintI(WiFi.macAddress());
logPrintI(", IPv4: ");
logPrintlnI(WiFi.localIP().toString());
logPrintI(WiFi.localIP().toString());
logPrintI(", Gateway: ");
logPrintI(WiFi.gatewayIP().toString());
logPrintI(", DNS1: ");
logPrintI(WiFi.dnsIP().toString());
logPrintI(", DNS2: ");
logPrintlnI(WiFi.dnsIP(1).toString());
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
logPrintlnW("WiFi Disconnected");
Expand All @@ -39,8 +46,12 @@ void WiFiEvent(WiFiEvent_t event) {
logPrintI(ETH.macAddress());
logPrintI(", IPv4: ");
logPrintI(ETH.localIP().toString());
logPrintI(", DNS: ");
logPrintI(", Gateway: ");
logPrintI(ETH.gatewayIP().toString());
logPrintI(", DNS1: ");
logPrintI(ETH.dnsIP().toString());
logPrintI(", DNS2: ");
logPrintI(ETH.dnsIP(1).toString());
if (ETH.fullDuplex()) {
logPrintI(", FULL_DUPLEX");
}
Expand Down Expand Up @@ -89,6 +100,10 @@ bool EthTask::setup(System &system) {
delay(200);
digitalWrite(ETH_NRST, 1);

if (!system.getUserConfig()->network.DHCP) {
ETH.config(system.getUserConfig()->network.staticIP, system.getUserConfig()->network.gateway, system.getUserConfig()->network.subnet, system.getUserConfig()->network.dns1, system.getUserConfig()->network.dns2);
}

ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/TaskRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool RouterTask::loop(System &system) {
String path = digiMsg->getPath();

// simple loop check
if (path.indexOf("WIDE1-1") >= 0 || path.indexOf(system.getUserConfig()->callsign) == -1) {
if (path.indexOf("WIDE1-1") >= 0 && path.indexOf(system.getUserConfig()->callsign) == -1) {
// fixme
digiMsg->setPath(system.getUserConfig()->callsign + "*");

Expand Down
11 changes: 11 additions & 0 deletions src/TaskWifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@ WifiTask::~WifiTask() {
}

bool WifiTask::setup(System &system) {
// Don't save WiFi configuration in flash
WiFi.persistent(false);

// Set WiFi to station mode
WiFi.mode(WIFI_STA);

WiFi.onEvent(WiFiEvent);
WiFi.setHostname(system.getUserConfig()->callsign.c_str());

if (!system.getUserConfig()->network.DHCP) {
WiFi.config(system.getUserConfig()->network.staticIP, system.getUserConfig()->network.gateway, system.getUserConfig()->network.subnet, system.getUserConfig()->network.dns1, system.getUserConfig()->network.dns2);
}

for (Configuration::Wifi::AP ap : system.getUserConfig()->wifi.APs) {
logPrintD("Looking for AP: ");
logPrintlnD(ap.SSID);
Expand Down
21 changes: 20 additions & 1 deletion src/project_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen
if (data.containsKey("callsign"))
conf.callsign = data["callsign"].as<String>();

if (data.containsKey("network") && data["network"].containsKey("DHCP")) {
conf.network.DHCP = data["network"]["DHCP"];
conf.network.staticIP.fromString(data["network"]["staticIP"].as<String>());
conf.network.subnet.fromString(data["network"]["subnet"].as<String>());
conf.network.gateway.fromString(data["network"]["gateway"].as<String>());
conf.network.dns1.fromString(data["network"]["dns1"].as<String>());
conf.network.dns2.fromString(data["network"]["dns2"].as<String>());
}

JsonArray aps = data["wifi"]["AP"].as<JsonArray>();
for (JsonVariant v : aps) {
Configuration::Wifi::AP ap;
Expand Down Expand Up @@ -63,7 +72,17 @@ void ProjectConfigurationManagement::readProjectConfiguration(DynamicJsonDocumen

void ProjectConfigurationManagement::writeProjectConfiguration(Configuration &conf, DynamicJsonDocument &data) {
data["callsign"] = conf.callsign;
JsonArray aps = data["wifi"].createNestedArray("AP");

if (!conf.network.DHCP) {
data["network"]["DHCP"] = conf.network.DHCP;
data["network"]["staticIP"] = conf.network.staticIP.toString();
data["network"]["subnet"] = conf.network.subnet.toString();
data["network"]["gateway"] = conf.network.gateway.toString();
data["network"]["dns1"] = conf.network.dns1.toString();
data["network"]["dns2"] = conf.network.dns2.toString();
}

JsonArray aps = data["wifi"].createNestedArray("AP");
for (Configuration::Wifi::AP ap : conf.wifi.APs) {
JsonObject v = aps.createNestedObject();
v["SSID"] = ap.SSID;
Expand Down
14 changes: 14 additions & 0 deletions src/project_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@

class Configuration {
public:
class Network {
public:
Network() : DHCP(true) {
}

bool DHCP;
IPAddress staticIP;
IPAddress subnet;
IPAddress gateway;
IPAddress dns1;
IPAddress dns2;
};

class Wifi {
public:
class AP {
Expand Down Expand Up @@ -93,6 +106,7 @@ class Configuration {
Configuration() : callsign("NOCALL-10"), board(""), ntpServer("pool.ntp.org"){};

String callsign;
Network network;
Wifi wifi;
Beacon beacon;
APRS_IS aprs_is;
Expand Down

0 comments on commit ebf89f0

Please sign in to comment.