diff --git a/bin/regen-protos.sh b/bin/regen-protos.sh index 655db9a7a..817dc5d24 100755 --- a/bin/regen-protos.sh +++ b/bin/regen-protos.sh @@ -5,7 +5,7 @@ set -e echo "This script requires https://jpa.kapsi.fi/nanopb/download/ version 0.4.1" # the nanopb tool seems to require that the .options file be in the current directory! cd proto -../../nanopb-0.4.1-linux-x86/generator-bin/protoc --nanopb_out=-v:../src/mesh -I=../proto portnums.proto mesh.proto +../../nanopb-0.4.1-linux-x86/generator-bin/protoc --nanopb_out=-v:../src/mesh -I=../proto *.proto echo "Regenerating protobuf documentation - if you see an error message" echo "you can ignore it unless doing a new protobuf release to github." diff --git a/docs/software/TODO.md b/docs/software/TODO.md index fc1c27c83..5a26c8e10 100644 --- a/docs/software/TODO.md +++ b/docs/software/TODO.md @@ -4,14 +4,16 @@ You probably don't care about this section - skip to the next one. For app cleanup: -* have python tool check max packet size before sending to device +* DONE have python tool check max packet size before sending to device +* if request was sent reliably, send reply reliably * DONE require a recent python api to talk to these new device loads * DONE require a recent android app to talk to these new device loads * DONE fix handleIncomingPosition * DONE move want_replies handling into plugins * on android for received positions handle either old or new positions / user messages * on android side send old or new positions as needed / user messages -* on python side handle new position/user messages +* test python side handle new position/user messages +* make a gpio example * DONE fix position sending to use new plugin * DONE Add SinglePortNumPlugin - as the new most useful baseclass * DONE move positions into regular data packets (use new app framework) @@ -20,6 +22,7 @@ For app cleanup: * test that position, text messages and user info work properly with new android app and old device code * call the plugin setup functions * fix the RTC drift bug +* move ping functionality into device, reply with rxsnr info For high speed/lots of devices/short range tasks: diff --git a/proto b/proto index 13b69ad55..6e8d220ad 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 13b69ad55079e3f35774f63e960064867de20235 +Subproject commit 6e8d220ad0d9f7ae6ce37db94c2b3f55a70f4f45 diff --git a/src/mesh/portnums.pb.h b/src/mesh/portnums.pb.h index 595d31146..eab09126b 100644 --- a/src/mesh/portnums.pb.h +++ b/src/mesh/portnums.pb.h @@ -17,7 +17,7 @@ extern "C" { typedef enum _PortNum { PortNum_UNKNOWN_APP = 0, PortNum_TEXT_MESSAGE_APP = 1, - PortNum_GPIO_APP = 2, + PortNum_REMOTE_HARDWARE_APP = 2, PortNum_POSITION_APP = 3, PortNum_NODEINFO_APP = 4, PortNum_PRIVATE_APP = 256, diff --git a/src/mesh/remote_hardware.pb.c b/src/mesh/remote_hardware.pb.c new file mode 100644 index 000000000..a334db461 --- /dev/null +++ b/src/mesh/remote_hardware.pb.c @@ -0,0 +1,13 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.1 */ + +#include "remote_hardware.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(HardwareMessage, HardwareMessage, AUTO) + + + + diff --git a/src/mesh/remote_hardware.pb.h b/src/mesh/remote_hardware.pb.h new file mode 100644 index 000000000..036d82fb8 --- /dev/null +++ b/src/mesh/remote_hardware.pb.h @@ -0,0 +1,69 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.1 */ + +#ifndef PB_REMOTE_HARDWARE_PB_H_INCLUDED +#define PB_REMOTE_HARDWARE_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Enum definitions */ +typedef enum _HardwareMessage_MessageType { + HardwareMessage_MessageType_UNSET = 0, + HardwareMessage_MessageType_WRITE_GPIOS = 1, + HardwareMessage_MessageType_WATCH_GPIOS = 2, + HardwareMessage_MessageType_GPIOS_CHANGED = 3, + HardwareMessage_MessageType_READ_GPIOS = 4, + HardwareMessage_MessageType_READ_GPIOS_REPLY = 5 +} HardwareMessage_MessageType; + +/* Struct definitions */ +typedef struct _HardwareMessage { + HardwareMessage_MessageType typ; + uint64_t gpio_mask; + uint64_t gpio_value; +} HardwareMessage; + + +/* Helper constants for enums */ +#define _HardwareMessage_MessageType_MIN HardwareMessage_MessageType_UNSET +#define _HardwareMessage_MessageType_MAX HardwareMessage_MessageType_READ_GPIOS_REPLY +#define _HardwareMessage_MessageType_ARRAYSIZE ((HardwareMessage_MessageType)(HardwareMessage_MessageType_READ_GPIOS_REPLY+1)) + + +/* Initializer values for message structs */ +#define HardwareMessage_init_default {_HardwareMessage_MessageType_MIN, 0, 0} +#define HardwareMessage_init_zero {_HardwareMessage_MessageType_MIN, 0, 0} + +/* Field tags (for use in manual encoding/decoding) */ +#define HardwareMessage_typ_tag 1 +#define HardwareMessage_gpio_mask_tag 2 +#define HardwareMessage_gpio_value_tag 3 + +/* Struct field encoding specification for nanopb */ +#define HardwareMessage_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UENUM, typ, 1) \ +X(a, STATIC, SINGULAR, UINT64, gpio_mask, 2) \ +X(a, STATIC, SINGULAR, UINT64, gpio_value, 3) +#define HardwareMessage_CALLBACK NULL +#define HardwareMessage_DEFAULT NULL + +extern const pb_msgdesc_t HardwareMessage_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define HardwareMessage_fields &HardwareMessage_msg + +/* Maximum encoded size of messages (where known) */ +#define HardwareMessage_size 24 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/src/plugins/RemoteHardwarePlugin.cpp b/src/plugins/RemoteHardwarePlugin.cpp new file mode 100644 index 000000000..70c7232af --- /dev/null +++ b/src/plugins/RemoteHardwarePlugin.cpp @@ -0,0 +1,17 @@ +#include "RemoteHardwarePlugin.h" +#include "MeshService.h" +#include "NodeDB.h" +#include "RTC.h" +#include "Router.h" +#include "configuration.h" +#include "main.h" + +RemoteHardwarePlugin remoteHardwarePlugin; + +bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &mp, const HardwareMessage &p) +{ + + return false; // Let others look at this message also if they want +} + + diff --git a/src/plugins/RemoteHardwarePlugin.h b/src/plugins/RemoteHardwarePlugin.h new file mode 100644 index 000000000..faae4894d --- /dev/null +++ b/src/plugins/RemoteHardwarePlugin.h @@ -0,0 +1,24 @@ +#pragma once +#include "ProtobufPlugin.h" +#include "remote_hardware.pb.h" + +/** + * A plugin that provides easy low-level remote access to device hardware. + */ +class RemoteHardwarePlugin : public ProtobufPlugin +{ + public: + /** Constructor + * name is for debugging output + */ + RemoteHardwarePlugin() : ProtobufPlugin("remotehardware", PortNum_REMOTE_HARDWARE_APP, HardwareMessage_fields) {} + + protected: + /** Called to handle a particular incoming message + + @return true if you've guaranteed you've handled this message and no other handlers should be considered for it + */ + virtual bool handleReceivedProtobuf(const MeshPacket &mp, const HardwareMessage &p); +}; + +extern RemoteHardwarePlugin remoteHardwarePlugin; \ No newline at end of file