diff --git a/src/main.cpp b/src/main.cpp index f2681bc19..24b1767dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -537,6 +537,21 @@ uint32_t shutdownAtMsec; // If not zero we will shutdown at this time (used to s // This will supress the current delay and instead try to run ASAP. bool runASAP; +extern meshtastic_DeviceMetadata getDeviceMetadata() +{ + meshtastic_DeviceMetadata deviceMetadata; + strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18); + deviceMetadata.device_state_version = DEVICESTATE_CUR_VER; + deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN; + deviceMetadata.hasBluetooth = HAS_BLUETOOTH; + deviceMetadata.hasWifi = HAS_WIFI; + deviceMetadata.hasEthernet = HAS_ETHERNET; + deviceMetadata.role = config.device.role; + deviceMetadata.position_flags = config.position.position_flags; + deviceMetadata.hw_model = HW_VENDOR; + return deviceMetadata; +} + void loop() { runASAP = false; diff --git a/src/main.h b/src/main.h index b1bee1b06..62c022b2b 100644 --- a/src/main.h +++ b/src/main.h @@ -61,3 +61,5 @@ extern uint32_t serialSinceMsec; extern bool runASAP; void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), clearBonds(); + +meshtastic_DeviceMetadata getDeviceMetadata(); diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index e03f9bb17..5c28f5261 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -11,6 +11,7 @@ #include "RTC.h" #include "Router.h" #include "error.h" +#include "main.h" #include "mesh-pb-constants.h" #include #include diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 7d95062a2..a6fbd9cb0 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -1,7 +1,6 @@ #pragma once #include "Observer.h" -#include "main.h" #include #include @@ -230,18 +229,3 @@ extern uint32_t radioGeneration; (ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \ ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \ ModuleConfig_TelemetryConfig_size + ModuleConfig_size) - -inline meshtastic_DeviceMetadata getDeviceMetadata() -{ - meshtastic_DeviceMetadata deviceMetadata; - strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18); - deviceMetadata.device_state_version = DEVICESTATE_CUR_VER; - deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN; - deviceMetadata.hasBluetooth = HAS_BLUETOOTH; - deviceMetadata.hasWifi = HAS_WIFI; - deviceMetadata.hasEthernet = HAS_ETHERNET; - deviceMetadata.role = config.device.role; - deviceMetadata.position_flags = config.position.position_flags; - deviceMetadata.hw_model = HW_VENDOR; - return deviceMetadata; -} \ No newline at end of file diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index c91863bdc..c69694196 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -6,6 +6,7 @@ #include "PowerFSM.h" #include "RadioInterface.h" #include "configuration.h" +#include "main.h" #include "xmodem.h" #if FromRadio_size > MAX_TO_FROM_RADIO_SIZE diff --git a/src/mesh/generated/meshtastic/device_metadata.pb.c b/src/mesh/generated/meshtastic/device_metadata.pb.c deleted file mode 100644 index 627ce3244..000000000 --- a/src/mesh/generated/meshtastic/device_metadata.pb.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.4.7 */ - -#include "meshtastic/device_metadata.pb.h" -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -PB_BIND(meshtastic_DeviceMetadata, meshtastic_DeviceMetadata, AUTO) - - - diff --git a/src/mesh/generated/meshtastic/device_metadata.pb.h b/src/mesh/generated/meshtastic/device_metadata.pb.h deleted file mode 100644 index 44cf29079..000000000 --- a/src/mesh/generated/meshtastic/device_metadata.pb.h +++ /dev/null @@ -1,83 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.4.7 */ - -#ifndef PB_MESHTASTIC_MESHTASTIC_DEVICE_METADATA_PB_H_INCLUDED -#define PB_MESHTASTIC_MESHTASTIC_DEVICE_METADATA_PB_H_INCLUDED -#include -#include "meshtastic/config.pb.h" -#include "meshtastic/mesh.pb.h" - -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -/* Struct definitions */ -/* Device metadata response */ -typedef struct _meshtastic_DeviceMetadata { - /* Device firmware version string */ - char firmware_version[18]; - /* Device state version */ - uint32_t device_state_version; - /* Indicates whether the device can shutdown CPU natively or via power management chip */ - bool canShutdown; - /* Indicates that the device has native wifi capability */ - bool hasWifi; - /* Indicates that the device has native bluetooth capability */ - bool hasBluetooth; - /* Indicates that the device has an ethernet peripheral */ - bool hasEthernet; - /* Indicates that the device's role in the mesh */ - meshtastic_Config_DeviceConfig_Role role; - /* Indicates the device's current enabled position flags */ - uint32_t position_flags; - /* Device hardware model */ - meshtastic_HardwareModel hw_model; -} meshtastic_DeviceMetadata; - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Initializer values for message structs */ -#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN} -#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN} - -/* Field tags (for use in manual encoding/decoding) */ -#define meshtastic_DeviceMetadata_firmware_version_tag 1 -#define meshtastic_DeviceMetadata_device_state_version_tag 2 -#define meshtastic_DeviceMetadata_canShutdown_tag 3 -#define meshtastic_DeviceMetadata_hasWifi_tag 4 -#define meshtastic_DeviceMetadata_hasBluetooth_tag 5 -#define meshtastic_DeviceMetadata_hasEthernet_tag 6 -#define meshtastic_DeviceMetadata_role_tag 7 -#define meshtastic_DeviceMetadata_position_flags_tag 8 -#define meshtastic_DeviceMetadata_hw_model_tag 9 - -/* Struct field encoding specification for nanopb */ -#define meshtastic_DeviceMetadata_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, STRING, firmware_version, 1) \ -X(a, STATIC, SINGULAR, UINT32, device_state_version, 2) \ -X(a, STATIC, SINGULAR, BOOL, canShutdown, 3) \ -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, UINT32, position_flags, 8) \ -X(a, STATIC, SINGULAR, UENUM, hw_model, 9) -#define meshtastic_DeviceMetadata_CALLBACK NULL -#define meshtastic_DeviceMetadata_DEFAULT NULL - -extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg; - -/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ -#define meshtastic_DeviceMetadata_fields &meshtastic_DeviceMetadata_msg - -/* Maximum encoded size of messages (where known) */ -#define meshtastic_DeviceMetadata_size 44 - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif