mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-15 17:42:12 +00:00
Formatting
This commit is contained in:
parent
202223236d
commit
ff029ad752
@ -24,7 +24,8 @@ SOFTWARE.*/
|
||||
|
||||
#include "DebugConfiguration.h"
|
||||
|
||||
Syslog::Syslog(UDP &client) {
|
||||
Syslog::Syslog(UDP &client)
|
||||
{
|
||||
this->_client = &client;
|
||||
this->_server = NULL;
|
||||
this->_port = 0;
|
||||
@ -33,44 +34,52 @@ Syslog::Syslog(UDP &client) {
|
||||
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->_port = port;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Syslog &Syslog::server(IPAddress ip, uint16_t port) {
|
||||
Syslog &Syslog::server(IPAddress ip, uint16_t port)
|
||||
{
|
||||
this->_ip = ip;
|
||||
this->_server = NULL;
|
||||
this->_port = port;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Syslog &Syslog::deviceHostname(const char* deviceHostname) {
|
||||
Syslog &Syslog::deviceHostname(const char *deviceHostname)
|
||||
{
|
||||
this->_deviceHostname = (deviceHostname == NULL) ? SYSLOG_NILVALUE : deviceHostname;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Syslog &Syslog::appName(const char* appName) {
|
||||
Syslog &Syslog::appName(const char *appName)
|
||||
{
|
||||
this->_appName = (appName == NULL) ? SYSLOG_NILVALUE : appName;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Syslog &Syslog::defaultPriority(uint16_t pri) {
|
||||
Syslog &Syslog::defaultPriority(uint16_t pri)
|
||||
{
|
||||
this->_priDefault = pri;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Syslog &Syslog::logMask(uint8_t priMask) {
|
||||
Syslog &Syslog::logMask(uint8_t priMask)
|
||||
{
|
||||
this->_priMask = priMask;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Syslog::enable() {
|
||||
void Syslog::enable()
|
||||
{
|
||||
this->_enabled = true;
|
||||
}
|
||||
|
||||
void Syslog::disable() {
|
||||
void Syslog::disable()
|
||||
{
|
||||
this->_enabled = false;
|
||||
}
|
||||
|
||||
@ -79,19 +88,23 @@ bool Syslog::isEnabled()
|
||||
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);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
bool Syslog::log(uint16_t pri, const char *message) {
|
||||
bool Syslog::log(uint16_t pri, const char *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;
|
||||
size_t initialLen;
|
||||
size_t len;
|
||||
@ -115,7 +128,8 @@ bool Syslog::vlogf(uint16_t pri, const char *fmt, va_list args) {
|
||||
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;
|
||||
size_t initialLen;
|
||||
size_t len;
|
||||
@ -139,8 +153,8 @@ bool Syslog::vlogf_P(uint16_t pri, PGM_P fmt_P, va_list args) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool Syslog::logf(uint16_t pri, const char *fmt, ...) {
|
||||
bool Syslog::logf(uint16_t pri, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
bool result;
|
||||
|
||||
@ -150,7 +164,8 @@ bool Syslog::logf(uint16_t pri, const char *fmt, ...) {
|
||||
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;
|
||||
bool result;
|
||||
|
||||
@ -160,7 +175,8 @@ bool Syslog::logf_P(uint16_t pri, PGM_P fmt_P, ...) {
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool Syslog::_sendLog(uint16_t pri, const char *message) {
|
||||
inline bool Syslog::_sendLog(uint16_t pri, const char *message)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!this->_enabled)
|
||||
@ -200,7 +216,8 @@ inline bool Syslog::_sendLog(uint16_t pri, const char *message) {
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Syslog::_sendLog(uint16_t pri, const __FlashStringHelper *message) {
|
||||
inline bool Syslog::_sendLog(uint16_t pri, const __FlashStringHelper *message)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!this->_enabled)
|
||||
@ -236,6 +253,5 @@ inline bool Syslog::_sendLog(uint16_t pri, const __FlashStringHelper *message) {
|
||||
this->_client->print(message);
|
||||
this->_client->endPacket();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
@ -63,40 +63,40 @@
|
||||
|
||||
#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
|
||||
/* extract priority */
|
||||
#define LOG_PRI(p) ((p) & LOG_PRIMASK)
|
||||
#define LOG_PRI(p) ((p)&LOG_PRIMASK)
|
||||
#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
|
||||
|
||||
/* facility codes */
|
||||
#define LOGLEVEL_KERN (0<<3) /* kernel messages */
|
||||
#define LOGLEVEL_USER (1<<3) /* random user-level messages */
|
||||
#define LOGLEVEL_MAIL (2<<3) /* mail system */
|
||||
#define LOGLEVEL_DAEMON (3<<3) /* system daemons */
|
||||
#define LOGLEVEL_AUTH (4<<3) /* security/authorization messages */
|
||||
#define LOGLEVEL_SYSLOG (5<<3) /* messages generated internally by syslogd */
|
||||
#define LOGLEVEL_LPR (6<<3) /* line printer subsystem */
|
||||
#define LOGLEVEL_NEWS (7<<3) /* network news subsystem */
|
||||
#define LOGLEVEL_UUCP (8<<3) /* UUCP subsystem */
|
||||
#define LOGLEVEL_CRON (9<<3) /* clock daemon */
|
||||
#define LOGLEVEL_AUTHPRIV (10<<3) /* security/authorization messages (private) */
|
||||
#define LOGLEVEL_FTP (11<<3) /* ftp daemon */
|
||||
#define LOGLEVEL_KERN (0 << 3) /* kernel messages */
|
||||
#define LOGLEVEL_USER (1 << 3) /* random user-level messages */
|
||||
#define LOGLEVEL_MAIL (2 << 3) /* mail system */
|
||||
#define LOGLEVEL_DAEMON (3 << 3) /* system daemons */
|
||||
#define LOGLEVEL_AUTH (4 << 3) /* security/authorization messages */
|
||||
#define LOGLEVEL_SYSLOG (5 << 3) /* messages generated internally by syslogd */
|
||||
#define LOGLEVEL_LPR (6 << 3) /* line printer subsystem */
|
||||
#define LOGLEVEL_NEWS (7 << 3) /* network news subsystem */
|
||||
#define LOGLEVEL_UUCP (8 << 3) /* UUCP subsystem */
|
||||
#define LOGLEVEL_CRON (9 << 3) /* clock daemon */
|
||||
#define LOGLEVEL_AUTHPRIV (10 << 3) /* security/authorization messages (private) */
|
||||
#define LOGLEVEL_FTP (11 << 3) /* ftp daemon */
|
||||
|
||||
/* other codes through 15 reserved for system use */
|
||||
#define LOGLEVEL_LOCAL0 (16<<3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL1 (17<<3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL2 (18<<3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL3 (19<<3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL4 (20<<3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL5 (21<<3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL6 (22<<3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL7 (23<<3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL0 (16 << 3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL1 (17 << 3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL2 (18 << 3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL3 (19 << 3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL4 (20 << 3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL5 (21 << 3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL6 (22 << 3) /* reserved for local use */
|
||||
#define LOGLEVEL_LOCAL7 (23 << 3) /* reserved for local use */
|
||||
|
||||
#define LOG_NFACILITIES 24 /* current number of facilities */
|
||||
#define LOG_FACMASK 0x03f8 /* mask to extract facility part */
|
||||
/* facility of pri */
|
||||
#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
|
||||
#define LOG_FAC(p) (((p)&LOG_FACMASK) >> 3)
|
||||
|
||||
#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
|
||||
#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
|
||||
#define LOG_UPTO(pri) ((1 << ((pri) + 1)) - 1) /* all priorities through pri */
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// AXP192 (Rev1-specific options)
|
||||
@ -108,14 +108,15 @@
|
||||
// Default Bluetooth PIN
|
||||
#define defaultBLEPin 123456
|
||||
|
||||
class Syslog {
|
||||
class Syslog
|
||||
{
|
||||
private:
|
||||
UDP* _client;
|
||||
UDP *_client;
|
||||
IPAddress _ip;
|
||||
const char* _server;
|
||||
const char *_server;
|
||||
uint16_t _port;
|
||||
const char* _deviceHostname;
|
||||
const char* _appName;
|
||||
const char *_deviceHostname;
|
||||
const char *_appName;
|
||||
uint16_t _priDefault;
|
||||
uint8_t _priMask = 0xff;
|
||||
bool _enabled = false;
|
||||
@ -126,10 +127,10 @@ class Syslog {
|
||||
public:
|
||||
Syslog(UDP &client);
|
||||
|
||||
Syslog &server(const char* server, uint16_t port);
|
||||
Syslog &server(const char *server, uint16_t port);
|
||||
Syslog &server(IPAddress ip, uint16_t port);
|
||||
Syslog &deviceHostname(const char* deviceHostname);
|
||||
Syslog &appName(const char* appName);
|
||||
Syslog &deviceHostname(const char *deviceHostname);
|
||||
Syslog &appName(const char *appName);
|
||||
Syslog &defaultPriority(uint16_t pri = LOGLEVEL_KERN);
|
||||
Syslog &logMask(uint8_t priMask);
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
#include "NodeDB.h"
|
||||
#include "RTC.h"
|
||||
#include "concurrency/Periodic.h"
|
||||
#include <SPI.h>
|
||||
#include <RAK13800_W5100S.h>
|
||||
#include "target_specific.h"
|
||||
#include "mesh/api/ethServerAPI.h"
|
||||
#include "mqtt/MQTT.h"
|
||||
#include "target_specific.h"
|
||||
#include <RAK13800_W5100S.h>
|
||||
#include <SPI.h>
|
||||
|
||||
#ifndef DISABLE_NTP
|
||||
#include <NTPClient.h>
|
||||
@ -40,7 +40,7 @@ static int32_t reconnectETH()
|
||||
timeClient.setUpdateInterval(60 * 60); // Update once an hour
|
||||
#endif
|
||||
|
||||
if(config.network.rsyslog_server[0]) {
|
||||
if (config.network.rsyslog_server[0]) {
|
||||
LOG_INFO("Starting Syslog client\n");
|
||||
// Defaults
|
||||
int serverPort = 514;
|
||||
@ -109,7 +109,7 @@ bool initEthernet()
|
||||
digitalWrite(PIN_ETHERNET_RESET, HIGH); // Reset Time.
|
||||
#endif
|
||||
|
||||
Ethernet.init( ETH_SPI_PORT, PIN_ETHERNET_SS );
|
||||
Ethernet.init(ETH_SPI_PORT, PIN_ETHERNET_SS);
|
||||
|
||||
uint8_t mac[6];
|
||||
|
||||
@ -138,15 +138,19 @@ bool initEthernet()
|
||||
} else if (Ethernet.linkStatus() == LinkOFF) {
|
||||
LOG_ERROR("Ethernet cable is not connected.\n");
|
||||
return false;
|
||||
} else{
|
||||
} else {
|
||||
LOG_ERROR("Unknown Ethernet error.\n");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LOG_INFO("Local IP %u.%u.%u.%u\n",Ethernet.localIP()[0], Ethernet.localIP()[1], Ethernet.localIP()[2], Ethernet.localIP()[3]);
|
||||
LOG_INFO("Subnet Mask %u.%u.%u.%u\n",Ethernet.subnetMask()[0], Ethernet.subnetMask()[1], Ethernet.subnetMask()[2], 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]);
|
||||
LOG_INFO("Local IP %u.%u.%u.%u\n", Ethernet.localIP()[0], Ethernet.localIP()[1], Ethernet.localIP()[2],
|
||||
Ethernet.localIP()[3]);
|
||||
LOG_INFO("Subnet Mask %u.%u.%u.%u\n", Ethernet.subnetMask()[0], Ethernet.subnetMask()[1], Ethernet.subnetMask()[2],
|
||||
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);
|
||||
@ -159,7 +163,8 @@ bool initEthernet()
|
||||
}
|
||||
}
|
||||
|
||||
bool isEthernetAvailable() {
|
||||
bool isEthernetAvailable()
|
||||
{
|
||||
|
||||
if (!config.network.eth_enabled) {
|
||||
syslog.disable();
|
||||
|
@ -1,17 +1,17 @@
|
||||
#include "mesh/http/WiFiAPClient.h"
|
||||
#include "NodeDB.h"
|
||||
#include "RTC.h"
|
||||
#include "concurrency/Periodic.h"
|
||||
#include "mesh/http/WiFiAPClient.h"
|
||||
#include "configuration.h"
|
||||
#include "main.h"
|
||||
#include "mesh/http/WebServer.h"
|
||||
#include "mesh/api/WiFiServerAPI.h"
|
||||
#include "mesh/http/WebServer.h"
|
||||
#include "mqtt/MQTT.h"
|
||||
#include "target_specific.h"
|
||||
#include <ESPmDNS.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <WiFi.h>
|
||||
#include <WiFiUdp.h>
|
||||
#include <esp_wifi.h>
|
||||
|
||||
#ifndef DISABLE_NTP
|
||||
#include <NTPClient.h>
|
||||
@ -58,7 +58,7 @@ static int32_t reconnectWiFi()
|
||||
|
||||
// Make sure we clear old connection credentials
|
||||
WiFi.disconnect(false, true);
|
||||
LOG_INFO("Reconnecting to WiFi access point %s\n",wifiName);
|
||||
LOG_INFO("Reconnecting to WiFi access point %s\n", wifiName);
|
||||
|
||||
delay(5000);
|
||||
|
||||
@ -69,7 +69,7 @@ static int32_t reconnectWiFi()
|
||||
|
||||
#ifndef DISABLE_NTP
|
||||
if (WiFi.isConnected() && (((millis() - lastrun_ntp) > 43200000) || (lastrun_ntp == 0))) { // every 12 hours
|
||||
LOG_DEBUG("Updating NTP time from %s\n",config.network.ntp_server);
|
||||
LOG_DEBUG("Updating NTP time from %s\n", config.network.ntp_server);
|
||||
if (timeClient.update()) {
|
||||
LOG_DEBUG("NTP Request Success - Setting RTCQualityNTP if needed\n");
|
||||
|
||||
@ -138,7 +138,7 @@ static void onNetworkConnected()
|
||||
timeClient.setUpdateInterval(60 * 60); // Update once an hour
|
||||
#endif
|
||||
|
||||
if(config.network.rsyslog_server[0]) {
|
||||
if (config.network.rsyslog_server[0]) {
|
||||
LOG_INFO("Starting Syslog client\n");
|
||||
// Defaults
|
||||
int serverPort = 514;
|
||||
@ -195,9 +195,7 @@ bool initWifi()
|
||||
WiFi.setAutoReconnect(true);
|
||||
WiFi.setSleep(false);
|
||||
if (config.network.address_mode == Config_NetworkConfig_AddressMode_STATIC && config.network.ipv4_config.ip != 0) {
|
||||
WiFi.config(config.network.ipv4_config.ip,
|
||||
config.network.ipv4_config.gateway,
|
||||
config.network.ipv4_config.subnet,
|
||||
WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.gateway, config.network.ipv4_config.subnet,
|
||||
config.network.ipv4_config.dns,
|
||||
config.network.ipv4_config.dns); // Wifi wants two DNS servers... set both to the same value
|
||||
}
|
||||
@ -207,7 +205,6 @@ bool initWifi()
|
||||
|
||||
WiFi.onEvent(
|
||||
[](WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
|
||||
LOG_WARN("WiFi lost connection. Reason: %d\n", info.wifi_sta_disconnected.reason);
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user