Merge branch 'master' into rsyslog-client

This commit is contained in:
Thomas Göttgens
2023-01-18 22:13:38 +01:00
committed by GitHub
43 changed files with 818 additions and 792 deletions

View File

@@ -157,7 +157,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
if (info) {
LOG_INFO("Sending nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s\n", info->num, info->last_heard, info->user.id,
info->user.long_name);
info->user.long_name);
fromRadioScratch.which_payload_variant = FromRadio_node_info_tag;
fromRadioScratch.node_info = *info;
// Stay in current state until done sending nodeinfos
@@ -364,7 +364,7 @@ bool PhoneAPI::available()
case STATE_SEND_MODULECONFIG:
case STATE_SEND_COMPLETE_ID:
return true;
case STATE_SEND_NODEINFO:
if (!nodeInfoForPhone)
nodeInfoForPhone = nodeDB.readNextInfo();

View File

@@ -16,14 +16,15 @@
* Eventually there should be once instance of this class for each live connection (because it has a bit of state
* for that connection)
*/
class PhoneAPI : public Observer<uint32_t> // FIXME, we shouldn't be inheriting from Observer, instead use CallbackObserver as a member
class PhoneAPI
: public Observer<uint32_t> // FIXME, we shouldn't be inheriting from Observer, instead use CallbackObserver as a member
{
enum State {
STATE_SEND_NOTHING, // Initial state, don't send anything until the client starts asking for config
STATE_SEND_MY_INFO, // send our my info record
STATE_SEND_NODEINFO, // states progress in this order as the device sends to to the client
STATE_SEND_CHANNELS, // Send all channels
STATE_SEND_CONFIG, // Replacement for the old Radioconfig
STATE_SEND_NOTHING, // Initial state, don't send anything until the client starts asking for config
STATE_SEND_MY_INFO, // send our my info record
STATE_SEND_NODEINFO, // states progress in this order as the device sends to to the client
STATE_SEND_CHANNELS, // Send all channels
STATE_SEND_CONFIG, // Replacement for the old Radioconfig
STATE_SEND_MODULECONFIG, // Send Module specific config
STATE_SEND_COMPLETE_ID,
STATE_SEND_PACKETS // send packets or debug strings
@@ -65,7 +66,7 @@ class PhoneAPI : public Observer<uint32_t> // FIXME, we shouldn't be inheriting
// Call this when the client drops the connection, resets the state to STATE_SEND_NOTHING
// Unregisters our observer. A closed connection **can** be reopened by calling init again.
virtual void close();
/**
* Handle a ToRadio protobuf
* @return true true if a packet was queued for sending (so that caller can yield)
@@ -95,7 +96,7 @@ class PhoneAPI : public Observer<uint32_t> // FIXME, we shouldn't be inheriting
/** the last msec we heard from the client on the other side of this link */
uint32_t lastContactMsec = 0;
/// Hookable to find out when connection changes
virtual void onConnectionChanged(bool connected) {}

View File

@@ -300,6 +300,8 @@ typedef struct _Config_NetworkConfig {
/* struct to keep static address */
bool has_ipv4_config;
Config_NetworkConfig_IpV4Config ipv4_config;
/* rsyslog Server and Port */
char rsyslog_server[33];
} Config_NetworkConfig;
/* Display Config */
@@ -476,7 +478,7 @@ extern "C" {
#define Config_DeviceConfig_init_default {_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0}
#define Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0}
#define Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0}
#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_AddressMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default}
#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_AddressMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default, ""}
#define Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0}
#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN, _Config_DisplayConfig_DisplayMode_MIN, 0}
#define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, {0, 0, 0}}
@@ -485,7 +487,7 @@ extern "C" {
#define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0}
#define Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0}
#define Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0}
#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_AddressMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero}
#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_AddressMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero, ""}
#define Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0}
#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN, _Config_DisplayConfig_DisplayMode_MIN, 0}
#define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, {0, 0, 0}}
@@ -525,6 +527,7 @@ extern "C" {
#define Config_NetworkConfig_eth_enabled_tag 6
#define Config_NetworkConfig_address_mode_tag 7
#define Config_NetworkConfig_ipv4_config_tag 8
#define Config_NetworkConfig_rsyslog_server_tag 9
#define Config_DisplayConfig_screen_on_secs_tag 1
#define Config_DisplayConfig_gps_format_tag 2
#define Config_DisplayConfig_auto_screen_carousel_secs_tag 3
@@ -618,7 +621,8 @@ X(a, STATIC, SINGULAR, STRING, wifi_psk, 4) \
X(a, STATIC, SINGULAR, STRING, ntp_server, 5) \
X(a, STATIC, SINGULAR, BOOL, eth_enabled, 6) \
X(a, STATIC, SINGULAR, UENUM, address_mode, 7) \
X(a, STATIC, OPTIONAL, MESSAGE, ipv4_config, 8)
X(a, STATIC, OPTIONAL, MESSAGE, ipv4_config, 8) \
X(a, STATIC, SINGULAR, STRING, rsyslog_server, 9)
#define Config_NetworkConfig_CALLBACK NULL
#define Config_NetworkConfig_DEFAULT NULL
#define Config_NetworkConfig_ipv4_config_MSGTYPE Config_NetworkConfig_IpV4Config
@@ -695,10 +699,10 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg;
#define Config_DisplayConfig_size 26
#define Config_LoRaConfig_size 70
#define Config_NetworkConfig_IpV4Config_size 20
#define Config_NetworkConfig_size 161
#define Config_NetworkConfig_size 195
#define Config_PositionConfig_size 42
#define Config_PowerConfig_size 43
#define Config_size 164
#define Config_size 198
#ifdef __cplusplus
} /* extern "C" */

View File

@@ -28,7 +28,7 @@ typedef struct _DeviceMetadata {
/* Indicates that the device's role in the mesh */
Config_DeviceConfig_Role role;
/* Indicates the device's current enabled position flags */
Config_PositionConfig_PositionFlags position_flags;
uint32_t position_flags;
} DeviceMetadata;
@@ -37,8 +37,8 @@ extern "C" {
#endif
/* Initializer values for message structs */
#define DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _Config_DeviceConfig_Role_MIN, _Config_PositionConfig_PositionFlags_MIN}
#define DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _Config_DeviceConfig_Role_MIN, _Config_PositionConfig_PositionFlags_MIN}
#define DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _Config_DeviceConfig_Role_MIN, 0}
#define DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _Config_DeviceConfig_Role_MIN, 0}
/* Field tags (for use in manual encoding/decoding) */
#define DeviceMetadata_firmware_version_tag 1
@@ -59,7 +59,7 @@ X(a, STATIC, SINGULAR, BOOL, hasWifi, 4) \
X(a, STATIC, SINGULAR, BOOL, hasBluetooth, 5) \
X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) \
X(a, STATIC, SINGULAR, UENUM, role, 7) \
X(a, STATIC, SINGULAR, UENUM, position_flags, 8)
X(a, STATIC, SINGULAR, UINT32, position_flags, 8)
#define DeviceMetadata_CALLBACK NULL
#define DeviceMetadata_DEFAULT NULL
@@ -69,7 +69,7 @@ extern const pb_msgdesc_t DeviceMetadata_msg;
#define DeviceMetadata_fields &DeviceMetadata_msg
/* Maximum encoded size of messages (where known) */
#define DeviceMetadata_size 38
#define DeviceMetadata_size 41
#ifdef __cplusplus
} /* extern "C" */

View File

@@ -156,7 +156,7 @@ extern const pb_msgdesc_t LocalModuleConfig_msg;
#define LocalModuleConfig_fields &LocalModuleConfig_msg
/* Maximum encoded size of messages (where known) */
#define LocalConfig_size 391
#define LocalConfig_size 425
#define LocalModuleConfig_size 412
#ifdef __cplusplus

View File

@@ -1,9 +1,9 @@
#pragma once
#include "mesh/generated/meshtastic/mesh.pb.h"
#include "mesh/generated/meshtastic/localonly.pb.h"
#include "mesh/generated/meshtastic/deviceonly.pb.h"
#include "mesh/generated/meshtastic/admin.pb.h"
#include "mesh/generated/meshtastic/deviceonly.pb.h"
#include "mesh/generated/meshtastic/localonly.pb.h"
#include "mesh/generated/meshtastic/mesh.pb.h"
// this file defines constants which come from mesh.options
@@ -11,8 +11,8 @@
#define member_size(type, member) sizeof(((type *)0)->member)
/// max number of packets which can be waiting for delivery to android - note, this value comes from mesh.options protobuf
// FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in RAM
// #define MAX_RX_TOPHONE (member_size(DeviceState, receive_queue) / member_size(DeviceState, receive_queue[0]))
// FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in
// RAM #define MAX_RX_TOPHONE (member_size(DeviceState, receive_queue) / member_size(DeviceState, receive_queue[0]))
#define MAX_RX_TOPHONE 32
/// max number of nodes allowed in the mesh
@@ -36,7 +36,7 @@ bool writecb(pb_ostream_t *stream, const uint8_t *buf, size_t count);
/** is_in_repeated is a macro/function that returns true if a specified word appears in a repeated protobuf array.
* It relies on the following naming conventions from nanopb:
*
*
* pb_size_t ignore_incoming_count;
* uint32_t ignore_incoming[3];
*/