begin moving position stuff into plugin

1.2-legacy
Kevin Hester 2020-11-28 13:51:51 +08:00
rodzic 5138aff4b2
commit 7737123d0f
8 zmienionych plików z 29 dodań i 14 usunięć

Wyświetl plik

@ -4,7 +4,9 @@ You probably don't care about this section - skip to the next one.
For app cleanup:
* add app handlers in device code (make new app framework)
* require a recent python api to talk to these new device loads
* on android for received positions handle either old or new positions
* on android side send old or new positions as needed
* 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

2
proto

@ -1 +1 @@
Subproject commit 7c1016b8a01d4d019c4239fe46624dee7bde22c7
Subproject commit 9a7ffbecc72a11904bd4e85d086956e4e77eed6d

Wyświetl plik

@ -22,7 +22,7 @@ MeshPlugin::~MeshPlugin()
void MeshPlugin::callPlugins(const MeshPacket &mp)
{
DEBUG_MSG("In call plugins\n");
// DEBUG_MSG("In call plugins\n");
for (auto i = plugins->begin(); i != plugins->end(); ++i) {
auto &pi = **i;
if (pi.wantPortnum(mp.decoded.data.portnum)) {

Wyświetl plik

@ -26,6 +26,11 @@ class MeshPlugin
virtual ~MeshPlugin();
/** For use only by MeshService
*/
static void callPlugins(const MeshPacket &mp);
protected:
/**
* Initialize your plugin. This setup function is called once after all hardware and mesh protocol layers have
* been initialized
@ -42,8 +47,4 @@ class MeshPlugin
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it
*/
virtual bool handleReceived(const MeshPacket &mp) { return false; }
/** For use only by MeshService
*/
static void callPlugins(const MeshPacket &mp);
};

Wyświetl plik

@ -297,7 +297,6 @@ void MeshService::sendOurPosition(NodeNum dest, bool wantReplies)
int MeshService::onGPSChanged(const meshtastic::GPSStatus *unused)
{
// Update our local node info with our position (even if we don't decide to update anyone else)
MeshPacket *p = router->allocForSending();
p->decoded.which_payload = SubPacket_position_tag;

Wyświetl plik

@ -18,16 +18,16 @@ typedef enum _PortNum {
PortNum_UNKNOWN_APP = 0,
PortNum_TEXT_MESSAGE_APP = 1,
PortNum_GPIO_APP = 2,
PortNum_GPS_POSITION_APP = 3,
PortNum_POSITION_APP = 3,
PortNum_MESH_USERINFO_APP = 4,
PortNum_IP_TUNNEL_APP = 5,
PortNum_PRIVATE_APP = 256
PortNum_PRIVATE_APP = 256,
PortNum_IP_TUNNEL_APP = 1024
} PortNum;
/* Helper constants for enums */
#define _PortNum_MIN PortNum_UNKNOWN_APP
#define _PortNum_MAX PortNum_PRIVATE_APP
#define _PortNum_ARRAYSIZE ((PortNum)(PortNum_PRIVATE_APP+1))
#define _PortNum_MAX PortNum_IP_TUNNEL_APP
#define _PortNum_ARRAYSIZE ((PortNum)(PortNum_IP_TUNNEL_APP+1))
#ifdef __cplusplus

Wyświetl plik

@ -0,0 +1,13 @@
#include "configuration.h"
#include "PositionPlugin.h"
#include "NodeDB.h"
PositionPlugin positionPlugin;
bool PositionPlugin::handleReceived(const MeshPacket &mp)
{
auto &p = mp.decoded.data;
DEBUG_MSG("Received position from=0x%0x, id=%d, msg=%.*s\n", mp.from, mp.id, p.payload.size, p.payload.bytes);
return false; // Let others look at this message also if they want
}

Wyświetl plik

@ -7,12 +7,12 @@
class TextMessagePlugin : public MeshPlugin, public Observable<const MeshPacket *>
{
public:
/** Constructor
* name is for debugging output
*/
TextMessagePlugin() : MeshPlugin("text") {}
protected:
/**
* @return true if you want to receive the specified portnum
*/