Implement extended device metadata (#1874)

* Implement extended device metadata

* HAS_BLUETOOTH should be global
This commit is contained in:
Ben Meadors 2022-10-30 10:02:11 -05:00 committed by GitHub
parent 1f9db0a8fe
commit 311835a231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 6 deletions

@ -1 +1 @@
Subproject commit a79e3aef8117dad642b1a011ec0438619616740c
Subproject commit 46bc0afe050a836b6ec8b235c3ff55e9e037efcb

View File

@ -143,7 +143,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define HAS_WIFI 0
#endif
#ifndef HAS_ETHERNET
#define ETHERNET 0
#define HAS_ETHERNET 0
#endif
#ifndef HAS_SCREEN
#define HAS_SCREEN 0
@ -166,6 +166,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef HAS_RTC
#define HAS_RTC 0
#endif
#ifndef HAS_CPU_SHUTDOWN
#define HAS_CPU_SHUTDOWN 0
#endif
#ifndef HAS_BLUETOOTH
#define HAS_BLUETOOTH 0
#endif
#include "RF95Configuration.h"
#include "DebugConfiguration.h"

View File

@ -16,6 +16,14 @@ typedef struct _DeviceMetadata {
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;
} DeviceMetadata;
@ -24,17 +32,25 @@ extern "C" {
#endif
/* Initializer values for message structs */
#define DeviceMetadata_init_default {"", 0}
#define DeviceMetadata_init_zero {"", 0}
#define DeviceMetadata_init_default {"", 0, 0, 0, 0, 0}
#define DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0}
/* Field tags (for use in manual encoding/decoding) */
#define DeviceMetadata_firmware_version_tag 1
#define DeviceMetadata_device_state_version_tag 2
#define DeviceMetadata_canShutdown_tag 3
#define DeviceMetadata_hasWifi_tag 4
#define DeviceMetadata_hasBluetooth_tag 5
#define DeviceMetadata_hasEthernet_tag 6
/* Struct field encoding specification for nanopb */
#define 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, 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)
#define DeviceMetadata_CALLBACK NULL
#define DeviceMetadata_DEFAULT NULL
@ -44,7 +60,7 @@ extern const pb_msgdesc_t DeviceMetadata_msg;
#define DeviceMetadata_fields &DeviceMetadata_msg
/* Maximum encoded size of messages (where known) */
#define DeviceMetadata_size 25
#define DeviceMetadata_size 33
#ifdef __cplusplus
} /* extern "C" */

View File

@ -441,6 +441,10 @@ void AdminModule::handleGetDeviceMetadata(const MeshPacket &req) {
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;
r.get_device_metadata_response = deviceMetadata;
r.which_payload_variant = AdminMessage_get_device_metadata_response_tag;

View File

@ -26,6 +26,9 @@
#ifndef HAS_RADIO
#define HAS_RADIO 1
#endif
#ifdef HAS_CPU_SHUTDOWN
#define HAS_CPU_SHUTDOWN 1
#endif
//
// set HW_VENDOR