Formatting

This commit is contained in:
Ben Meadors 2023-01-18 15:37:23 -06:00
parent 202223236d
commit ff029ad752
4 changed files with 251 additions and 232 deletions

View File

@ -24,7 +24,8 @@ SOFTWARE.*/
#include "DebugConfiguration.h" #include "DebugConfiguration.h"
Syslog::Syslog(UDP &client) { Syslog::Syslog(UDP &client)
{
this->_client = &client; this->_client = &client;
this->_server = NULL; this->_server = NULL;
this->_port = 0; this->_port = 0;
@ -33,44 +34,52 @@ Syslog::Syslog(UDP &client) {
this->_priDefault = LOGLEVEL_KERN; this->_priDefault = LOGLEVEL_KERN;
} }
Syslog &Syslog::server(const char* server, uint16_t port) { Syslog &Syslog::server(const char *server, uint16_t port)
{
this->_server = server; this->_server = server;
this->_port = port; this->_port = port;
return *this; return *this;
} }
Syslog &Syslog::server(IPAddress ip, uint16_t port) { Syslog &Syslog::server(IPAddress ip, uint16_t port)
{
this->_ip = ip; this->_ip = ip;
this->_server = NULL; this->_server = NULL;
this->_port = port; this->_port = port;
return *this; return *this;
} }
Syslog &Syslog::deviceHostname(const char* deviceHostname) { Syslog &Syslog::deviceHostname(const char *deviceHostname)
{
this->_deviceHostname = (deviceHostname == NULL) ? SYSLOG_NILVALUE : deviceHostname; this->_deviceHostname = (deviceHostname == NULL) ? SYSLOG_NILVALUE : deviceHostname;
return *this; return *this;
} }
Syslog &Syslog::appName(const char* appName) { Syslog &Syslog::appName(const char *appName)
{
this->_appName = (appName == NULL) ? SYSLOG_NILVALUE : appName; this->_appName = (appName == NULL) ? SYSLOG_NILVALUE : appName;
return *this; return *this;
} }
Syslog &Syslog::defaultPriority(uint16_t pri) { Syslog &Syslog::defaultPriority(uint16_t pri)
{
this->_priDefault = pri; this->_priDefault = pri;
return *this; return *this;
} }
Syslog &Syslog::logMask(uint8_t priMask) { Syslog &Syslog::logMask(uint8_t priMask)
{
this->_priMask = priMask; this->_priMask = priMask;
return *this; return *this;
} }
void Syslog::enable() { void Syslog::enable()
{
this->_enabled = true; this->_enabled = true;
} }
void Syslog::disable() { void Syslog::disable()
{
this->_enabled = false; this->_enabled = false;
} }
@ -79,19 +88,23 @@ bool Syslog::isEnabled()
return this->_enabled; return this->_enabled;
} }
bool Syslog::log(uint16_t pri, const __FlashStringHelper *message) { bool Syslog::log(uint16_t pri, const __FlashStringHelper *message)
{
return this->_sendLog(pri, message); return this->_sendLog(pri, message);
} }
bool Syslog::log(uint16_t pri, const String &message) { bool Syslog::log(uint16_t pri, const String &message)
{
return this->_sendLog(pri, message.c_str()); return this->_sendLog(pri, message.c_str());
} }
bool Syslog::log(uint16_t pri, const char *message) { bool Syslog::log(uint16_t pri, const char *message)
{
return this->_sendLog(pri, message); return this->_sendLog(pri, message);
} }
bool Syslog::vlogf(uint16_t pri, const char *fmt, va_list args) { bool Syslog::vlogf(uint16_t pri, const char *fmt, va_list args)
{
char *message; char *message;
size_t initialLen; size_t initialLen;
size_t len; size_t len;
@ -115,7 +128,8 @@ bool Syslog::vlogf(uint16_t pri, const char *fmt, va_list args) {
return result; return result;
} }
bool Syslog::vlogf_P(uint16_t pri, PGM_P fmt_P, va_list args) { bool Syslog::vlogf_P(uint16_t pri, PGM_P fmt_P, va_list args)
{
char *message; char *message;
size_t initialLen; size_t initialLen;
size_t len; size_t len;
@ -139,8 +153,8 @@ bool Syslog::vlogf_P(uint16_t pri, PGM_P fmt_P, va_list args) {
return result; return result;
} }
bool Syslog::logf(uint16_t pri, const char *fmt, ...)
bool Syslog::logf(uint16_t pri, const char *fmt, ...) { {
va_list args; va_list args;
bool result; bool result;
@ -150,7 +164,8 @@ bool Syslog::logf(uint16_t pri, const char *fmt, ...) {
return result; return result;
} }
bool Syslog::logf_P(uint16_t pri, PGM_P fmt_P, ...) { bool Syslog::logf_P(uint16_t pri, PGM_P fmt_P, ...)
{
va_list args; va_list args;
bool result; bool result;
@ -160,7 +175,8 @@ bool Syslog::logf_P(uint16_t pri, PGM_P fmt_P, ...) {
return result; return result;
} }
inline bool Syslog::_sendLog(uint16_t pri, const char *message) { inline bool Syslog::_sendLog(uint16_t pri, const char *message)
{
int result; int result;
if (!this->_enabled) if (!this->_enabled)
@ -200,7 +216,8 @@ inline bool Syslog::_sendLog(uint16_t pri, const char *message) {
return true; return true;
} }
inline bool Syslog::_sendLog(uint16_t pri, const __FlashStringHelper *message) { inline bool Syslog::_sendLog(uint16_t pri, const __FlashStringHelper *message)
{
int result; int result;
if (!this->_enabled) if (!this->_enabled)
@ -236,6 +253,5 @@ inline bool Syslog::_sendLog(uint16_t pri, const __FlashStringHelper *message) {
this->_client->print(message); this->_client->print(message);
this->_client->endPacket(); this->_client->endPacket();
return true; return true;
} }

View File

@ -108,7 +108,8 @@
// Default Bluetooth PIN // Default Bluetooth PIN
#define defaultBLEPin 123456 #define defaultBLEPin 123456
class Syslog { class Syslog
{
private: private:
UDP *_client; UDP *_client;
IPAddress _ip; IPAddress _ip;

View File

@ -2,11 +2,11 @@
#include "NodeDB.h" #include "NodeDB.h"
#include "RTC.h" #include "RTC.h"
#include "concurrency/Periodic.h" #include "concurrency/Periodic.h"
#include <SPI.h>
#include <RAK13800_W5100S.h>
#include "target_specific.h"
#include "mesh/api/ethServerAPI.h" #include "mesh/api/ethServerAPI.h"
#include "mqtt/MQTT.h" #include "mqtt/MQTT.h"
#include "target_specific.h"
#include <RAK13800_W5100S.h>
#include <SPI.h>
#ifndef DISABLE_NTP #ifndef DISABLE_NTP
#include <NTPClient.h> #include <NTPClient.h>
@ -143,10 +143,14 @@ bool initEthernet()
return false; return false;
} }
} else { } else {
LOG_INFO("Local IP %u.%u.%u.%u\n",Ethernet.localIP()[0], Ethernet.localIP()[1], Ethernet.localIP()[2], Ethernet.localIP()[3]); LOG_INFO("Local IP %u.%u.%u.%u\n", Ethernet.localIP()[0], Ethernet.localIP()[1], Ethernet.localIP()[2],
LOG_INFO("Subnet Mask %u.%u.%u.%u\n",Ethernet.subnetMask()[0], Ethernet.subnetMask()[1], Ethernet.subnetMask()[2], Ethernet.subnetMask()[3]); Ethernet.localIP()[3]);
LOG_INFO("Gateway IP %u.%u.%u.%u\n",Ethernet.gatewayIP()[0], Ethernet.gatewayIP()[1], Ethernet.gatewayIP()[2], Ethernet.gatewayIP()[3]); LOG_INFO("Subnet Mask %u.%u.%u.%u\n", Ethernet.subnetMask()[0], Ethernet.subnetMask()[1], Ethernet.subnetMask()[2],
LOG_INFO("DNS Server IP %u.%u.%u.%u\n",Ethernet.dnsServerIP()[0], Ethernet.dnsServerIP()[1], Ethernet.dnsServerIP()[2], Ethernet.dnsServerIP()[3]); Ethernet.subnetMask()[3]);
LOG_INFO("Gateway IP %u.%u.%u.%u\n", Ethernet.gatewayIP()[0], Ethernet.gatewayIP()[1], Ethernet.gatewayIP()[2],
Ethernet.gatewayIP()[3]);
LOG_INFO("DNS Server IP %u.%u.%u.%u\n", Ethernet.dnsServerIP()[0], Ethernet.dnsServerIP()[1],
Ethernet.dnsServerIP()[2], Ethernet.dnsServerIP()[3]);
} }
ethEvent = new Periodic("ethConnect", reconnectETH); ethEvent = new Periodic("ethConnect", reconnectETH);
@ -159,7 +163,8 @@ bool initEthernet()
} }
} }
bool isEthernetAvailable() { bool isEthernetAvailable()
{
if (!config.network.eth_enabled) { if (!config.network.eth_enabled) {
syslog.disable(); syslog.disable();

View File

@ -1,17 +1,17 @@
#include "mesh/http/WiFiAPClient.h"
#include "NodeDB.h" #include "NodeDB.h"
#include "RTC.h" #include "RTC.h"
#include "concurrency/Periodic.h" #include "concurrency/Periodic.h"
#include "mesh/http/WiFiAPClient.h"
#include "configuration.h" #include "configuration.h"
#include "main.h" #include "main.h"
#include "mesh/http/WebServer.h"
#include "mesh/api/WiFiServerAPI.h" #include "mesh/api/WiFiServerAPI.h"
#include "mesh/http/WebServer.h"
#include "mqtt/MQTT.h" #include "mqtt/MQTT.h"
#include "target_specific.h" #include "target_specific.h"
#include <ESPmDNS.h> #include <ESPmDNS.h>
#include <esp_wifi.h>
#include <WiFi.h> #include <WiFi.h>
#include <WiFiUdp.h> #include <WiFiUdp.h>
#include <esp_wifi.h>
#ifndef DISABLE_NTP #ifndef DISABLE_NTP
#include <NTPClient.h> #include <NTPClient.h>
@ -195,9 +195,7 @@ bool initWifi()
WiFi.setAutoReconnect(true); WiFi.setAutoReconnect(true);
WiFi.setSleep(false); WiFi.setSleep(false);
if (config.network.address_mode == Config_NetworkConfig_AddressMode_STATIC && config.network.ipv4_config.ip != 0) { if (config.network.address_mode == Config_NetworkConfig_AddressMode_STATIC && config.network.ipv4_config.ip != 0) {
WiFi.config(config.network.ipv4_config.ip, WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.gateway, config.network.ipv4_config.subnet,
config.network.ipv4_config.gateway,
config.network.ipv4_config.subnet,
config.network.ipv4_config.dns, config.network.ipv4_config.dns,
config.network.ipv4_config.dns); // Wifi wants two DNS servers... set both to the same value config.network.ipv4_config.dns); // Wifi wants two DNS servers... set both to the same value
} }
@ -207,7 +205,6 @@ bool initWifi()
WiFi.onEvent( WiFi.onEvent(
[](WiFiEvent_t event, WiFiEventInfo_t info) { [](WiFiEvent_t event, WiFiEventInfo_t info) {
LOG_WARN("WiFi lost connection. Reason: %d\n", info.wifi_sta_disconnected.reason); LOG_WARN("WiFi lost connection. Reason: %d\n", info.wifi_sta_disconnected.reason);
/* /*