Compare commits

...

34 Commits

Author SHA1 Message Date
Ben Meadors
91ff7b9032 Merge pull request #2036 from meshtastic/create-pull-request/patch
Changes by create-pull-request action
2022-12-12 12:18:06 -06:00
thebentern
643f99f577 [create-pull-request] automated change 2022-12-12 18:06:11 +00:00
Ben Meadors
152288b4cc Merge pull request #2025 from meshtastic/power-fsm-experiment
Power FSM experiment
2022-12-12 12:01:00 -06:00
Ben Meadors
45b518baf2 Move sds transition back into esp32 only 2022-12-12 10:24:51 -06:00
Ben Meadors
0c65c73f90 Merge branch 'master' into power-fsm-experiment 2022-12-09 19:50:26 -06:00
Thomas Göttgens
0f0dbc3274 reboot nrf52 on critical error 8 2022-12-09 11:18:43 +01:00
Thomas Göttgens
06d34daeab Merge branch 'master' into power-fsm-experiment 2022-12-08 10:18:01 +01:00
Thomas Göttgens
ba1f68d758 Merge pull request #2027 from lewisxhe/master
Fix the charging parmas error of tbeam-s3core and change the default USB mode
2022-12-06 16:39:38 +01:00
Thomas Göttgens
d4c0977a70 Merge branch 'master' into master 2022-12-06 15:49:32 +01:00
Thomas Göttgens
1a19d71e95 Merge pull request #2023 from meshtastic/2022-bug-recording-critical-error-11-at-srcmeshradiolibinterfacecpp389
Add debug output
2022-12-06 15:48:57 +01:00
Thomas Göttgens
21c10934fc Merge pull request #2018 from arduionoGP/patch-3
Update MQTT.cpp
2022-12-06 15:47:30 +01:00
Thomas Göttgens
13cca91097 Merge branch 'master' into patch-3 2022-12-06 14:09:29 +01:00
Thomas Göttgens
b335b1c66b Merge branch 'master' into 2022-bug-recording-critical-error-11-at-srcmeshradiolibinterfacecpp389 2022-12-06 14:08:48 +01:00
Thomas Göttgens
cc2653bfb5 Merge pull request #2029 from meshtastic/create-pull-request/patch
Changes by create-pull-request action
2022-12-06 14:05:51 +01:00
caveman99
fc5bf5a68f [create-pull-request] automated change 2022-12-06 13:03:26 +00:00
lewishe
63d7338311 fix tbeams3-core PMU charging cut-off voltage 2022-12-06 11:01:14 +08:00
lewishe
37f716d27b Change tbeams3-core the default USB mode to TinyUSB 2022-12-06 10:58:59 +08:00
Ben Meadors
0f2a835359 Remove hard coded !isPowered 2022-12-05 10:13:19 -06:00
Thomas Göttgens
2a84d39e40 Always do battery resampling if we use the ADC. Improves reading a lot. 2022-12-05 16:40:23 +01:00
Ben Meadors
b14289e976 More cleanup 2022-12-05 08:35:54 -06:00
Ben Meadors
1fef6f0656 Clean up on battery shutdown condition 2022-12-05 07:37:01 -06:00
Thomas Göttgens
183ec2124f Add debug output 2022-12-05 11:48:46 +01:00
Ben Meadors
aeb9bfa063 Return false 2022-12-04 20:41:00 -06:00
arduinoGP
b84c7ae49b Oops, added time to the Pos 2022-12-04 19:41:58 -05:00
Thomas Göttgens
61598c5942 Merge pull request #2020 from meshtastic/serial-textmessage
Serial textmessage mode
2022-12-04 23:53:29 +01:00
Ben Meadors
a3a24e0216 Don't put newlines in the text buffer 2022-12-04 16:03:57 -06:00
Ben Meadors
31ec2da0e9 Text message mode for serial 2022-12-04 15:40:28 -06:00
arduinoGP
27a10b395f Update MQTT.cpp
(First real try at writing meaningful C++ but it seems to work.)
Allows sending JSON Position data from MQTT broker for broadcast to a LORA mesh via gateway device.
The new type is "sendposition". Valid envelope looks like:
{
    "sender": "someSender",
    "type": "sendposition",
    "payload": {
        "latitude_i": 399600000,
        "longitude_i": -862600000,
        "altitude": 100
    }
}
This complements the "sendtext" type envelope.
2022-12-04 00:00:43 -05:00
Ben Meadors
7570cdbd22 Fix shell scripts for both linux and darwin 2022-12-03 08:24:11 -06:00
Thomas Göttgens
c857474116 Merge pull request #2013 from arduionoGP/patch-2
Update MQTT.cpp
2022-12-01 22:17:35 +01:00
arduinoGP
8ff5dacc3c Update MQTT.cpp
case Portnum_POSITION_APP adjusted so the various options allways get encoded into JSON as long as lat and long are present. There are circumstances where timestamp, time, or altitude might be missing and this causes silent failures of JSON encoding..
2022-12-01 15:44:47 -05:00
Ben Meadors
f1179d31ba Fixed shell scripts 2022-11-27 07:40:40 -06:00
Ben Meadors
abe60b96f1 Merge pull request #2001 from meshtastic/create-pull-request/patch
Changes by create-pull-request action
2022-11-27 06:11:39 -06:00
thebentern
206520f179 [create-pull-request] automated change 2022-11-27 02:16:21 +00:00
18 changed files with 97 additions and 63 deletions

1
.gitignore vendored
View File

@@ -29,3 +29,4 @@ __pycache__
venv/
release/
.vscode/extensions.json

View File

@@ -45,7 +45,7 @@ shift "$((OPTIND-1))"
shift
}
if [ -f "${FILENAME}" ] && [[ "${FILENAME}" != *"update"* ]]; then
if [ -f "${FILENAME}" ] && [ ! -z "${FILENAME##*"update"*}" ]; then
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
"$PYTHON" -m esptool erase_flash
"$PYTHON" -m esptool write_flash 0x00 ${FILENAME}

View File

@@ -43,7 +43,7 @@ shift "$((OPTIND-1))"
shift
}
if [ -f "${FILENAME}" ] && [[ $FILENAME == *"update"* ]]; then
if [ -f "${FILENAME}" ] && [ -z "${FILENAME##*"update"*}" ]; then
printf "Trying to flash update ${FILENAME}"
$PYTHON -m esptool --baud 115200 write_flash 0x10000 ${FILENAME}
else

View File

@@ -1,6 +1,6 @@
{
"build": {
"arduino":{
"arduino": {
"ldscript": "esp32s3_out.ld"
},
"core": "esp32",
@@ -8,9 +8,7 @@
"-DBOARD_HAS_PSRAM",
"-DLILYGO_TBEAM_S3_CORE",
"-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_USB_DFU_ON_BOOT=1",
"-DARDUINO_USB_MSC_ON_BOOT=1",
"-DARDUINO_USB_MODE=1",
"-DARDUINO_USB_MODE=0",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1"
],

View File

@@ -102,6 +102,10 @@ class AnalogBatteryLevel : public HasBatteryLevel
#define ADC_MULTIPLIER 2.0
#endif
#ifndef BATTERY_SENSE_SAMPLES
#define BATTERY_SENSE_SAMPLES 30
#endif
#ifdef BATTERY_PIN
// Override variant or default ADC_MULTIPLIER if we have the override pref
float operativeAdcMultiplier = config.power.adc_multiplier_override > 0
@@ -112,16 +116,12 @@ class AnalogBatteryLevel : public HasBatteryLevel
if (millis() - last_read_time_ms > min_read_interval) {
last_read_time_ms = millis();
#ifdef BATTERY_SENSE_SAMPLES
//Set the number of samples, it has an effect of increasing sensitivity, especially in complex electromagnetic environment.
uint32_t raw = 0;
for(uint32_t i=0; i<BATTERY_SENSE_SAMPLES;i++){
for(uint32_t i=0; i<BATTERY_SENSE_SAMPLES; i++){
raw += analogRead(BATTERY_PIN);
}
raw = raw/BATTERY_SENSE_SAMPLES;
#else
uint32_t raw = analogRead(BATTERY_PIN);
#endif
float scaled;
#ifndef VBAT_RAW_TO_SCALED
@@ -290,7 +290,8 @@ void Power::readPowerStatus()
if (powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) {
if (batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS) {
low_voltage_counter++;
if (low_voltage_counter > 3)
DEBUG_MSG("Warning RAK4631 Low voltage counter: %d/10\n", low_voltage_counter);
if (low_voltage_counter > 10)
powerFSM.trigger(EVENT_LOW_BATTERY);
} else {
low_voltage_counter = 0;
@@ -455,6 +456,9 @@ bool Power::axpChipInit()
// Set constant current charging current
PMU->setChargerConstantCurr(XPOWERS_AXP192_CHG_CUR_450MA);
//Set up the charging voltage
PMU->setChargeTargetVoltage(XPOWERS_AXP192_CHG_VOL_4V2);
} else if (PMU->getChipModel() == XPOWERS_AXP2101) {
// t-beam s3 core
@@ -507,6 +511,8 @@ bool Power::axpChipInit()
//Set the constant current charging current of AXP2101, temporarily use 500mA by default
PMU->setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_500MA);
//Set up the charging voltage
PMU->setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V2);
}
@@ -560,9 +566,6 @@ bool Power::axpChipInit()
DEBUG_MSG("=======================================================================\n");
//Set up the charging voltage, AXP2101/AXP192 4.2V gear is the same
// XPOWERS_AXP192_CHG_VOL_4V2 = XPOWERS_AXP2101_CHG_VOL_4V2
PMU->setChargeTargetVoltage(XPOWERS_AXP192_CHG_VOL_4V2);
// Set PMU shutdown voltage at 2.6V to maximize battery utilization
PMU->setSysPowerDownVoltage(2600);

View File

@@ -34,7 +34,7 @@ static void sdsEnter()
{
DEBUG_MSG("Enter state: SDS\n");
// FIXME - make sure GPS and LORA radio are off first - because we want close to zero current draw
doDeepSleep(config.power.sds_secs * 1000);
doDeepSleep(getConfiguredOrDefaultMs(config.power.sds_secs));
}
extern Power *power;
@@ -324,11 +324,6 @@ void PowerFSM_setup()
powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_CONTACT_FROM_PHONE, NULL, "Contact from phone");
// each time we get a new update packet make sure we are staying in the ON state so the screen stays awake (also we don't
// shutdown bluetooth if is_router)
powerFSM.add_transition(&stateDARK, &stateON, EVENT_FIRMWARE_UPDATE, NULL, "Got firmware update");
powerFSM.add_transition(&stateON, &stateON, EVENT_FIRMWARE_UPDATE, NULL, "Got firmware update");
powerFSM.add_timed_transition(&stateON, &stateDARK, getConfiguredOrDefaultMs(config.display.screen_on_secs, default_screen_on_secs), NULL, "Screen-on timeout");
// On most boards we use light-sleep to be our main state, but on NRF52 we just stay in DARK
@@ -343,12 +338,13 @@ void PowerFSM_setup()
powerFSM.add_timed_transition(&stateDARK, &stateLS, getConfiguredOrDefaultMs(config.power.wait_bluetooth_secs, default_wait_bluetooth_secs), NULL, "Bluetooth timeout");
}
if (config.power.sds_secs != UINT32_MAX)
powerFSM.add_timed_transition(lowPowerState, &stateSDS, getConfiguredOrDefaultMs(config.power.sds_secs), NULL, "mesh timeout");
#elif defined (ARCH_NRF52)
lowPowerState = &stateDARK;
#endif
if (config.power.sds_secs != UINT32_MAX)
powerFSM.add_timed_transition(lowPowerState, &stateSDS, config.power.sds_secs * 1000, NULL, "mesh timeout");
powerFSM.run_machine(); // run one interation of the state machine, so we run our on enter tasks for the initial DARK state
}

View File

@@ -27,10 +27,8 @@ class PowerFSMThread : public OSThread
if (powerStatus->getHasUSB()) {
timeLastPowered = millis();
} else if (config.power.on_battery_shutdown_after_secs > 0 &&
millis() >
timeLastPowered +
(1000 *
config.power.on_battery_shutdown_after_secs)) { // shutdown after 30 minutes unpowered
config.power.on_battery_shutdown_after_secs != UINT32_MAX &&
millis() > (timeLastPowered + getConfiguredOrDefaultMs(config.power.on_battery_shutdown_after_secs))) { // shutdown after 30 minutes unpowered
powerFSM.trigger(EVENT_SHUTDOWN);
}

View File

@@ -3,6 +3,7 @@
#include "NodeDB.h"
#include "SPILock.h"
#include "configuration.h"
#include "main.h"
#include "error.h"
#include "mesh-pb-constants.h"
#include <pb_decode.h>
@@ -87,10 +88,8 @@ bool RadioLibInterface::canSendImmediately()
if (busyTx && (millis() - lastTxStart > 60000)) {
DEBUG_MSG("Hardware Failure! busyTx for more than 60s\n");
RECORD_CRITICALERROR(CriticalErrorCode_TRANSMIT_FAILED);
#ifdef ARCH_ESP32
if (busyTx && (millis() - lastTxStart > 65000)) // After 5s more, reboot
ESP.restart();
#endif
// reboot in 5 seconds when this condition occurs.
rebootAtMsec = lastTxStart + 65000;
}
if (busyRx)
DEBUG_MSG("Can not send yet, busyRx\n");
@@ -386,6 +385,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
int res = iface->startTransmit(radiobuf, numbytes);
if (res != RADIOLIB_ERR_NONE) {
DEBUG_MSG("startTransmit failed, error=%d\n", res);
RECORD_CRITICALERROR(CriticalErrorCode_RADIO_SPI_BUG);
// This send failed, but make sure to 'complete' it properly

View File

@@ -54,7 +54,7 @@ extern const pb_msgdesc_t ChannelSet_msg;
#define ChannelSet_fields &ChannelSet_msg
/* Maximum encoded size of messages (where known) */
#define ChannelSet_size 582
#define ChannelSet_size 584
#ifdef __cplusplus
} /* extern "C" */

View File

@@ -126,6 +126,7 @@ typedef struct _Config_LoRaConfig {
bool tx_enabled;
int8_t tx_power;
uint16_t channel_num;
bool override_duty_cycle;
pb_size_t ignore_incoming_count;
uint32_t ignore_incoming[3];
} Config_LoRaConfig;
@@ -235,7 +236,7 @@ extern "C" {
#define Config_NetworkConfig_init_default {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_default}
#define Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0}
#define Config_DisplayConfig_init_default {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN}
#define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}}
#define Config_LoRaConfig_init_default {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, {0, 0, 0}}
#define Config_BluetoothConfig_init_default {0, _Config_BluetoothConfig_PairingMode_MIN, 0}
#define Config_init_zero {0, {Config_DeviceConfig_init_zero}}
#define Config_DeviceConfig_init_zero {_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0}
@@ -244,7 +245,7 @@ extern "C" {
#define Config_NetworkConfig_init_zero {0, "", "", "", 0, _Config_NetworkConfig_EthMode_MIN, false, Config_NetworkConfig_IpV4Config_init_zero}
#define Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0}
#define Config_DisplayConfig_init_zero {0, _Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _Config_DisplayConfig_DisplayUnits_MIN, _Config_DisplayConfig_OledType_MIN}
#define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, {0, 0, 0}}
#define Config_LoRaConfig_init_zero {0, _Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, {0, 0, 0}}
#define Config_BluetoothConfig_init_zero {0, _Config_BluetoothConfig_PairingMode_MIN, 0}
/* Field tags (for use in manual encoding/decoding) */
@@ -274,6 +275,7 @@ extern "C" {
#define Config_LoRaConfig_tx_enabled_tag 9
#define Config_LoRaConfig_tx_power_tag 10
#define Config_LoRaConfig_channel_num_tag 11
#define Config_LoRaConfig_override_duty_cycle_tag 12
#define Config_LoRaConfig_ignore_incoming_tag 103
#define Config_NetworkConfig_IpV4Config_ip_tag 1
#define Config_NetworkConfig_IpV4Config_gateway_tag 2
@@ -407,6 +409,7 @@ X(a, STATIC, SINGULAR, UINT32, hop_limit, 8) \
X(a, STATIC, SINGULAR, BOOL, tx_enabled, 9) \
X(a, STATIC, SINGULAR, INT32, tx_power, 10) \
X(a, STATIC, SINGULAR, UINT32, channel_num, 11) \
X(a, STATIC, SINGULAR, BOOL, override_duty_cycle, 12) \
X(a, STATIC, REPEATED, UINT32, ignore_incoming, 103)
#define Config_LoRaConfig_CALLBACK NULL
#define Config_LoRaConfig_DEFAULT NULL
@@ -443,7 +446,7 @@ extern const pb_msgdesc_t Config_BluetoothConfig_msg;
#define Config_BluetoothConfig_size 10
#define Config_DeviceConfig_size 18
#define Config_DisplayConfig_size 22
#define Config_LoRaConfig_size 68
#define Config_LoRaConfig_size 70
#define Config_NetworkConfig_IpV4Config_size 20
#define Config_NetworkConfig_size 161
#define Config_PositionConfig_size 42

View File

@@ -150,8 +150,8 @@ extern const pb_msgdesc_t LocalModuleConfig_msg;
#define LocalModuleConfig_fields &LocalModuleConfig_msg
/* Maximum encoded size of messages (where known) */
#define LocalConfig_size 385
#define LocalModuleConfig_size 361
#define LocalConfig_size 387
#define LocalModuleConfig_size 358
#ifdef __cplusplus
} /* extern "C" */

View File

@@ -185,9 +185,11 @@ typedef enum _Routing_Error {
/* TODO: REPLACE */
Routing_Error_NO_RESPONSE = 8,
/* TODO: REPLACE */
Routing_Error_BAD_REQUEST = 32,
Routing_Error_DUTY_CYCLE_LIMIT = 9,
/* The new version of the heltec WiFi_Lora_32_V2 board that has battery sensing hooked to GPIO 37.
Sadly they did not update anything on the silkscreen to identify this board */
Routing_Error_BAD_REQUEST = 32,
/* Ancient heltec WiFi_Lora_32 board */
Routing_Error_NOT_AUTHORIZED = 33
} Routing_Error;

View File

@@ -63,10 +63,12 @@ typedef enum _ModuleConfig_CannedMessageConfig_InputEventChar {
/* Struct definitions */
typedef struct _ModuleConfig_AudioConfig {
bool codec2_enabled;
uint32_t mic_chan;
uint32_t amp_pin;
uint32_t ptt_pin;
uint8_t ptt_pin;
ModuleConfig_AudioConfig_Audio_Baud bitrate;
uint8_t i2s_ws;
uint8_t i2s_sd;
uint8_t i2s_din;
uint8_t i2s_sck;
} ModuleConfig_AudioConfig;
typedef struct _ModuleConfig_CannedMessageConfig {
@@ -183,7 +185,7 @@ extern "C" {
/* Initializer values for message structs */
#define ModuleConfig_init_default {0, {ModuleConfig_MQTTConfig_init_default}}
#define ModuleConfig_MQTTConfig_init_default {0, "", "", "", 0, 0}
#define ModuleConfig_AudioConfig_init_default {0, 0, 0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN}
#define ModuleConfig_AudioConfig_init_default {0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0}
#define ModuleConfig_SerialConfig_init_default {0, 0, 0, 0, _ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _ModuleConfig_SerialConfig_Serial_Mode_MIN}
#define ModuleConfig_ExternalNotificationConfig_init_default {0, 0, 0, 0, 0, 0, 0}
#define ModuleConfig_StoreForwardConfig_init_default {0, 0, 0, 0, 0}
@@ -192,7 +194,7 @@ extern "C" {
#define ModuleConfig_CannedMessageConfig_init_default {0, 0, 0, 0, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, _ModuleConfig_CannedMessageConfig_InputEventChar_MIN, 0, 0, "", 0}
#define ModuleConfig_init_zero {0, {ModuleConfig_MQTTConfig_init_zero}}
#define ModuleConfig_MQTTConfig_init_zero {0, "", "", "", 0, 0}
#define ModuleConfig_AudioConfig_init_zero {0, 0, 0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN}
#define ModuleConfig_AudioConfig_init_zero {0, 0, _ModuleConfig_AudioConfig_Audio_Baud_MIN, 0, 0, 0, 0}
#define ModuleConfig_SerialConfig_init_zero {0, 0, 0, 0, _ModuleConfig_SerialConfig_Serial_Baud_MIN, 0, _ModuleConfig_SerialConfig_Serial_Mode_MIN}
#define ModuleConfig_ExternalNotificationConfig_init_zero {0, 0, 0, 0, 0, 0, 0}
#define ModuleConfig_StoreForwardConfig_init_zero {0, 0, 0, 0, 0}
@@ -202,10 +204,12 @@ extern "C" {
/* Field tags (for use in manual encoding/decoding) */
#define ModuleConfig_AudioConfig_codec2_enabled_tag 1
#define ModuleConfig_AudioConfig_mic_chan_tag 2
#define ModuleConfig_AudioConfig_amp_pin_tag 3
#define ModuleConfig_AudioConfig_ptt_pin_tag 4
#define ModuleConfig_AudioConfig_bitrate_tag 5
#define ModuleConfig_AudioConfig_ptt_pin_tag 2
#define ModuleConfig_AudioConfig_bitrate_tag 3
#define ModuleConfig_AudioConfig_i2s_ws_tag 4
#define ModuleConfig_AudioConfig_i2s_sd_tag 5
#define ModuleConfig_AudioConfig_i2s_din_tag 6
#define ModuleConfig_AudioConfig_i2s_sck_tag 7
#define ModuleConfig_CannedMessageConfig_rotary1_enabled_tag 1
#define ModuleConfig_CannedMessageConfig_inputbroker_pin_a_tag 2
#define ModuleConfig_CannedMessageConfig_inputbroker_pin_b_tag 3
@@ -292,10 +296,12 @@ X(a, STATIC, SINGULAR, BOOL, json_enabled, 6)
#define ModuleConfig_AudioConfig_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, BOOL, codec2_enabled, 1) \
X(a, STATIC, SINGULAR, UINT32, mic_chan, 2) \
X(a, STATIC, SINGULAR, UINT32, amp_pin, 3) \
X(a, STATIC, SINGULAR, UINT32, ptt_pin, 4) \
X(a, STATIC, SINGULAR, UENUM, bitrate, 5)
X(a, STATIC, SINGULAR, UINT32, ptt_pin, 2) \
X(a, STATIC, SINGULAR, UENUM, bitrate, 3) \
X(a, STATIC, SINGULAR, UINT32, i2s_ws, 4) \
X(a, STATIC, SINGULAR, UINT32, i2s_sd, 5) \
X(a, STATIC, SINGULAR, UINT32, i2s_din, 6) \
X(a, STATIC, SINGULAR, UINT32, i2s_sck, 7)
#define ModuleConfig_AudioConfig_CALLBACK NULL
#define ModuleConfig_AudioConfig_DEFAULT NULL
@@ -383,7 +389,7 @@ extern const pb_msgdesc_t ModuleConfig_CannedMessageConfig_msg;
#define ModuleConfig_CannedMessageConfig_fields &ModuleConfig_CannedMessageConfig_msg
/* Maximum encoded size of messages (where known) */
#define ModuleConfig_AudioConfig_size 22
#define ModuleConfig_AudioConfig_size 19
#define ModuleConfig_CannedMessageConfig_size 49
#define ModuleConfig_ExternalNotificationConfig_size 22
#define ModuleConfig_MQTTConfig_size 169

View File

@@ -82,6 +82,9 @@ typedef enum _PortNum {
Maintained by GitHub user GUVWAF.
Project files at https://github.com/GUVWAF/Meshtasticator */
PortNum_SIMULATOR_APP = 69,
/* Provides a traceroute functionality to show the route a packet towards
a certain destination would take on the mesh. */
PortNum_TRACEROUTE_APP = 70,
/* Private applications should use portnums >= 256.
To simplify initial development and testing you can use "PRIVATE_APP"
in your code without needing to rebuild protobuf files (via [regen-protos.sh](https://github.com/meshtastic/firmware/blob/master/bin/regen-protos.sh)) */

View File

@@ -214,7 +214,6 @@ int32_t SerialModule::runOnce()
MeshPacket *SerialModuleRadio::allocReply()
{
auto reply = allocDataPacket(); // Allocate a packet for sending
return reply;
@@ -266,7 +265,12 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_DEFAULT ||
moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_SIMPLE) {
Serial2.printf("%s", p.payload.bytes);
} else if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_TEXTMSG) {
NodeInfo *node = nodeDB.getNode(getFrom(&mp));
String sender = (node && node->has_user) ? node->user.short_name : "???";
Serial2.println();
Serial2.printf("%s: %s", sender, p.payload.bytes);
Serial2.println();
} else if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_PROTO) {
// TODO this needs to be implemented
} else if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_NMEA) {

View File

@@ -61,7 +61,27 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length)
} else {
DEBUG_MSG("JSON Ignoring downlink message we originally sent.\n");
}
} else if ((json.find("sender") != json.end()) && (json.find("payload") != json.end()) && (json.find("type") != json.end()) && json["type"]->IsString() && (json["type"]->AsString().compare("sendposition") == 0)) {
//invent the "sendposition" type for a valid envelope
if (json["payload"]->IsObject() && json["type"]->IsString() && (json["sender"]->AsString().compare(owner.id) != 0)) {
JSONObject posit;
posit=json["payload"]->AsObject(); //get nested JSON Position
Position pos =Position_init_default;
pos.latitude_i=posit["latitude_i"]->AsNumber();
pos.longitude_i=posit["longitude_i"]->AsNumber();
pos.altitude=posit["altitude"]->AsNumber();
pos.time=posit["time"]->AsNumber();
// construct protobuf data packet using POSITION, send it to the mesh
MeshPacket *p = router->allocForSending();
p->decoded.portnum = PortNum_POSITION_APP;
p->decoded.payload.size=pb_encode_to_bytes(p->decoded.payload.bytes,sizeof(p->decoded.payload.bytes),Position_fields, &pos); //make the Data protobuf from position
service.sendToMesh(p, RX_SRC_LOCAL);
} else {
DEBUG_MSG("JSON Ignoring downlink message we originally sent.\n");
}
} else{
DEBUG_MSG("JSON Received payload on MQTT but not a valid envelope\n");
}
} else {
@@ -346,11 +366,11 @@ std::string MQTT::downstreamPacketToJson(MeshPacket *mp)
memset(&scratch, 0, sizeof(scratch));
if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &Position_msg, &scratch)) {
decoded = &scratch;
msgPayload["time"] = new JSONValue((int)decoded->time);
msgPayload["timestamp"] = new JSONValue((int)decoded->timestamp);
if((int)decoded->time){msgPayload["time"] = new JSONValue((int)decoded->time);}
if ((int)decoded->timestamp){msgPayload["timestamp"] = new JSONValue((int)decoded->timestamp);}
msgPayload["latitude_i"] = new JSONValue((int)decoded->latitude_i);
msgPayload["longitude_i"] = new JSONValue((int)decoded->longitude_i);
msgPayload["altitude"] = new JSONValue((int)decoded->altitude);
if((int)decoded->altitude){msgPayload["altitude"] = new JSONValue((int)decoded->altitude);}
jsonObj["payload"] = new JSONValue(msgPayload);
} else {
DEBUG_MSG("Error decoding protobuf for position message!\n");

View File

@@ -1,4 +1,4 @@
[VERSION]
major = 2
minor = 0
build = 6
build = 7