From b4c379f5fcca0f0a8d77c8f850fe640ba9ef4436 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 18 Mar 2021 19:09:31 +0800 Subject: [PATCH 1/3] add sim exit cmd --- proto | 2 +- src/mesh/generated/admin.pb.h | 5 ++++- src/plugins/AdminPlugin.cpp | 11 +++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/proto b/proto index 39bb8b26b..b8c0499f2 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 39bb8b26bbc107aae3586d5a5e11a06ea12680bc +Subproject commit b8c0499f28f9673d1df17d04da562e30703f01cb diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index d68103cea..cf71a9cb2 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -25,6 +25,7 @@ typedef struct _AdminMessage { Channel get_channel_response; bool confirm_set_channel; bool confirm_set_radio; + bool exit_simulator; }; } AdminMessage; @@ -47,6 +48,7 @@ extern "C" { #define AdminMessage_get_channel_response_tag 7 #define AdminMessage_confirm_set_channel_tag 32 #define AdminMessage_confirm_set_radio_tag 33 +#define AdminMessage_exit_simulator_tag 34 /* Struct field encoding specification for nanopb */ #define AdminMessage_FIELDLIST(X, a) \ @@ -58,7 +60,8 @@ X(a, STATIC, ONEOF, MESSAGE, (variant,get_radio_response,get_radio_respons X(a, STATIC, ONEOF, UINT32, (variant,get_channel_request,get_channel_request), 6) \ X(a, STATIC, ONEOF, MESSAGE, (variant,get_channel_response,get_channel_response), 7) \ X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_channel,confirm_set_channel), 32) \ -X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_radio,confirm_set_radio), 33) +X(a, STATIC, ONEOF, BOOL, (variant,confirm_set_radio,confirm_set_radio), 33) \ +X(a, STATIC, ONEOF, BOOL, (variant,exit_simulator,exit_simulator), 34) #define AdminMessage_CALLBACK NULL #define AdminMessage_DEFAULT NULL #define AdminMessage_variant_set_radio_MSGTYPE RadioConfig diff --git a/src/plugins/AdminPlugin.cpp b/src/plugins/AdminPlugin.cpp index 96b5c51a0..9d935b26f 100644 --- a/src/plugins/AdminPlugin.cpp +++ b/src/plugins/AdminPlugin.cpp @@ -6,6 +6,10 @@ #include "configuration.h" #include "main.h" +#ifdef PORTDUINO +#include "unistd.h" +#endif + AdminPlugin *adminPlugin; void AdminPlugin::handleGetChannel(const MeshPacket &req, uint32_t channelIndex) @@ -65,6 +69,13 @@ bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, const AdminMessag handleGetRadio(mp); break; +#ifdef PORTDUINO + case AdminMessage_exit_simulator_tag: + DEBUG_MSG("Exiting simulator"); + _exit(0); + break; +#endif + default: // Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages DEBUG_MSG("Ignoring nonrelevant admin %d\n", r->which_variant); From cef6e248e705da642a7dbfae40a5941bd525eba6 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 18 Mar 2021 19:40:00 +0800 Subject: [PATCH 2/3] add newline --- src/plugins/AdminPlugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/AdminPlugin.cpp b/src/plugins/AdminPlugin.cpp index 9d935b26f..5cc4876aa 100644 --- a/src/plugins/AdminPlugin.cpp +++ b/src/plugins/AdminPlugin.cpp @@ -71,7 +71,7 @@ bool AdminPlugin::handleReceivedProtobuf(const MeshPacket &mp, const AdminMessag #ifdef PORTDUINO case AdminMessage_exit_simulator_tag: - DEBUG_MSG("Exiting simulator"); + DEBUG_MSG("Exiting simulator\n"); _exit(0); break; #endif From a97072eca05258ea5b9ec7518551eeca2e88530c Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 18 Mar 2021 19:48:06 +0800 Subject: [PATCH 3/3] add first integration test for CI --- .github/workflows/main.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 585775e48..b01111fd9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,10 +15,10 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.x - - name: Install Platform IO + - name: Install Platform IO and meshtastic-python run: | python -m pip install --upgrade pip - pip install -U platformio + pip install -U platformio meshtastic - name: Install extra python tools run: | pip install -U adafruit-nrfutil @@ -31,6 +31,11 @@ jobs: run: platformio run -e heltec - name: Build for lora-relay-v1 run: platformio run -e lora-relay-v1 - # Turn off linux for now - name: Build for native + - name: Build for native run: platformio run -e native + - name: Integration test + run: | + .pio/build/native/program & + sleep 1 + python3 -c 'from meshtastic.test import testSimulator; testSimulator()' +