diff --git a/bin/build-all.sh b/bin/build-all.sh
index fae51feee..1e2f159bb 100755
--- a/bin/build-all.sh
+++ b/bin/build-all.sh
@@ -4,12 +4,6 @@ set -e
VERSION=`bin/buildinfo.py`
-# We now only do regionless builds
-COUNTRIES=""
-#COUNTRIES="US EU433 EU865 CN JP ANZ KR"
-#COUNTRIES=US
-#COUNTRIES=CN
-
BOARDS_ESP32="tlora-v2 tlora-v1 tlora-v2-1-1.6 tbeam heltec tbeam0.7"
#BOARDS_ESP32=tbeam
@@ -30,26 +24,17 @@ mkdir -p $OUTDIR/bins/universal $OUTDIR/elfs/universal
# build the named environment and copy the bins to the release directory
function do_build() {
BOARD=$1
- COUNTRY=$2
isNrf=$3
- echo "Building $COUNTRY for $BOARD with $PLATFORMIO_BUILD_FLAGS"
+ echo "Building for $BOARD with $PLATFORMIO_BUILD_FLAGS"
rm -f .pio/build/$BOARD/firmware.*
# The shell vars the build tool expects to find
export APP_VERSION=$VERSION
# Are we building a universal/regionless rom?
- if [ "x$COUNTRY" != "x" ]
- then
- export HW_VERSION="1.0-$COUNTRY"
- export COUNTRY
- basename=firmware-$BOARD-$COUNTRY-$VERSION
- else
- export HW_VERSION="1.0"
- unset COUNTRY
- basename=universal/firmware-$BOARD-$VERSION
- fi
+ export HW_VERSION="1.0"
+ basename=universal/firmware-$BOARD-$VERSION
pio run --environment $BOARD # -v
SRCELF=.pio/build/$BOARD/firmware.elf
@@ -71,10 +56,6 @@ function do_boards() {
declare boards=$1
declare isNrf=$2
for board in $boards; do
- for country in $COUNTRIES; do
- do_build $board $country "$isNrf"
- done
-
# Build universal
do_build $board "" "$isNrf"
done
diff --git a/bin/device-update.sh b/bin/device-update.sh
index 4125ade6a..894230364 100755
--- a/bin/device-update.sh
+++ b/bin/device-update.sh
@@ -35,6 +35,8 @@ shift "$((OPTIND-1))"
if [ -f "${FILENAME}" ]; then
echo "Trying to flash update ${FILENAME}."
esptool.py --baud 921600 write_flash 0x10000 ${FILENAME}
+ echo "Erasing the otadata partition, which will turn off flash flippy-flop and force the first image to be used"
+ esptool.py --baud 921600 erase_region 0xe000 0x2000
else
echo "Invalid file: ${FILENAME}"
show_help
diff --git a/docs/software/TODO.md b/docs/software/TODO.md
index 3a768e68f..9633c021e 100644
--- a/docs/software/TODO.md
+++ b/docs/software/TODO.md
@@ -4,9 +4,15 @@ You probably don't care about this section - skip to the next one.
## 1.2 cleanup & multichannel support:
+* DONE cleanup the external notification and serial plugins
+* non ack version of stress test fails sometimes!
* timestamps on oled screen are wrong - don't seem to be updating based on message rx
* luxon bug report - seeing rx acks for nodes that are not on the network
* channel hash suffixes are wrong on android
+* tx fault test has a bug #734
+* DONE move device types into an enum in nodeinfo
+* fix android to use new device types for firmware update
+
* cdcacm bug on nrf52: emittx thinks it emitted but client sees nothing. works again later
* nrf52: segger logs have errors in formatting that should be impossible (because not going through serial, try stalling on segger)
* DONE call RouterPlugin for *all* packets - not just Router packets
diff --git a/proto b/proto
index bf8ac6718..e68763737 160000
--- a/proto
+++ b/proto
@@ -1 +1 @@
-Subproject commit bf8ac6718c08fe7c94a9896d91ef85572694f7b0
+Subproject commit e68763737e3345ebf12c4776c84d27d83e1e9e1a
diff --git a/src/configuration.h b/src/configuration.h
index cb68a2e39..e389e46cf 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -163,7 +163,7 @@ along with this program. If not, see .
#if defined(TBEAM_V10)
// This string must exactly match the case used in release file names or the android updater won't work
-#define HW_VENDOR "tbeam"
+#define HW_VENDOR HardwareModel_TBEAM
// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep
@@ -204,7 +204,7 @@ along with this program. If not, see .
#elif defined(TBEAM_V07)
// This string must exactly match the case used in release file names or the android updater won't work
-#define HW_VENDOR "tbeam0.7"
+#define HW_VENDOR HardwareModel_TBEAM0p7
// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep
@@ -228,7 +228,7 @@ along with this program. If not, see .
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2)
// This string must exactly match the case used in release file names or the android updater won't work
-#define HW_VENDOR "heltec"
+#define HW_VENDOR HardwareModel_HELTEC
// the default ESP32 Pin of 15 is the Oled SCL, set to 36 and 37 and works fine.
// Tested on Neo6m module.
@@ -258,7 +258,7 @@ along with this program. If not, see .
#elif defined(TLORA_V1)
// This string must exactly match the case used in release file names or the android updater won't work
-#define HW_VENDOR "tlora-v1"
+#define HW_VENDOR HardwareModel_TLORA_V1
#undef GPS_RX_PIN
#undef GPS_TX_PIN
#define GPS_RX_PIN 36
@@ -282,7 +282,7 @@ along with this program. If not, see .
#elif defined(TLORA_V2)
// This string must exactly match the case used in release file names or the android updater won't work
-#define HW_VENDOR "tlora-v2"
+#define HW_VENDOR HardwareModel_TLORA_V2
#undef GPS_RX_PIN
#undef GPS_TX_PIN
@@ -311,7 +311,7 @@ along with this program. If not, see .
#elif defined(TLORA_V1_3)
// This string must exactly match the case used in release file names or the android updater won't work
-#define HW_VENDOR "tlora-v1-3"
+#define HW_VENDOR HardwareModel_TLORA_V1p3
#undef GPS_RX_PIN
#undef GPS_TX_PIN
@@ -338,7 +338,7 @@ along with this program. If not, see .
#elif defined(TLORA_V2_1_16)
// This string must exactly match the case used in release file names or the android updater won't work
-#define HW_VENDOR "tlora-v2-1-1.6"
+#define HW_VENDOR HardwareModel_TLORA_V2_1p6_
#undef GPS_RX_PIN
#undef GPS_TX_PIN
@@ -366,7 +366,7 @@ along with this program. If not, see .
#elif defined(GENIEBLOCKS)
// This string must exactly match the case used in release file names or the android updater won't work
-#define HW_VENDOR "genieblocks"
+#define HW_VENDOR HardwareModel_GENIEBLOCKS
#undef GPS_RX_PIN
#undef GPS_TX_PIN
#define GPS_RX_PIN 5
@@ -399,7 +399,7 @@ along with this program. If not, see .
#ifdef ARDUINO_NRF52840_PCA10056
// This string must exactly match the case used in release file names or the android updater won't work
-#define HW_VENDOR "nrf52dk"
+#define HW_VENDOR HardwareModel_NRF52840DK
// This board uses 0 to be mean LED on
#undef LED_INVERTED
@@ -407,15 +407,15 @@ along with this program. If not, see .
#elif defined(ARDUINO_NRF52840_PPR)
-#define HW_VENDOR "ppr"
+#define HW_VENDOR HardwareModel_PPR
#elif NRF52_SERIES
-#define HW_VENDOR "nrf52unknown" // FIXME - unknown nrf52 board
+#define HW_VENDOR HardwareModel_NRF52_UNKNOWN
#elif PORTDUINO
-#define HW_VENDOR "portduino"
+#define HW_VENDOR HardwareModel_PORTDUINO
#define USE_SIM_RADIO
diff --git a/src/main.cpp b/src/main.cpp
index d4eaafae2..d0c024004 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -365,7 +365,7 @@ void setup()
#endif
// Hello
- DEBUG_MSG("Meshtastic hwvendor=%s, swver=%s, hwver=%s\n", HW_VENDOR, optstr(APP_VERSION), optstr(HW_VERSION));
+ DEBUG_MSG("Meshtastic hwvendor=%d, swver=%s, hwver=%s\n", HW_VENDOR, optstr(APP_VERSION), optstr(HW_VERSION));
#ifndef NO_ESP32
// Don't init display if we don't have one or we are waking headless due to a timer event
diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp
index 2a04c9a7b..135ff4329 100644
--- a/src/mesh/Channels.cpp
+++ b/src/mesh/Channels.cpp
@@ -10,6 +10,10 @@ static const uint8_t defaultpsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0
Channels channels;
+const char *Channels::adminChannel = "admin";
+const char *Channels::gpioChannel = "gpio";
+const char *Channels::serialChannel = "serial";
+
uint8_t xorHash(const uint8_t *p, size_t len)
{
uint8_t code = 0;
diff --git a/src/mesh/Channels.h b/src/mesh/Channels.h
index 4fbafe42b..bbd767fa0 100644
--- a/src/mesh/Channels.h
+++ b/src/mesh/Channels.h
@@ -29,6 +29,10 @@ class Channels
int16_t hashes[MAX_NUM_CHANNELS];
public:
+
+ /// Well known channel names
+ static const char *adminChannel, *gpioChannel, *serialChannel;
+
const ChannelSettings &getPrimary() { return getByIndex(getPrimaryIndex()).settings; }
/** Return the Channel for a specified index */
diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp
index 1840aa360..35f54fa72 100644
--- a/src/mesh/NodeDB.cpp
+++ b/src/mesh/NodeDB.cpp
@@ -195,6 +195,9 @@ void NodeDB::init()
// keep using that nodenum forever. Crummy guess at our nodenum (but we will check against the nodedb to avoid conflicts)
pickNewNodeNum();
+ // Set our board type so we can share it with others
+ owner.hw_model = HW_VENDOR;
+
// Include our owner in the node db under our nodenum
NodeInfo *info = getOrCreateNode(getNodeNum());
info->user = owner;
@@ -223,7 +226,10 @@ void NodeDB::init()
}
strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version));
- strncpy(myNodeInfo.hw_model, HW_VENDOR, sizeof(myNodeInfo.hw_model));
+
+ // hw_model is no longer stored in myNodeInfo (as of 1.2.11) - we now store it as an enum in nodeinfo
+ myNodeInfo.hw_model_deprecated[0] = '\0';
+ // strncpy(myNodeInfo.hw_model, HW_VENDOR, sizeof(myNodeInfo.hw_model));
resetRadioConfig(); // If bogus settings got saved, then fix them
diff --git a/src/mesh/ReliableRouter.cpp b/src/mesh/ReliableRouter.cpp
index 28ad65bfa..131d5bb97 100644
--- a/src/mesh/ReliableRouter.cpp
+++ b/src/mesh/ReliableRouter.cpp
@@ -14,9 +14,10 @@ ErrorCode ReliableRouter::send(MeshPacket *p)
{
if (p->want_ack) {
// If someone asks for acks on broadcast, we need the hop limit to be at least one, so that first node that receives our
- // message will rebroadcast
+ // message will rebroadcast. But asking for hop_limit 0 in that context means the client app has no preference on hop counts
+ // and we want this message to get through the whole mesh, so use the default.
if (p->to == NODENUM_BROADCAST && p->hop_limit == 0)
- p->hop_limit = 1;
+ p->hop_limit = HOP_RELIABLE;
auto copy = packetPool.allocCopy(*p);
startRetransmission(copy);
diff --git a/src/mesh/generated/deviceonly.pb.h b/src/mesh/generated/deviceonly.pb.h
index 9c40e2110..a325dfc50 100644
--- a/src/mesh/generated/deviceonly.pb.h
+++ b/src/mesh/generated/deviceonly.pb.h
@@ -125,7 +125,7 @@ extern const pb_msgdesc_t ChannelFile_msg;
/* Maximum encoded size of messages (where known) */
#define LegacyRadioConfig_size 4
#define LegacyRadioConfig_LegacyPreferences_size 2
-#define DeviceState_size 5056
+#define DeviceState_size 4898
#define ChannelFile_size 832
#ifdef __cplusplus
diff --git a/src/mesh/generated/mesh.pb.c b/src/mesh/generated/mesh.pb.c
index ab27832f8..b2cc65f06 100644
--- a/src/mesh/generated/mesh.pb.c
+++ b/src/mesh/generated/mesh.pb.c
@@ -45,3 +45,4 @@ PB_BIND(ToRadio, ToRadio, 2)
+
diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h
index 10487e40d..5f4f9bf35 100644
--- a/src/mesh/generated/mesh.pb.h
+++ b/src/mesh/generated/mesh.pb.h
@@ -11,6 +11,24 @@
#endif
/* Enum definitions */
+typedef enum _HardwareModel {
+ HardwareModel_UNSET = 0,
+ HardwareModel_TLORA_V2 = 1,
+ HardwareModel_TLORA_V1 = 2,
+ HardwareModel_TLORA_V2_1_1p6 = 3,
+ HardwareModel_TBEAM = 4,
+ HardwareModel_HELTEC = 5,
+ HardwareModel_TBEAM0p7 = 6,
+ HardwareModel_T_ECHO = 7,
+ HardwareModel_TLORA_V1_1p3 = 8,
+ HardwareModel_LORA_RELAY_V1 = 32,
+ HardwareModel_NRF52840DK = 33,
+ HardwareModel_PPR = 34,
+ HardwareModel_GENIEBLOCKS = 35,
+ HardwareModel_NRF52_UNKNOWN = 36,
+ HardwareModel_PORTDUINO = 37
+} HardwareModel;
+
typedef enum _Constants {
Constants_Unused = 0,
Constants_DATA_PAYLOAD_LEN = 240
@@ -84,7 +102,7 @@ typedef struct _MyNodeInfo {
bool has_gps;
uint32_t num_bands;
char region[12];
- char hw_model[16];
+ char hw_model_deprecated[16];
char firmware_version[12];
CriticalErrorCode error_code;
uint32_t error_address;
@@ -112,6 +130,7 @@ typedef struct _User {
char long_name[40];
char short_name[5];
pb_byte_t macaddr[6];
+ HardwareModel hw_model;
} User;
typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t;
@@ -138,7 +157,6 @@ typedef struct _NodeInfo {
User user;
bool has_position;
Position position;
- uint32_t next_hop;
float snr;
} NodeInfo;
@@ -174,6 +192,10 @@ typedef struct _ToRadio {
/* Helper constants for enums */
+#define _HardwareModel_MIN HardwareModel_UNSET
+#define _HardwareModel_MAX HardwareModel_PORTDUINO
+#define _HardwareModel_ARRAYSIZE ((HardwareModel)(HardwareModel_PORTDUINO+1))
+
#define _Constants_MIN Constants_Unused
#define _Constants_MAX Constants_DATA_PAYLOAD_LEN
#define _Constants_ARRAYSIZE ((Constants)(Constants_DATA_PAYLOAD_LEN+1))
@@ -201,23 +223,23 @@ extern "C" {
/* Initializer values for message structs */
#define Position_init_default {0, 0, 0, 0, 0}
-#define User_init_default {"", "", "", {0}}
+#define User_init_default {"", "", "", {0}, _HardwareModel_MIN}
#define RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}}
#define Routing_init_default {0, {RouteDiscovery_init_default}}
#define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0}
#define MeshPacket_init_default {0, 0, 0, 0, {Data_init_default}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN}
-#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0}
+#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0}
#define MyNodeInfo_init_default {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0}
#define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN}
#define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}}
#define ToRadio_init_default {0, {MeshPacket_init_default}}
#define Position_init_zero {0, 0, 0, 0, 0}
-#define User_init_zero {"", "", "", {0}}
+#define User_init_zero {"", "", "", {0}, _HardwareModel_MIN}
#define RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}}
#define Routing_init_zero {0, {RouteDiscovery_init_zero}}
#define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0}
#define MeshPacket_init_zero {0, 0, 0, 0, {Data_init_zero}, 0, 0, 0, 0, 0, _MeshPacket_Priority_MIN}
-#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0}
+#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0}
#define MyNodeInfo_init_zero {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0}
#define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN}
#define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}}
@@ -238,7 +260,7 @@ extern "C" {
#define MyNodeInfo_has_gps_tag 2
#define MyNodeInfo_num_bands_tag 3
#define MyNodeInfo_region_tag 4
-#define MyNodeInfo_hw_model_tag 5
+#define MyNodeInfo_hw_model_deprecated_tag 5
#define MyNodeInfo_firmware_version_tag 6
#define MyNodeInfo_error_code_tag 7
#define MyNodeInfo_error_address_tag 8
@@ -256,6 +278,7 @@ extern "C" {
#define User_long_name_tag 2
#define User_short_name_tag 3
#define User_macaddr_tag 4
+#define User_hw_model_tag 6
#define MeshPacket_from_tag 1
#define MeshPacket_to_tag 2
#define MeshPacket_channel_tag 3
@@ -270,7 +293,6 @@ extern "C" {
#define NodeInfo_num_tag 1
#define NodeInfo_user_tag 2
#define NodeInfo_position_tag 3
-#define NodeInfo_next_hop_tag 5
#define NodeInfo_snr_tag 7
#define Routing_route_request_tag 1
#define Routing_route_reply_tag 2
@@ -299,7 +321,8 @@ X(a, STATIC, SINGULAR, FIXED32, time, 9)
X(a, STATIC, SINGULAR, STRING, id, 1) \
X(a, STATIC, SINGULAR, STRING, long_name, 2) \
X(a, STATIC, SINGULAR, STRING, short_name, 3) \
-X(a, STATIC, SINGULAR, FIXED_LENGTH_BYTES, macaddr, 4)
+X(a, STATIC, SINGULAR, FIXED_LENGTH_BYTES, macaddr, 4) \
+X(a, STATIC, SINGULAR, UENUM, hw_model, 6)
#define User_CALLBACK NULL
#define User_DEFAULT NULL
@@ -347,7 +370,6 @@ X(a, STATIC, SINGULAR, UENUM, priority, 12)
X(a, STATIC, SINGULAR, UINT32, num, 1) \
X(a, STATIC, OPTIONAL, MESSAGE, user, 2) \
X(a, STATIC, OPTIONAL, MESSAGE, position, 3) \
-X(a, STATIC, SINGULAR, UINT32, next_hop, 5) \
X(a, STATIC, SINGULAR, FLOAT, snr, 7)
#define NodeInfo_CALLBACK NULL
#define NodeInfo_DEFAULT NULL
@@ -359,7 +381,7 @@ X(a, STATIC, SINGULAR, UINT32, my_node_num, 1) \
X(a, STATIC, SINGULAR, BOOL, has_gps, 2) \
X(a, STATIC, SINGULAR, UINT32, num_bands, 3) \
X(a, STATIC, SINGULAR, STRING, region, 4) \
-X(a, STATIC, SINGULAR, STRING, hw_model, 5) \
+X(a, STATIC, SINGULAR, STRING, hw_model_deprecated, 5) \
X(a, STATIC, SINGULAR, STRING, firmware_version, 6) \
X(a, STATIC, SINGULAR, UENUM, error_code, 7) \
X(a, STATIC, SINGULAR, UINT32, error_address, 8) \
@@ -427,12 +449,12 @@ extern const pb_msgdesc_t ToRadio_msg;
/* Maximum encoded size of messages (where known) */
#define Position_size 37
-#define User_size 72
+#define User_size 74
#define RouteDiscovery_size 40
#define Routing_size 42
#define Data_size 260
#define MeshPacket_size 298
-#define NodeInfo_size 130
+#define NodeInfo_size 126
#define MyNodeInfo_size 89
#define LogRecord_size 81
#define FromRadio_size 307
diff --git a/src/nrf52/NRF52Bluetooth.cpp b/src/nrf52/NRF52Bluetooth.cpp
index 35093ff17..244918e93 100644
--- a/src/nrf52/NRF52Bluetooth.cpp
+++ b/src/nrf52/NRF52Bluetooth.cpp
@@ -224,7 +224,8 @@ void NRF52Bluetooth::setup()
// Configure and Start the Device Information Service
DEBUG_MSG("Configuring the Device Information Service\n");
- bledis.setManufacturer(HW_VENDOR);
+ // FIXME, we should set a mfg string based on our HW_VENDOR enum
+ // bledis.setManufacturer(HW_VENDOR);
bledis.setModel(optstr(HW_VERSION));
bledis.setFirmwareRev(optstr(APP_VERSION));
bledis.begin();
diff --git a/src/plugins/AdminPlugin.cpp b/src/plugins/AdminPlugin.cpp
index 060b1e635..96b5c51a0 100644
--- a/src/plugins/AdminPlugin.cpp
+++ b/src/plugins/AdminPlugin.cpp
@@ -126,5 +126,5 @@ MeshPacket *AdminPlugin::allocReply()
AdminPlugin::AdminPlugin() : ProtobufPlugin("Admin", PortNum_ADMIN_APP, AdminMessage_fields)
{
// restrict to the admin channel for rx
- boundChannel = "admin";
+ boundChannel = Channels::adminChannel;
}
diff --git a/src/plugins/ExternalNotificationPlugin.cpp b/src/plugins/ExternalNotificationPlugin.cpp
index 0320c7b30..e48b7beda 100644
--- a/src/plugins/ExternalNotificationPlugin.cpp
+++ b/src/plugins/ExternalNotificationPlugin.cpp
@@ -43,25 +43,17 @@
*/
-
// Default configurations
#define EXT_NOTIFICATION_PLUGIN_OUTPUT 13
#define EXT_NOTIFICATION_PLUGIN_OUTPUT_MS 1000
#define ASCII_BELL 0x07
-ExternalNotificationPlugin *externalNotificationPlugin;
-ExternalNotificationPluginRadio *externalNotificationPluginRadio;
-
-ExternalNotificationPlugin::ExternalNotificationPlugin() : concurrency::OSThread("ExternalNotificationPlugin") {}
-
bool externalCurrentState = 0;
uint32_t externalTurnedOn = 0;
int32_t ExternalNotificationPlugin::runOnce()
{
-#ifndef NO_ESP32
-
/*
Uncomment the preferences below if you want to use the plugin
without having to configure it from the PythonAPI or WebUI.
@@ -75,48 +67,19 @@ int32_t ExternalNotificationPlugin::runOnce()
// radioConfig.preferences.ext_notification_plugin_output_ms = 1000;
// radioConfig.preferences.ext_notification_plugin_output = 13;
- if (radioConfig.preferences.ext_notification_plugin_enabled) {
+ if (externalCurrentState) {
- if (firstTime) {
-
- DEBUG_MSG("Initializing External Notification Plugin\n");
-
- // Set the direction of a pin
- pinMode((radioConfig.preferences.ext_notification_plugin_output
- ? radioConfig.preferences.ext_notification_plugin_output
- : EXT_NOTIFICATION_PLUGIN_OUTPUT),
- OUTPUT);
-
- // Turn off the pin
+ // If the output is turned on, turn it back off after the given period of time.
+ if (externalTurnedOn + (radioConfig.preferences.ext_notification_plugin_output_ms
+ ? radioConfig.preferences.ext_notification_plugin_output_ms
+ : EXT_NOTIFICATION_PLUGIN_OUTPUT_MS) <
+ millis()) {
+ DEBUG_MSG("Turning off external notification\n");
setExternalOff();
-
- externalNotificationPluginRadio = new ExternalNotificationPluginRadio();
-
- firstTime = 0;
-
- } else {
- if (externalCurrentState) {
-
- // If the output is turned on, turn it back off after the given period of time.
- if (externalTurnedOn + (radioConfig.preferences.ext_notification_plugin_output_ms
- ? radioConfig.preferences.ext_notification_plugin_output_ms
- : EXT_NOTIFICATION_PLUGIN_OUTPUT_MS) <
- millis()) {
- DEBUG_MSG("Turning off external notification\n");
- setExternalOff();
- }
- }
}
-
- return (25);
- } else {
- DEBUG_MSG("External Notification Plugin Disabled\n");
-
- return (INT32_MAX);
}
-#else
- return INT32_MAX;
-#endif
+
+ return (25);
}
void ExternalNotificationPlugin::setExternalOn()
@@ -140,7 +103,47 @@ void ExternalNotificationPlugin::setExternalOff()
// --------
-bool ExternalNotificationPluginRadio::handleReceived(const MeshPacket &mp)
+ExternalNotificationPlugin::ExternalNotificationPlugin()
+ : SinglePortPlugin("ExternalNotificationPlugin", PortNum_TEXT_MESSAGE_APP), concurrency::OSThread(
+ "ExternalNotificationPlugin")
+{
+ // restrict to the admin channel for rx
+ boundChannel = Channels::gpioChannel;
+
+#ifndef NO_ESP32
+
+ /*
+ Uncomment the preferences below if you want to use the plugin
+ without having to configure it from the PythonAPI or WebUI.
+ */
+
+ // radioConfig.preferences.ext_notification_plugin_enabled = 1;
+ // radioConfig.preferences.ext_notification_plugin_alert_message = 1;
+
+ // radioConfig.preferences.ext_notification_plugin_active = 1;
+ // radioConfig.preferences.ext_notification_plugin_alert_bell = 1;
+ // radioConfig.preferences.ext_notification_plugin_output_ms = 1000;
+ // radioConfig.preferences.ext_notification_plugin_output = 13;
+
+ if (radioConfig.preferences.ext_notification_plugin_enabled) {
+
+ DEBUG_MSG("Initializing External Notification Plugin\n");
+
+ // Set the direction of a pin
+ pinMode((radioConfig.preferences.ext_notification_plugin_output ? radioConfig.preferences.ext_notification_plugin_output
+ : EXT_NOTIFICATION_PLUGIN_OUTPUT),
+ OUTPUT);
+
+ // Turn off the pin
+ setExternalOff();
+ } else {
+ DEBUG_MSG("External Notification Plugin Disabled\n");
+ enabled = false;
+ }
+#endif
+}
+
+bool ExternalNotificationPlugin::handleReceived(const MeshPacket &mp)
{
#ifndef NO_ESP32
@@ -156,14 +159,14 @@ bool ExternalNotificationPluginRadio::handleReceived(const MeshPacket &mp)
DEBUG_MSG("externalNotificationPlugin - Notification Bell\n");
for (int i = 0; i < p.payload.size; i++) {
if (p.payload.bytes[i] == ASCII_BELL) {
- externalNotificationPlugin->setExternalOn();
+ setExternalOn();
}
}
}
if (radioConfig.preferences.ext_notification_plugin_alert_message) {
DEBUG_MSG("externalNotificationPlugin - Notification Plugin\n");
- externalNotificationPlugin->setExternalOn();
+ setExternalOn();
}
}
diff --git a/src/plugins/ExternalNotificationPlugin.h b/src/plugins/ExternalNotificationPlugin.h
index a9ef58d04..cb430b1b7 100644
--- a/src/plugins/ExternalNotificationPlugin.h
+++ b/src/plugins/ExternalNotificationPlugin.h
@@ -6,11 +6,12 @@
#include
#include
-
-class ExternalNotificationPlugin : private concurrency::OSThread
+/*
+ * Radio interface for ExternalNotificationPlugin
+ *
+ */
+class ExternalNotificationPlugin : public SinglePortPlugin, private concurrency::OSThread
{
- bool firstTime = 1;
-
public:
ExternalNotificationPlugin();
@@ -19,29 +20,13 @@ class ExternalNotificationPlugin : private concurrency::OSThread
void getExternal();
protected:
- virtual int32_t runOnce();
-};
-
-extern ExternalNotificationPlugin *externalNotificationPlugin;
-
-/*
- * Radio interface for ExternalNotificationPlugin
- *
- */
-class ExternalNotificationPluginRadio : public SinglePortPlugin
-{
-
- public:
- ExternalNotificationPluginRadio() : SinglePortPlugin("ExternalNotificationPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
-
- protected:
- //virtual MeshPacket *allocReply();
+ // virtual MeshPacket *allocReply();
/** 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 handleReceived(const MeshPacket &mp);
-};
-extern ExternalNotificationPluginRadio *externalNotificationPluginRadio;
\ No newline at end of file
+ virtual int32_t runOnce();
+};
diff --git a/src/plugins/RemoteHardwarePlugin.cpp b/src/plugins/RemoteHardwarePlugin.cpp
index 33130663f..ac7e70e58 100644
--- a/src/plugins/RemoteHardwarePlugin.cpp
+++ b/src/plugins/RemoteHardwarePlugin.cpp
@@ -69,7 +69,8 @@ bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, const H
case HardwareMessage_Type_READ_GPIOS: {
// Print notification to LCD screen
- screen->print("Read GPIOs\n");
+ if(screen)
+ screen->print("Read GPIOs\n");
uint64_t res = digitalReads(p.gpio_mask);
diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp
index 9aab876f9..a2e2113b3 100644
--- a/src/plugins/SerialPlugin.cpp
+++ b/src/plugins/SerialPlugin.cpp
@@ -61,6 +61,12 @@ SerialPlugin::SerialPlugin() : concurrency::OSThread("SerialPlugin") {}
char serialStringChar[Constants_DATA_PAYLOAD_LEN];
+SerialPluginRadio::SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP)
+{
+ // restrict to the admin channel for rx
+ boundChannel = Channels::serialChannel;
+}
+
int32_t SerialPlugin::runOnce()
{
#ifndef NO_ESP32
diff --git a/src/plugins/SerialPlugin.h b/src/plugins/SerialPlugin.h
index 4555c65b8..54776ec6a 100644
--- a/src/plugins/SerialPlugin.h
+++ b/src/plugins/SerialPlugin.h
@@ -33,8 +33,7 @@ class SerialPluginRadio : public SinglePortPlugin
from the main code.
*/
- // SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_TEXT_MESSAGE_APP) {}
- SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP) {}
+ SerialPluginRadio();
/**
* Send our payload into the mesh