mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-24 17:32:18 +00:00
add remote gpio control as an example plugin
https://github.com/meshtastic/Meshtastic-device/issues/182
This commit is contained in:
parent
3e0dc44210
commit
8f5a1f19d3
@ -5,7 +5,7 @@ set -e
|
|||||||
echo "This script requires https://jpa.kapsi.fi/nanopb/download/ version 0.4.1"
|
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!
|
# the nanopb tool seems to require that the .options file be in the current directory!
|
||||||
cd proto
|
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 "Regenerating protobuf documentation - if you see an error message"
|
||||||
echo "you can ignore it unless doing a new protobuf release to github."
|
echo "you can ignore it unless doing a new protobuf release to github."
|
||||||
|
@ -4,14 +4,16 @@ You probably don't care about this section - skip to the next one.
|
|||||||
|
|
||||||
For app cleanup:
|
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 python api to talk to these new device loads
|
||||||
* DONE require a recent android app to talk to these new device loads
|
* DONE require a recent android app to talk to these new device loads
|
||||||
* DONE fix handleIncomingPosition
|
* DONE fix handleIncomingPosition
|
||||||
* DONE move want_replies handling into plugins
|
* DONE move want_replies handling into plugins
|
||||||
* on android for received positions handle either old or new positions / user messages
|
* 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 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 fix position sending to use new plugin
|
||||||
* DONE Add SinglePortNumPlugin - as the new most useful baseclass
|
* DONE Add SinglePortNumPlugin - as the new most useful baseclass
|
||||||
* DONE move positions into regular data packets (use new app framework)
|
* 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
|
* test that position, text messages and user info work properly with new android app and old device code
|
||||||
* call the plugin setup functions
|
* call the plugin setup functions
|
||||||
* fix the RTC drift bug
|
* fix the RTC drift bug
|
||||||
|
* move ping functionality into device, reply with rxsnr info
|
||||||
|
|
||||||
For high speed/lots of devices/short range tasks:
|
For high speed/lots of devices/short range tasks:
|
||||||
|
|
||||||
|
2
proto
2
proto
@ -1 +1 @@
|
|||||||
Subproject commit 13b69ad55079e3f35774f63e960064867de20235
|
Subproject commit 6e8d220ad0d9f7ae6ce37db94c2b3f55a70f4f45
|
@ -17,7 +17,7 @@ extern "C" {
|
|||||||
typedef enum _PortNum {
|
typedef enum _PortNum {
|
||||||
PortNum_UNKNOWN_APP = 0,
|
PortNum_UNKNOWN_APP = 0,
|
||||||
PortNum_TEXT_MESSAGE_APP = 1,
|
PortNum_TEXT_MESSAGE_APP = 1,
|
||||||
PortNum_GPIO_APP = 2,
|
PortNum_REMOTE_HARDWARE_APP = 2,
|
||||||
PortNum_POSITION_APP = 3,
|
PortNum_POSITION_APP = 3,
|
||||||
PortNum_NODEINFO_APP = 4,
|
PortNum_NODEINFO_APP = 4,
|
||||||
PortNum_PRIVATE_APP = 256,
|
PortNum_PRIVATE_APP = 256,
|
||||||
|
13
src/mesh/remote_hardware.pb.c
Normal file
13
src/mesh/remote_hardware.pb.c
Normal file
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
69
src/mesh/remote_hardware.pb.h
Normal file
69
src/mesh/remote_hardware.pb.h
Normal file
@ -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 <pb.h>
|
||||||
|
|
||||||
|
#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
|
17
src/plugins/RemoteHardwarePlugin.cpp
Normal file
17
src/plugins/RemoteHardwarePlugin.cpp
Normal file
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
24
src/plugins/RemoteHardwarePlugin.h
Normal file
24
src/plugins/RemoteHardwarePlugin.h
Normal file
@ -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<HardwareMessage>
|
||||||
|
{
|
||||||
|
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;
|
Loading…
Reference in New Issue
Block a user