Merge pull request #739 from geeksville/dev

Dev
This commit is contained in:
Kevin Hester 2021-03-17 20:30:25 +08:00 committed by GitHub
commit a4bbdc443f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 152 additions and 130 deletions

View File

@ -4,12 +4,6 @@ set -e
VERSION=`bin/buildinfo.py` 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="tlora-v2 tlora-v1 tlora-v2-1-1.6 tbeam heltec tbeam0.7"
#BOARDS_ESP32=tbeam #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 # build the named environment and copy the bins to the release directory
function do_build() { function do_build() {
BOARD=$1 BOARD=$1
COUNTRY=$2
isNrf=$3 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.* rm -f .pio/build/$BOARD/firmware.*
# The shell vars the build tool expects to find # The shell vars the build tool expects to find
export APP_VERSION=$VERSION export APP_VERSION=$VERSION
# Are we building a universal/regionless rom? # 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" export HW_VERSION="1.0"
unset COUNTRY
basename=universal/firmware-$BOARD-$VERSION basename=universal/firmware-$BOARD-$VERSION
fi
pio run --environment $BOARD # -v pio run --environment $BOARD # -v
SRCELF=.pio/build/$BOARD/firmware.elf SRCELF=.pio/build/$BOARD/firmware.elf
@ -71,10 +56,6 @@ function do_boards() {
declare boards=$1 declare boards=$1
declare isNrf=$2 declare isNrf=$2
for board in $boards; do for board in $boards; do
for country in $COUNTRIES; do
do_build $board $country "$isNrf"
done
# Build universal # Build universal
do_build $board "" "$isNrf" do_build $board "" "$isNrf"
done done

View File

@ -35,6 +35,8 @@ shift "$((OPTIND-1))"
if [ -f "${FILENAME}" ]; then if [ -f "${FILENAME}" ]; then
echo "Trying to flash update ${FILENAME}." echo "Trying to flash update ${FILENAME}."
esptool.py --baud 921600 write_flash 0x10000 ${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 else
echo "Invalid file: ${FILENAME}" echo "Invalid file: ${FILENAME}"
show_help show_help

View File

@ -4,9 +4,15 @@ You probably don't care about this section - skip to the next one.
## 1.2 cleanup & multichannel support: ## 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 * 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 * luxon bug report - seeing rx acks for nodes that are not on the network
* channel hash suffixes are wrong on android * 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 * 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) * 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 * DONE call RouterPlugin for *all* packets - not just Router packets

2
proto

@ -1 +1 @@
Subproject commit bf8ac6718c08fe7c94a9896d91ef85572694f7b0 Subproject commit e68763737e3345ebf12c4776c84d27d83e1e9e1a

View File

@ -163,7 +163,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#if defined(TBEAM_V10) #if defined(TBEAM_V10)
// This string must exactly match the case used in release file names or the android updater won't work // 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 // #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 <http://www.gnu.org/licenses/>.
#elif defined(TBEAM_V07) #elif defined(TBEAM_V07)
// This string must exactly match the case used in release file names or the android updater won't work // 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 // #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 <http://www.gnu.org/licenses/>.
#elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2) #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 // 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. // the default ESP32 Pin of 15 is the Oled SCL, set to 36 and 37 and works fine.
// Tested on Neo6m module. // Tested on Neo6m module.
@ -258,7 +258,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(TLORA_V1) #elif defined(TLORA_V1)
// This string must exactly match the case used in release file names or the android updater won't work // 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_RX_PIN
#undef GPS_TX_PIN #undef GPS_TX_PIN
#define GPS_RX_PIN 36 #define GPS_RX_PIN 36
@ -282,7 +282,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(TLORA_V2) #elif defined(TLORA_V2)
// This string must exactly match the case used in release file names or the android updater won't work // 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_RX_PIN
#undef GPS_TX_PIN #undef GPS_TX_PIN
@ -311,7 +311,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(TLORA_V1_3) #elif defined(TLORA_V1_3)
// This string must exactly match the case used in release file names or the android updater won't work // 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_RX_PIN
#undef GPS_TX_PIN #undef GPS_TX_PIN
@ -338,7 +338,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(TLORA_V2_1_16) #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 // 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_RX_PIN
#undef GPS_TX_PIN #undef GPS_TX_PIN
@ -366,7 +366,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(GENIEBLOCKS) #elif defined(GENIEBLOCKS)
// This string must exactly match the case used in release file names or the android updater won't work // 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_RX_PIN
#undef GPS_TX_PIN #undef GPS_TX_PIN
#define GPS_RX_PIN 5 #define GPS_RX_PIN 5
@ -399,7 +399,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef ARDUINO_NRF52840_PCA10056 #ifdef ARDUINO_NRF52840_PCA10056
// This string must exactly match the case used in release file names or the android updater won't work // 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 // This board uses 0 to be mean LED on
#undef LED_INVERTED #undef LED_INVERTED
@ -407,15 +407,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#elif defined(ARDUINO_NRF52840_PPR) #elif defined(ARDUINO_NRF52840_PPR)
#define HW_VENDOR "ppr" #define HW_VENDOR HardwareModel_PPR
#elif NRF52_SERIES #elif NRF52_SERIES
#define HW_VENDOR "nrf52unknown" // FIXME - unknown nrf52 board #define HW_VENDOR HardwareModel_NRF52_UNKNOWN
#elif PORTDUINO #elif PORTDUINO
#define HW_VENDOR "portduino" #define HW_VENDOR HardwareModel_PORTDUINO
#define USE_SIM_RADIO #define USE_SIM_RADIO

View File

@ -365,7 +365,7 @@ void setup()
#endif #endif
// Hello // 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 #ifndef NO_ESP32
// Don't init display if we don't have one or we are waking headless due to a timer event // Don't init display if we don't have one or we are waking headless due to a timer event

View File

@ -10,6 +10,10 @@ static const uint8_t defaultpsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0
Channels channels; 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 xorHash(const uint8_t *p, size_t len)
{ {
uint8_t code = 0; uint8_t code = 0;

View File

@ -29,6 +29,10 @@ class Channels
int16_t hashes[MAX_NUM_CHANNELS]; int16_t hashes[MAX_NUM_CHANNELS];
public: public:
/// Well known channel names
static const char *adminChannel, *gpioChannel, *serialChannel;
const ChannelSettings &getPrimary() { return getByIndex(getPrimaryIndex()).settings; } const ChannelSettings &getPrimary() { return getByIndex(getPrimaryIndex()).settings; }
/** Return the Channel for a specified index */ /** Return the Channel for a specified index */

View File

@ -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) // keep using that nodenum forever. Crummy guess at our nodenum (but we will check against the nodedb to avoid conflicts)
pickNewNodeNum(); 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 // Include our owner in the node db under our nodenum
NodeInfo *info = getOrCreateNode(getNodeNum()); NodeInfo *info = getOrCreateNode(getNodeNum());
info->user = owner; info->user = owner;
@ -223,7 +226,10 @@ void NodeDB::init()
} }
strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version)); 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 resetRadioConfig(); // If bogus settings got saved, then fix them

View File

@ -14,9 +14,10 @@ ErrorCode ReliableRouter::send(MeshPacket *p)
{ {
if (p->want_ack) { 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 // 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) if (p->to == NODENUM_BROADCAST && p->hop_limit == 0)
p->hop_limit = 1; p->hop_limit = HOP_RELIABLE;
auto copy = packetPool.allocCopy(*p); auto copy = packetPool.allocCopy(*p);
startRetransmission(copy); startRetransmission(copy);

View File

@ -125,7 +125,7 @@ extern const pb_msgdesc_t ChannelFile_msg;
/* Maximum encoded size of messages (where known) */ /* Maximum encoded size of messages (where known) */
#define LegacyRadioConfig_size 4 #define LegacyRadioConfig_size 4
#define LegacyRadioConfig_LegacyPreferences_size 2 #define LegacyRadioConfig_LegacyPreferences_size 2
#define DeviceState_size 5056 #define DeviceState_size 4898
#define ChannelFile_size 832 #define ChannelFile_size 832
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -45,3 +45,4 @@ PB_BIND(ToRadio, ToRadio, 2)

View File

@ -11,6 +11,24 @@
#endif #endif
/* Enum definitions */ /* 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 { typedef enum _Constants {
Constants_Unused = 0, Constants_Unused = 0,
Constants_DATA_PAYLOAD_LEN = 240 Constants_DATA_PAYLOAD_LEN = 240
@ -84,7 +102,7 @@ typedef struct _MyNodeInfo {
bool has_gps; bool has_gps;
uint32_t num_bands; uint32_t num_bands;
char region[12]; char region[12];
char hw_model[16]; char hw_model_deprecated[16];
char firmware_version[12]; char firmware_version[12];
CriticalErrorCode error_code; CriticalErrorCode error_code;
uint32_t error_address; uint32_t error_address;
@ -112,6 +130,7 @@ typedef struct _User {
char long_name[40]; char long_name[40];
char short_name[5]; char short_name[5];
pb_byte_t macaddr[6]; pb_byte_t macaddr[6];
HardwareModel hw_model;
} User; } User;
typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t; typedef PB_BYTES_ARRAY_T(256) MeshPacket_encrypted_t;
@ -138,7 +157,6 @@ typedef struct _NodeInfo {
User user; User user;
bool has_position; bool has_position;
Position position; Position position;
uint32_t next_hop;
float snr; float snr;
} NodeInfo; } NodeInfo;
@ -174,6 +192,10 @@ typedef struct _ToRadio {
/* Helper constants for enums */ /* 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_MIN Constants_Unused
#define _Constants_MAX Constants_DATA_PAYLOAD_LEN #define _Constants_MAX Constants_DATA_PAYLOAD_LEN
#define _Constants_ARRAYSIZE ((Constants)(Constants_DATA_PAYLOAD_LEN+1)) #define _Constants_ARRAYSIZE ((Constants)(Constants_DATA_PAYLOAD_LEN+1))
@ -201,23 +223,23 @@ extern "C" {
/* Initializer values for message structs */ /* Initializer values for message structs */
#define Position_init_default {0, 0, 0, 0, 0} #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 RouteDiscovery_init_default {0, {0, 0, 0, 0, 0, 0, 0, 0}}
#define Routing_init_default {0, {RouteDiscovery_init_default}} #define Routing_init_default {0, {RouteDiscovery_init_default}}
#define Data_init_default {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0} #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 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 MyNodeInfo_init_default {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0}
#define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN} #define LogRecord_init_default {"", 0, "", _LogRecord_Level_MIN}
#define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}} #define FromRadio_init_default {0, 0, {MyNodeInfo_init_default}}
#define ToRadio_init_default {0, {MeshPacket_init_default}} #define ToRadio_init_default {0, {MeshPacket_init_default}}
#define Position_init_zero {0, 0, 0, 0, 0} #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 RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}}
#define Routing_init_zero {0, {RouteDiscovery_init_zero}} #define Routing_init_zero {0, {RouteDiscovery_init_zero}}
#define Data_init_zero {_PortNum_MIN, {0, {0}}, 0, 0, 0, 0} #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 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 MyNodeInfo_init_zero {0, 0, 0, "", "", "", _CriticalErrorCode_MIN, 0, 0, 0, 0, 0}
#define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN} #define LogRecord_init_zero {"", 0, "", _LogRecord_Level_MIN}
#define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}} #define FromRadio_init_zero {0, 0, {MyNodeInfo_init_zero}}
@ -238,7 +260,7 @@ extern "C" {
#define MyNodeInfo_has_gps_tag 2 #define MyNodeInfo_has_gps_tag 2
#define MyNodeInfo_num_bands_tag 3 #define MyNodeInfo_num_bands_tag 3
#define MyNodeInfo_region_tag 4 #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_firmware_version_tag 6
#define MyNodeInfo_error_code_tag 7 #define MyNodeInfo_error_code_tag 7
#define MyNodeInfo_error_address_tag 8 #define MyNodeInfo_error_address_tag 8
@ -256,6 +278,7 @@ extern "C" {
#define User_long_name_tag 2 #define User_long_name_tag 2
#define User_short_name_tag 3 #define User_short_name_tag 3
#define User_macaddr_tag 4 #define User_macaddr_tag 4
#define User_hw_model_tag 6
#define MeshPacket_from_tag 1 #define MeshPacket_from_tag 1
#define MeshPacket_to_tag 2 #define MeshPacket_to_tag 2
#define MeshPacket_channel_tag 3 #define MeshPacket_channel_tag 3
@ -270,7 +293,6 @@ extern "C" {
#define NodeInfo_num_tag 1 #define NodeInfo_num_tag 1
#define NodeInfo_user_tag 2 #define NodeInfo_user_tag 2
#define NodeInfo_position_tag 3 #define NodeInfo_position_tag 3
#define NodeInfo_next_hop_tag 5
#define NodeInfo_snr_tag 7 #define NodeInfo_snr_tag 7
#define Routing_route_request_tag 1 #define Routing_route_request_tag 1
#define Routing_route_reply_tag 2 #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, id, 1) \
X(a, STATIC, SINGULAR, STRING, long_name, 2) \ X(a, STATIC, SINGULAR, STRING, long_name, 2) \
X(a, STATIC, SINGULAR, STRING, short_name, 3) \ 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_CALLBACK NULL
#define User_DEFAULT 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, SINGULAR, UINT32, num, 1) \
X(a, STATIC, OPTIONAL, MESSAGE, user, 2) \ X(a, STATIC, OPTIONAL, MESSAGE, user, 2) \
X(a, STATIC, OPTIONAL, MESSAGE, position, 3) \ X(a, STATIC, OPTIONAL, MESSAGE, position, 3) \
X(a, STATIC, SINGULAR, UINT32, next_hop, 5) \
X(a, STATIC, SINGULAR, FLOAT, snr, 7) X(a, STATIC, SINGULAR, FLOAT, snr, 7)
#define NodeInfo_CALLBACK NULL #define NodeInfo_CALLBACK NULL
#define NodeInfo_DEFAULT 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, BOOL, has_gps, 2) \
X(a, STATIC, SINGULAR, UINT32, num_bands, 3) \ X(a, STATIC, SINGULAR, UINT32, num_bands, 3) \
X(a, STATIC, SINGULAR, STRING, region, 4) \ 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, STRING, firmware_version, 6) \
X(a, STATIC, SINGULAR, UENUM, error_code, 7) \ X(a, STATIC, SINGULAR, UENUM, error_code, 7) \
X(a, STATIC, SINGULAR, UINT32, error_address, 8) \ 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) */ /* Maximum encoded size of messages (where known) */
#define Position_size 37 #define Position_size 37
#define User_size 72 #define User_size 74
#define RouteDiscovery_size 40 #define RouteDiscovery_size 40
#define Routing_size 42 #define Routing_size 42
#define Data_size 260 #define Data_size 260
#define MeshPacket_size 298 #define MeshPacket_size 298
#define NodeInfo_size 130 #define NodeInfo_size 126
#define MyNodeInfo_size 89 #define MyNodeInfo_size 89
#define LogRecord_size 81 #define LogRecord_size 81
#define FromRadio_size 307 #define FromRadio_size 307

View File

@ -224,7 +224,8 @@ void NRF52Bluetooth::setup()
// Configure and Start the Device Information Service // Configure and Start the Device Information Service
DEBUG_MSG("Configuring the Device Information Service\n"); 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.setModel(optstr(HW_VERSION));
bledis.setFirmwareRev(optstr(APP_VERSION)); bledis.setFirmwareRev(optstr(APP_VERSION));
bledis.begin(); bledis.begin();

View File

@ -126,5 +126,5 @@ MeshPacket *AdminPlugin::allocReply()
AdminPlugin::AdminPlugin() : ProtobufPlugin("Admin", PortNum_ADMIN_APP, AdminMessage_fields) AdminPlugin::AdminPlugin() : ProtobufPlugin("Admin", PortNum_ADMIN_APP, AdminMessage_fields)
{ {
// restrict to the admin channel for rx // restrict to the admin channel for rx
boundChannel = "admin"; boundChannel = Channels::adminChannel;
} }

View File

@ -43,25 +43,17 @@
*/ */
// Default configurations // Default configurations
#define EXT_NOTIFICATION_PLUGIN_OUTPUT 13 #define EXT_NOTIFICATION_PLUGIN_OUTPUT 13
#define EXT_NOTIFICATION_PLUGIN_OUTPUT_MS 1000 #define EXT_NOTIFICATION_PLUGIN_OUTPUT_MS 1000
#define ASCII_BELL 0x07 #define ASCII_BELL 0x07
ExternalNotificationPlugin *externalNotificationPlugin;
ExternalNotificationPluginRadio *externalNotificationPluginRadio;
ExternalNotificationPlugin::ExternalNotificationPlugin() : concurrency::OSThread("ExternalNotificationPlugin") {}
bool externalCurrentState = 0; bool externalCurrentState = 0;
uint32_t externalTurnedOn = 0; uint32_t externalTurnedOn = 0;
int32_t ExternalNotificationPlugin::runOnce() int32_t ExternalNotificationPlugin::runOnce()
{ {
#ifndef NO_ESP32
/* /*
Uncomment the preferences below if you want to use the plugin Uncomment the preferences below if you want to use the plugin
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
@ -75,26 +67,6 @@ int32_t ExternalNotificationPlugin::runOnce()
// radioConfig.preferences.ext_notification_plugin_output_ms = 1000; // radioConfig.preferences.ext_notification_plugin_output_ms = 1000;
// radioConfig.preferences.ext_notification_plugin_output = 13; // radioConfig.preferences.ext_notification_plugin_output = 13;
if (radioConfig.preferences.ext_notification_plugin_enabled) {
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
setExternalOff();
externalNotificationPluginRadio = new ExternalNotificationPluginRadio();
firstTime = 0;
} else {
if (externalCurrentState) { if (externalCurrentState) {
// If the output is turned on, turn it back off after the given period of time. // If the output is turned on, turn it back off after the given period of time.
@ -106,17 +78,8 @@ int32_t ExternalNotificationPlugin::runOnce()
setExternalOff(); setExternalOff();
} }
} }
}
return (25); return (25);
} else {
DEBUG_MSG("External Notification Plugin Disabled\n");
return (INT32_MAX);
}
#else
return INT32_MAX;
#endif
} }
void ExternalNotificationPlugin::setExternalOn() 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 #ifndef NO_ESP32
@ -156,14 +159,14 @@ bool ExternalNotificationPluginRadio::handleReceived(const MeshPacket &mp)
DEBUG_MSG("externalNotificationPlugin - Notification Bell\n"); DEBUG_MSG("externalNotificationPlugin - Notification Bell\n");
for (int i = 0; i < p.payload.size; i++) { for (int i = 0; i < p.payload.size; i++) {
if (p.payload.bytes[i] == ASCII_BELL) { if (p.payload.bytes[i] == ASCII_BELL) {
externalNotificationPlugin->setExternalOn(); setExternalOn();
} }
} }
} }
if (radioConfig.preferences.ext_notification_plugin_alert_message) { if (radioConfig.preferences.ext_notification_plugin_alert_message) {
DEBUG_MSG("externalNotificationPlugin - Notification Plugin\n"); DEBUG_MSG("externalNotificationPlugin - Notification Plugin\n");
externalNotificationPlugin->setExternalOn(); setExternalOn();
} }
} }

View File

@ -6,11 +6,12 @@
#include <Arduino.h> #include <Arduino.h>
#include <functional> #include <functional>
/*
class ExternalNotificationPlugin : private concurrency::OSThread * Radio interface for ExternalNotificationPlugin
*
*/
class ExternalNotificationPlugin : public SinglePortPlugin, private concurrency::OSThread
{ {
bool firstTime = 1;
public: public:
ExternalNotificationPlugin(); ExternalNotificationPlugin();
@ -18,22 +19,6 @@ class ExternalNotificationPlugin : private concurrency::OSThread
void setExternalOff(); void setExternalOff();
void getExternal(); 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: protected:
// virtual MeshPacket *allocReply(); // virtual MeshPacket *allocReply();
@ -42,6 +27,6 @@ class ExternalNotificationPluginRadio : public SinglePortPlugin
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it @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); virtual bool handleReceived(const MeshPacket &mp);
};
extern ExternalNotificationPluginRadio *externalNotificationPluginRadio; virtual int32_t runOnce();
};

View File

@ -69,6 +69,7 @@ bool RemoteHardwarePlugin::handleReceivedProtobuf(const MeshPacket &req, const H
case HardwareMessage_Type_READ_GPIOS: { case HardwareMessage_Type_READ_GPIOS: {
// Print notification to LCD screen // Print notification to LCD screen
if(screen)
screen->print("Read GPIOs\n"); screen->print("Read GPIOs\n");
uint64_t res = digitalReads(p.gpio_mask); uint64_t res = digitalReads(p.gpio_mask);

View File

@ -61,6 +61,12 @@ SerialPlugin::SerialPlugin() : concurrency::OSThread("SerialPlugin") {}
char serialStringChar[Constants_DATA_PAYLOAD_LEN]; 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() int32_t SerialPlugin::runOnce()
{ {
#ifndef NO_ESP32 #ifndef NO_ESP32

View File

@ -33,8 +33,7 @@ class SerialPluginRadio : public SinglePortPlugin
from the main code. from the main code.
*/ */
// SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_TEXT_MESSAGE_APP) {} SerialPluginRadio();
SerialPluginRadio() : SinglePortPlugin("SerialPluginRadio", PortNum_SERIAL_APP) {}
/** /**
* Send our payload into the mesh * Send our payload into the mesh