From 9b24cc6dd62c3e0883cde7d2e77a83cdd599a58a Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Fri, 4 Dec 2020 18:54:00 +0800 Subject: [PATCH] update protobufs --- bin/regen-protos.sh | 6 ++++++ docs/software/TODO.md | 40 ++++++++++++++++++++++++++++++++++++++++ proto | 2 +- src/mesh/mesh.pb.c | 3 --- src/mesh/mesh.pb.h | 24 ------------------------ src/mesh/portnums.pb.h | 2 +- 6 files changed, 48 insertions(+), 29 deletions(-) diff --git a/bin/regen-protos.sh b/bin/regen-protos.sh index dd266c54b..655db9a7a 100755 --- a/bin/regen-protos.sh +++ b/bin/regen-protos.sh @@ -1,6 +1,12 @@ #!/bin/bash +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 + +echo "Regenerating protobuf documentation - if you see an error message" +echo "you can ignore it unless doing a new protobuf release to github." +bin/regen-docs.sh \ No newline at end of file diff --git a/docs/software/TODO.md b/docs/software/TODO.md index d6119aebf..492d51def 100644 --- a/docs/software/TODO.md +++ b/docs/software/TODO.md @@ -9,6 +9,7 @@ For app cleanup: * on android for received positions handle either old or new positions * on android side send old or new positions as needed * fix position sending to use new plugin +* Add SinglePortNumPlugin - as the new most useful baseclass * move positions into regular data packets (use new app framework) * move user info into regular data packets (use new app framework) * test that positions, text messages and user info still work @@ -27,6 +28,45 @@ This should nicely help 'router' nodes do the right thing when long range, or if * turn on amazon reviews support * add a tablet layout (with map next to messages) in the android app +# Old docs to merge + +MESH RADIO PROTOCOL + +Old TODO notes on the mesh radio protocol, merge into real docs someday... + +for each named group we have a pre-shared key known by all group members and +wrapped around the device. you can only be in one group at a time (FIXME?!) To +join the group we read a qr code with the preshared key and ParamsCodeEnum. that +gets sent via bluetooth to the device. ParamsCodeEnum maps to a set of various +radio params (regulatory region, center freq, SF, bandwidth, bitrate, power +etc...) so all members of the mesh can have their radios set the same way. + +once in that group, we can talk between 254 node numbers. +to get our node number (and announce our presence in the channel) we pick a +random node number and broadcast as that node with WANT-NODENUM(my globally +unique name). If anyone on the channel has seen someone _else_ using that name +within the last 24 hrs(?) they reply with DENY-NODENUM. Note: we might receive +multiple denies. Note: this allows others to speak up for some other node that +might be saving battery right now. Any time we hear from another node (for any +message type), we add that node number to the unpickable list. To dramatically +decrease the odds a node number we request is already used by someone. If no one +denies within TBD seconds, we assume that we have that node number. As long as +we keep talking to folks at least once every 24 hrs, others should remember we +have it. + +Once we have a node number we can broadcast POSITION-UPDATE(my globally unique +name, lat, lon, alt, amt battery remaining). All receivers will use this to a) +update the mapping of who is at what node nums, b) the time of last rx, c) +position. If we haven't heard from that node in a while we reply to that node +(only) with our current POSITION_UPDATE state - so that node (presumably just +rejoined the network) can build a map of all participants. + +We will periodically broadcast POSITION-UPDATE as needed based on distance moved +or a periodic minimum heartbeat. + +If user wants to send a text they can SEND_TEXT(dest user, short text message). +Dest user is a node number, or 0xff for broadcast. + # Medium priority Items to complete before 1.0. diff --git a/proto b/proto index 9a7ffbecc..8b24fbab1 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 9a7ffbecc72a11904bd4e85d086956e4e77eed6d +Subproject commit 8b24fbab195ca76932e70456750cd0172d47db79 diff --git a/src/mesh/mesh.pb.c b/src/mesh/mesh.pb.c index 032d4ed7f..42b5eb949 100644 --- a/src/mesh/mesh.pb.c +++ b/src/mesh/mesh.pb.c @@ -51,9 +51,6 @@ PB_BIND(FromRadio, FromRadio, 2) PB_BIND(ToRadio, ToRadio, 2) -PB_BIND(ManufacturingData, ManufacturingData, AUTO) - - diff --git a/src/mesh/mesh.pb.h b/src/mesh/mesh.pb.h index 58323a98a..9fb4900b0 100644 --- a/src/mesh/mesh.pb.h +++ b/src/mesh/mesh.pb.h @@ -82,13 +82,6 @@ typedef struct _DebugString { char message[256]; } DebugString; -typedef struct _ManufacturingData { - uint32_t fradioFreq; - pb_callback_t hw_model; - pb_callback_t hw_version; - int32_t selftest_result; -} ManufacturingData; - typedef struct _MyNodeInfo { uint32_t my_node_num; bool has_gps; @@ -292,7 +285,6 @@ typedef struct _ToRadio { #define DebugString_init_default {""} #define FromRadio_init_default {0, 0, {MeshPacket_init_default}} #define ToRadio_init_default {0, {MeshPacket_init_default}} -#define ManufacturingData_init_default {0, {{NULL}, NULL}, {{NULL}, NULL}, 0} #define Position_init_zero {0, 0, 0, 0, 0} #define Data_init_zero {_PortNum_MIN, {0, {0}}} #define User_init_zero {"", "", "", {0}} @@ -308,7 +300,6 @@ typedef struct _ToRadio { #define DebugString_init_zero {""} #define FromRadio_init_zero {0, 0, {MeshPacket_init_zero}} #define ToRadio_init_zero {0, {MeshPacket_init_zero}} -#define ManufacturingData_init_zero {0, {{NULL}, NULL}, {{NULL}, NULL}, 0} /* Field tags (for use in manual encoding/decoding) */ #define ChannelSettings_tx_power_tag 1 @@ -322,10 +313,6 @@ typedef struct _ToRadio { #define Data_portnum_tag 1 #define Data_payload_tag 2 #define DebugString_message_tag 1 -#define ManufacturingData_fradioFreq_tag 1 -#define ManufacturingData_hw_model_tag 2 -#define ManufacturingData_hw_version_tag 3 -#define ManufacturingData_selftest_result_tag 4 #define MyNodeInfo_my_node_num_tag 1 #define MyNodeInfo_has_gps_tag 2 #define MyNodeInfo_num_channels_tag 3 @@ -615,14 +602,6 @@ X(a, STATIC, ONEOF, MESSAGE, (variant,set_owner,variant.set_owner), 102) #define ToRadio_variant_set_radio_MSGTYPE RadioConfig #define ToRadio_variant_set_owner_MSGTYPE User -#define ManufacturingData_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, fradioFreq, 1) \ -X(a, CALLBACK, SINGULAR, STRING, hw_model, 2) \ -X(a, CALLBACK, SINGULAR, STRING, hw_version, 3) \ -X(a, STATIC, SINGULAR, SINT32, selftest_result, 4) -#define ManufacturingData_CALLBACK pb_default_field_callback -#define ManufacturingData_DEFAULT NULL - extern const pb_msgdesc_t Position_msg; extern const pb_msgdesc_t Data_msg; extern const pb_msgdesc_t User_msg; @@ -638,7 +617,6 @@ extern const pb_msgdesc_t DeviceState_msg; extern const pb_msgdesc_t DebugString_msg; extern const pb_msgdesc_t FromRadio_msg; extern const pb_msgdesc_t ToRadio_msg; -extern const pb_msgdesc_t ManufacturingData_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ #define Position_fields &Position_msg @@ -656,7 +634,6 @@ extern const pb_msgdesc_t ManufacturingData_msg; #define DebugString_fields &DebugString_msg #define FromRadio_fields &FromRadio_msg #define ToRadio_fields &ToRadio_msg -#define ManufacturingData_fields &ManufacturingData_msg /* Maximum encoded size of messages (where known) */ #define Position_size 39 @@ -674,7 +651,6 @@ extern const pb_msgdesc_t ManufacturingData_msg; #define DebugString_size 258 #define FromRadio_size 323 #define ToRadio_size 317 -/* ManufacturingData_size depends on runtime parameters */ #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/portnums.pb.h b/src/mesh/portnums.pb.h index 285910510..179b9b5d6 100644 --- a/src/mesh/portnums.pb.h +++ b/src/mesh/portnums.pb.h @@ -17,8 +17,8 @@ extern "C" { typedef enum _PortNum { PortNum_UNKNOWN_APP = 0, PortNum_TEXT_MESSAGE_APP = 1, - PortNum_GPIO_APP = 2, PortNum_POSITION_APP = 3, + PortNum_GPIO_APP = 2, PortNum_MESH_USERINFO_APP = 4, PortNum_PRIVATE_APP = 256, PortNum_IP_TUNNEL_APP = 1024