From 4777e53c231827e86af09de2684b80b8519ad025 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Mon, 28 Dec 2020 13:36:11 +0800 Subject: [PATCH] more mqtt design work --- docs/software/mqtt.md | 7 ++++-- proto | 2 +- src/mesh/apponly.pb.c | 12 ++++++++++ src/mesh/apponly.pb.h | 56 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 src/mesh/apponly.pb.c create mode 100644 src/mesh/apponly.pb.h diff --git a/docs/software/mqtt.md b/docs/software/mqtt.md index d2060acb..0be2ccae 100644 --- a/docs/software/mqtt.md +++ b/docs/software/mqtt.md @@ -84,9 +84,9 @@ FIXME, possibly don't global mirror text messages - instead rely on matrix/riot? #### Service Envelope -The payload published on mesh/... will always be wrapped in a ServiceEnvelope protobuf. +The payload published on mesh/... will always be wrapped in a [ServiceEnvelope protobuf](https://github.com/meshtastic/Meshtastic-protobufs/blob/master/docs/docs.md#.ServiceEnvelope). -FIXME, the payload published on the topic, will include the message, and full information about arrival time, who forwarded it, source channel, source mesh id, etc... +ServiceEnvelope will include the message, and full information about arrival time, who forwarded it, source channel, source mesh id, etc... #### NODEID @@ -174,6 +174,9 @@ on how this will be implemented and guesses at approximate work items. - DONE Refactor the position features into a position "mini-app". Use only the new public on-device API to implement this app. - DONE Refactor the on device texting features into a messaging "mini-app". (Similar to the position mini-app) - Add new multi channel concept +- Add portion of channelid to the raw lora packet header +- Confirm that we can now forward encrypted packets without decrypting at each node +- Use a channel named "remotehw" to secure the GPIO service. If that channel is not found, don't even start the service. Document this as the standard method for securing services. - Add first cut of the "gateway node" code (i.e. MQTT broker client) to the python API (very little code needed for this component) - Confirm that texting works to/from the internet - Confirm that positions are optionally sent to the internet diff --git a/proto b/proto index 5a23071d..a66504ed 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 5a23071d2363725ca954562f00bfca0d5717ca79 +Subproject commit a66504ed6404ed967799e8b4441e4a2adbe62660 diff --git a/src/mesh/apponly.pb.c b/src/mesh/apponly.pb.c new file mode 100644 index 00000000..c93d6329 --- /dev/null +++ b/src/mesh/apponly.pb.c @@ -0,0 +1,12 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.4 */ + +#include "apponly.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(ServiceEnvelope, ServiceEnvelope, 2) + + + diff --git a/src/mesh/apponly.pb.h b/src/mesh/apponly.pb.h new file mode 100644 index 00000000..29b1f4bf --- /dev/null +++ b/src/mesh/apponly.pb.h @@ -0,0 +1,56 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.4 */ + +#ifndef PB_APPONLY_PB_H_INCLUDED +#define PB_APPONLY_PB_H_INCLUDED +#include +#include "mesh.pb.h" + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Struct definitions */ +typedef struct _ServiceEnvelope { + bool has_packet; + MeshPacket packet; + pb_callback_t channel_id; + pb_callback_t mesh_id; +} ServiceEnvelope; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define ServiceEnvelope_init_default {false, MeshPacket_init_default, {{NULL}, NULL}, {{NULL}, NULL}} +#define ServiceEnvelope_init_zero {false, MeshPacket_init_zero, {{NULL}, NULL}, {{NULL}, NULL}} + +/* Field tags (for use in manual encoding/decoding) */ +#define ServiceEnvelope_packet_tag 1 +#define ServiceEnvelope_channel_id_tag 2 +#define ServiceEnvelope_mesh_id_tag 3 + +/* Struct field encoding specification for nanopb */ +#define ServiceEnvelope_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, packet, 1) \ +X(a, CALLBACK, SINGULAR, STRING, channel_id, 2) \ +X(a, CALLBACK, SINGULAR, STRING, mesh_id, 3) +#define ServiceEnvelope_CALLBACK pb_default_field_callback +#define ServiceEnvelope_DEFAULT NULL +#define ServiceEnvelope_packet_MSGTYPE MeshPacket + +extern const pb_msgdesc_t ServiceEnvelope_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define ServiceEnvelope_fields &ServiceEnvelope_msg + +/* Maximum encoded size of messages (where known) */ +/* ServiceEnvelope_size depends on runtime parameters */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif