mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-19 11:43:27 +00:00
Merge branch 'meshtastic:master' into StoreAndForward
This commit is contained in:
commit
2ace1f48b8
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -50,7 +50,8 @@
|
|||||||
"cassert": "cpp",
|
"cassert": "cpp",
|
||||||
"iterator": "cpp",
|
"iterator": "cpp",
|
||||||
"shared_mutex": "cpp",
|
"shared_mutex": "cpp",
|
||||||
"iostream": "cpp"
|
"iostream": "cpp",
|
||||||
|
"esp_nimble_hci.h": "c"
|
||||||
},
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"Blox",
|
"Blox",
|
||||||
|
@ -9,7 +9,7 @@ BOARDS_ESP32="tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v2.0 helt
|
|||||||
#BOARDS_ESP32=tbeam
|
#BOARDS_ESP32=tbeam
|
||||||
|
|
||||||
# FIXME note nrf52840dk build is for some reason only generating a BIN file but not a HEX file nrf52840dk-geeksville is fine
|
# FIXME note nrf52840dk build is for some reason only generating a BIN file but not a HEX file nrf52840dk-geeksville is fine
|
||||||
BOARDS_NRF52="rak4631 t-echo"
|
BOARDS_NRF52="rak4631_5005 rak4631_19003 t-echo"
|
||||||
#BOARDS_NRF52=""
|
#BOARDS_NRF52=""
|
||||||
|
|
||||||
OUTDIR=release/latest
|
OUTDIR=release/latest
|
||||||
|
@ -113,9 +113,13 @@ lib_deps =
|
|||||||
adafruit/Adafruit Unified Sensor@^1.1.4
|
adafruit/Adafruit Unified Sensor@^1.1.4
|
||||||
paulstoffregen/OneWire@^2.3.5
|
paulstoffregen/OneWire@^2.3.5
|
||||||
robtillaart/DS18B20@^0.1.11
|
robtillaart/DS18B20@^0.1.11
|
||||||
|
h2zero/NimBLE-Arduino@1.3.1
|
||||||
# Hmm - this doesn't work yet
|
# Hmm - this doesn't work yet
|
||||||
# board_build.ldscript = linker/esp32.extram.bss.ld
|
# board_build.ldscript = linker/esp32.extram.bss.ld
|
||||||
lib_ignore = segger_rtt
|
lib_ignore =
|
||||||
|
segger_rtt
|
||||||
|
ESP32 BLE Arduino
|
||||||
|
|
||||||
platform_packages =
|
platform_packages =
|
||||||
framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#4cde0f5d412d2695184f32e8a47e9bea57b45276
|
framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#4cde0f5d412d2695184f32e8a47e9bea57b45276
|
||||||
|
|
||||||
@ -325,12 +329,21 @@ monitor_speed = 115200
|
|||||||
# board_build.ldscript = linker/nrf52840_s140_sim832.ld
|
# board_build.ldscript = linker/nrf52840_s140_sim832.ld
|
||||||
|
|
||||||
; The very slick RAK wireless RAK 4631 / 4630 board
|
; The very slick RAK wireless RAK 4631 / 4630 board
|
||||||
[env:rak4631]
|
[env:rak4631_5005]
|
||||||
extends = nrf52840_base
|
extends = nrf52840_base
|
||||||
board = wiscore_rak4631
|
board = wiscore_rak4631
|
||||||
# add our variants files to the include and src paths
|
# add our variants files to the include and src paths
|
||||||
# define build flags for the TFT_eSPI library
|
# define build flags for the TFT_eSPI library
|
||||||
build_flags = ${nrf52840_base.build_flags} -Ivariants/WisCore_RAK4631_Board
|
build_flags = ${nrf52840_base.build_flags} -Ivariants/WisCore_RAK4631_Board -D RAK_BASE_5005
|
||||||
|
src_filter = ${nrf52_base.src_filter} +<../variants/WisCore_RAK4631_Board>
|
||||||
|
debug_tool = jlink
|
||||||
|
|
||||||
|
[env:rak4631_19003]
|
||||||
|
extends = nrf52840_base
|
||||||
|
board = wiscore_rak4631
|
||||||
|
# add our variants files to the include and src paths
|
||||||
|
# define build flags for the TFT_eSPI library
|
||||||
|
build_flags = ${nrf52840_base.build_flags} -Ivariants/WisCore_RAK4631_Board -D RAK_BASE_19003
|
||||||
src_filter = ${nrf52_base.src_filter} +<../variants/WisCore_RAK4631_Board>
|
src_filter = ${nrf52_base.src_filter} +<../variants/WisCore_RAK4631_Board>
|
||||||
debug_tool = jlink
|
debug_tool = jlink
|
||||||
; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm)
|
; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm)
|
||||||
|
2
proto
2
proto
@ -1 +1 @@
|
|||||||
Subproject commit 10e6857b1bd4a03ec16ec5cbaadf4f28293ab9a5
|
Subproject commit c52c8ef99ead88a5edb73891b33247c54d37cb28
|
@ -243,6 +243,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
//#define GPS_TX_PIN 12 // not connected
|
//#define GPS_TX_PIN 12 // not connected
|
||||||
|
|
||||||
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
|
#define BUTTON_PIN 39 // The middle button GPIO on the T-Beam
|
||||||
|
#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Plugin (#975).
|
||||||
|
|
||||||
#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module
|
#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module
|
||||||
#define LORA_RESET 23 // RST for SX1276, and for SX1262/SX1268
|
#define LORA_RESET 23 // RST for SX1276, and for SX1262/SX1268
|
||||||
@ -330,8 +331,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define GPS_RX_PIN 36
|
#define GPS_RX_PIN 36
|
||||||
#define GPS_TX_PIN 37
|
#define GPS_TX_PIN 37
|
||||||
|
|
||||||
#define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
|
||||||
|
|
||||||
#define I2C_SDA 4 // I2C pins for this board
|
#define I2C_SDA 4 // I2C pins for this board
|
||||||
#define I2C_SCL 15
|
#define I2C_SCL 15
|
||||||
|
|
||||||
|
@ -36,9 +36,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "gps/GeoCoord.h"
|
#include "gps/GeoCoord.h"
|
||||||
|
#include "sleep.h"
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
#include "mesh/http/WiFiAPClient.h"
|
#include "mesh/http/WiFiAPClient.h"
|
||||||
|
#include "esp_task_wdt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace meshtastic; /** @todo remove */
|
using namespace meshtastic; /** @todo remove */
|
||||||
@ -154,8 +156,17 @@ static void drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawString(64 + x, y, "Creating SSL certificate");
|
display->drawString(64 + x, y, "Creating SSL certificate");
|
||||||
|
|
||||||
|
#ifndef NO_ESP32
|
||||||
|
yield();
|
||||||
|
esp_task_wdt_reset();
|
||||||
|
#endif
|
||||||
|
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait...");
|
if ((millis() / 1000) % 2) {
|
||||||
|
display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . .");
|
||||||
|
} else {
|
||||||
|
display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAS_EINK
|
#ifdef HAS_EINK
|
||||||
@ -215,7 +226,11 @@ static void drawFrameFirmware(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||||||
display->drawString(64 + x, y, "Updating");
|
display->drawString(64 + x, y, "Updating");
|
||||||
|
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait...");
|
if ((millis() / 1000) % 2) {
|
||||||
|
display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . .");
|
||||||
|
} else {
|
||||||
|
display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . ");
|
||||||
|
}
|
||||||
|
|
||||||
// display->setFont(FONT_LARGE);
|
// display->setFont(FONT_LARGE);
|
||||||
// display->drawString(64 + x, 26 + y, btPIN);
|
// display->drawString(64 + x, 26 + y, btPIN);
|
||||||
@ -413,7 +428,10 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const
|
|||||||
auto gpsFormat = radioConfig.preferences.gps_format;
|
auto gpsFormat = radioConfig.preferences.gps_format;
|
||||||
String displayLine = "";
|
String displayLine = "";
|
||||||
|
|
||||||
if (!gps->getIsConnected() && !radioConfig.preferences.fixed_position) {
|
if (radioConfig.preferences.fixed_position) {
|
||||||
|
displayLine = "Fixed GPS";
|
||||||
|
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
||||||
|
} else if (!gps->getIsConnected() && !radioConfig.preferences.fixed_position) {
|
||||||
displayLine = "No GPS Module";
|
displayLine = "No GPS Module";
|
||||||
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
||||||
} else if (!gps->getHasLock() && !radioConfig.preferences.fixed_position) {
|
} else if (!gps->getHasLock() && !radioConfig.preferences.fixed_position) {
|
||||||
@ -688,6 +706,7 @@ void _screen_header()
|
|||||||
|
|
||||||
Screen::Screen(uint8_t address, int sda, int scl) : OSThread("Screen"), cmdQueue(32), dispdev(address, sda, scl), ui(&dispdev)
|
Screen::Screen(uint8_t address, int sda, int scl) : OSThread("Screen"), cmdQueue(32), dispdev(address, sda, scl), ui(&dispdev)
|
||||||
{
|
{
|
||||||
|
address_found = address;
|
||||||
cmdQueue.setReader(this);
|
cmdQueue.setReader(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,6 +894,11 @@ int32_t Screen::runOnce()
|
|||||||
// oldFrameState = ui.getUiState()->frameState;
|
// oldFrameState = ui.getUiState()->frameState;
|
||||||
DEBUG_MSG("Setting idle framerate\n");
|
DEBUG_MSG("Setting idle framerate\n");
|
||||||
targetFramerate = IDLE_FRAMERATE;
|
targetFramerate = IDLE_FRAMERATE;
|
||||||
|
|
||||||
|
#ifndef NO_ESP32
|
||||||
|
setCPUFast(false); // Turn up the CPU to improve screen animations
|
||||||
|
#endif
|
||||||
|
|
||||||
ui.setTargetFPS(targetFramerate);
|
ui.setTargetFPS(targetFramerate);
|
||||||
forceDisplay();
|
forceDisplay();
|
||||||
}
|
}
|
||||||
@ -920,10 +944,12 @@ void Screen::drawDebugInfoWiFiTrampoline(OLEDDisplay *display, OLEDDisplayUiStat
|
|||||||
* it is expected that this will be used during the boot phase */
|
* it is expected that this will be used during the boot phase */
|
||||||
void Screen::setSSLFrames()
|
void Screen::setSSLFrames()
|
||||||
{
|
{
|
||||||
DEBUG_MSG("showing SSL frames\n");
|
if (address_found) {
|
||||||
static FrameCallback sslFrames[] = {drawSSLScreen};
|
// DEBUG_MSG("showing SSL frames\n");
|
||||||
ui.setFrames(sslFrames, 1);
|
static FrameCallback sslFrames[] = {drawSSLScreen};
|
||||||
ui.update();
|
ui.setFrames(sslFrames, 1);
|
||||||
|
ui.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore our regular frame list
|
// restore our regular frame list
|
||||||
@ -1074,6 +1100,11 @@ void Screen::setFastFramerate()
|
|||||||
|
|
||||||
// We are about to start a transition so speed up fps
|
// We are about to start a transition so speed up fps
|
||||||
targetFramerate = SCREEN_TRANSITION_FRAMERATE;
|
targetFramerate = SCREEN_TRANSITION_FRAMERATE;
|
||||||
|
|
||||||
|
#ifndef NO_ESP32
|
||||||
|
setCPUFast(true); // Turn up the CPU to improve screen animations
|
||||||
|
#endif
|
||||||
|
|
||||||
ui.setTargetFPS(targetFramerate);
|
ui.setTargetFPS(targetFramerate);
|
||||||
setInterval(0); // redraw ASAP
|
setInterval(0); // redraw ASAP
|
||||||
runASAP = true;
|
runASAP = true;
|
||||||
@ -1299,7 +1330,24 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||||||
display->drawString(x, y, String("USB"));
|
display->drawString(x, y, String("USB"));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mode = "Mode " + String(channels.getPrimary().modem_config);
|
auto mode = "";
|
||||||
|
|
||||||
|
if (channels.getPrimary().modem_config == 0) {
|
||||||
|
mode = "ShrtSlow";
|
||||||
|
} else if (channels.getPrimary().modem_config == 1) {
|
||||||
|
mode = "ShrtFast";
|
||||||
|
} else if (channels.getPrimary().modem_config == 2) {
|
||||||
|
mode = "LngFast";
|
||||||
|
} else if (channels.getPrimary().modem_config == 3) {
|
||||||
|
mode = "LngSlow";
|
||||||
|
} else if (channels.getPrimary().modem_config == 4) {
|
||||||
|
mode = "MedSlow";
|
||||||
|
} else if (channels.getPrimary().modem_config == 5) {
|
||||||
|
mode = "MedFast";
|
||||||
|
} else {
|
||||||
|
mode = "Custom";
|
||||||
|
}
|
||||||
|
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(mode), y, mode);
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(mode), y, mode);
|
||||||
|
|
||||||
// Line 2
|
// Line 2
|
||||||
|
@ -97,6 +97,8 @@ class Screen : public concurrency::OSThread
|
|||||||
Screen(const Screen &) = delete;
|
Screen(const Screen &) = delete;
|
||||||
Screen &operator=(const Screen &) = delete;
|
Screen &operator=(const Screen &) = delete;
|
||||||
|
|
||||||
|
uint8_t address_found;
|
||||||
|
|
||||||
/// Initializes the UI, turns on the display, starts showing boot screen.
|
/// Initializes the UI, turns on the display, starts showing boot screen.
|
||||||
//
|
//
|
||||||
// Not thread safe - must be called before any other methods are called.
|
// Not thread safe - must be called before any other methods are called.
|
||||||
|
@ -245,6 +245,10 @@ void NodeDB::init()
|
|||||||
preferences.end();
|
preferences.end();
|
||||||
DEBUG_MSG("Number of Device Reboots: %d\n", myNodeInfo.reboot_count);
|
DEBUG_MSG("Number of Device Reboots: %d\n", myNodeInfo.reboot_count);
|
||||||
|
|
||||||
|
/* The ESP32 has a wifi radio. This will need to be modified at some point so
|
||||||
|
* the test isn't so simplistic.
|
||||||
|
*/
|
||||||
|
myNodeInfo.has_wifi = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
resetRadioConfig(); // If bogus settings got saved, then fix them
|
resetRadioConfig(); // If bogus settings got saved, then fix them
|
||||||
@ -429,7 +433,7 @@ uint32_t sinceLastSeen(const NodeInfo *n)
|
|||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NUM_ONLINE_SECS (60 * 2) // 2 hrs to consider someone offline
|
#define NUM_ONLINE_SECS (60 & 60 * 2) // 2 hrs to consider someone offline
|
||||||
|
|
||||||
size_t NodeDB::getNumOnlineNodes()
|
size_t NodeDB::getNumOnlineNodes()
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,13 @@ ErrorCode ReliableRouter::send(MeshPacket *p)
|
|||||||
// 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. But asking for hop_limit 0 in that context means the client app has no preference on hop counts
|
// 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.
|
// 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 = HOP_RELIABLE;
|
if (radioConfig.preferences.hop_limit && radioConfig.preferences.hop_limit <= HOP_MAX) {
|
||||||
|
p->hop_limit = (radioConfig.preferences.hop_limit >= HOP_MAX) ? HOP_MAX : radioConfig.preferences.hop_limit;
|
||||||
|
} else {
|
||||||
|
p->hop_limit = HOP_RELIABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto copy = packetPool.allocCopy(*p);
|
auto copy = packetPool.allocCopy(*p);
|
||||||
startRetransmission(copy);
|
startRetransmission(copy);
|
||||||
|
@ -115,7 +115,11 @@ MeshPacket *Router::allocForSending()
|
|||||||
p->which_payloadVariant = MeshPacket_decoded_tag; // Assume payload is decoded at start.
|
p->which_payloadVariant = MeshPacket_decoded_tag; // Assume payload is decoded at start.
|
||||||
p->from = nodeDB.getNodeNum();
|
p->from = nodeDB.getNodeNum();
|
||||||
p->to = NODENUM_BROADCAST;
|
p->to = NODENUM_BROADCAST;
|
||||||
p->hop_limit = HOP_RELIABLE;
|
if (radioConfig.preferences.hop_limit && radioConfig.preferences.hop_limit <= HOP_MAX) {
|
||||||
|
p->hop_limit = (radioConfig.preferences.hop_limit >= HOP_MAX) ? HOP_MAX : radioConfig.preferences.hop_limit;
|
||||||
|
} else {
|
||||||
|
p->hop_limit = HOP_RELIABLE;
|
||||||
|
}
|
||||||
p->id = generatePacketId();
|
p->id = generatePacketId();
|
||||||
p->rx_time =
|
p->rx_time =
|
||||||
getValidTime(RTCQualityFromNet); // Just in case we process the packet locally - make sure it has a valid timestamp
|
getValidTime(RTCQualityFromNet); // Just in case we process the packet locally - make sure it has a valid timestamp
|
||||||
|
@ -86,7 +86,7 @@ extern const pb_msgdesc_t AdminMessage_msg;
|
|||||||
#define AdminMessage_fields &AdminMessage_msg
|
#define AdminMessage_fields &AdminMessage_msg
|
||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define AdminMessage_size 454
|
#define AdminMessage_size 461
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@ -152,6 +152,7 @@ typedef struct _RadioConfig_UserPreferences {
|
|||||||
bool is_always_powered;
|
bool is_always_powered;
|
||||||
uint32_t auto_screen_carousel_secs;
|
uint32_t auto_screen_carousel_secs;
|
||||||
uint32_t on_battery_shutdown_after_secs;
|
uint32_t on_battery_shutdown_after_secs;
|
||||||
|
uint32_t hop_limit;
|
||||||
} RadioConfig_UserPreferences;
|
} RadioConfig_UserPreferences;
|
||||||
|
|
||||||
typedef struct _RadioConfig {
|
typedef struct _RadioConfig {
|
||||||
@ -196,9 +197,9 @@ extern "C" {
|
|||||||
|
|
||||||
/* Initializer values for message structs */
|
/* Initializer values for message structs */
|
||||||
#define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default}
|
#define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default}
|
||||||
#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0}
|
#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
#define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero}
|
#define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero}
|
||||||
#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0}
|
#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _LocationSharing_MIN, _GpsOperation_MIN, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
|
|
||||||
/* Field tags (for use in manual encoding/decoding) */
|
/* Field tags (for use in manual encoding/decoding) */
|
||||||
#define RadioConfig_UserPreferences_position_broadcast_secs_tag 1
|
#define RadioConfig_UserPreferences_position_broadcast_secs_tag 1
|
||||||
@ -266,6 +267,7 @@ extern "C" {
|
|||||||
#define RadioConfig_UserPreferences_is_always_powered_tag 151
|
#define RadioConfig_UserPreferences_is_always_powered_tag 151
|
||||||
#define RadioConfig_UserPreferences_auto_screen_carousel_secs_tag 152
|
#define RadioConfig_UserPreferences_auto_screen_carousel_secs_tag 152
|
||||||
#define RadioConfig_UserPreferences_on_battery_shutdown_after_secs_tag 153
|
#define RadioConfig_UserPreferences_on_battery_shutdown_after_secs_tag 153
|
||||||
|
#define RadioConfig_UserPreferences_hop_limit_tag 154
|
||||||
#define RadioConfig_preferences_tag 1
|
#define RadioConfig_preferences_tag 1
|
||||||
|
|
||||||
/* Struct field encoding specification for nanopb */
|
/* Struct field encoding specification for nanopb */
|
||||||
@ -340,7 +342,8 @@ X(a, STATIC, SINGULAR, BOOL, store_forward_plugin_heartbeat, 149) \
|
|||||||
X(a, STATIC, SINGULAR, UINT32, position_flags, 150) \
|
X(a, STATIC, SINGULAR, UINT32, position_flags, 150) \
|
||||||
X(a, STATIC, SINGULAR, BOOL, is_always_powered, 151) \
|
X(a, STATIC, SINGULAR, BOOL, is_always_powered, 151) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 152) \
|
X(a, STATIC, SINGULAR, UINT32, auto_screen_carousel_secs, 152) \
|
||||||
X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 153)
|
X(a, STATIC, SINGULAR, UINT32, on_battery_shutdown_after_secs, 153) \
|
||||||
|
X(a, STATIC, SINGULAR, UINT32, hop_limit, 154)
|
||||||
#define RadioConfig_UserPreferences_CALLBACK NULL
|
#define RadioConfig_UserPreferences_CALLBACK NULL
|
||||||
#define RadioConfig_UserPreferences_DEFAULT NULL
|
#define RadioConfig_UserPreferences_DEFAULT NULL
|
||||||
|
|
||||||
@ -352,8 +355,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg;
|
|||||||
#define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg
|
#define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg
|
||||||
|
|
||||||
/* Maximum encoded size of messages (where known) */
|
/* Maximum encoded size of messages (where known) */
|
||||||
#define RadioConfig_size 451
|
#define RadioConfig_size 458
|
||||||
#define RadioConfig_UserPreferences_size 448
|
#define RadioConfig_UserPreferences_size 455
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
#include <HTTPBodyParser.hpp>
|
#include <HTTPBodyParser.hpp>
|
||||||
#include <HTTPMultipartBodyParser.hpp>
|
#include <HTTPMultipartBodyParser.hpp>
|
||||||
#include <HTTPURLEncodedBodyParser.hpp>
|
#include <HTTPURLEncodedBodyParser.hpp>
|
||||||
|
#include "sleep.h"
|
||||||
|
#include "graphics/Screen.h"
|
||||||
|
|
||||||
|
|
||||||
#include <WebServer.h>
|
#include <WebServer.h>
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
@ -78,13 +81,15 @@ static void taskCreateCert(void *parameter)
|
|||||||
{
|
{
|
||||||
prefs.begin("MeshtasticHTTPS", false);
|
prefs.begin("MeshtasticHTTPS", false);
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
// Delete the saved certs (used in debugging)
|
// Delete the saved certs (used in debugging)
|
||||||
if (0) {
|
DEBUG_MSG("Deleting any saved SSL keys ...\n");
|
||||||
DEBUG_MSG("Deleting any saved SSL keys ...\n");
|
// prefs.clear();
|
||||||
// prefs.clear();
|
prefs.remove("PK");
|
||||||
prefs.remove("PK");
|
prefs.remove("cert");
|
||||||
prefs.remove("cert");
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG_MSG("Checking if we have a previously saved SSL Certificate.\n");
|
DEBUG_MSG("Checking if we have a previously saved SSL Certificate.\n");
|
||||||
|
|
||||||
@ -103,16 +108,12 @@ static void taskCreateCert(void *parameter)
|
|||||||
cert = new SSLCert(certBuffer, certLen, pkBuffer, pkLen);
|
cert = new SSLCert(certBuffer, certLen, pkBuffer, pkLen);
|
||||||
|
|
||||||
DEBUG_MSG("Retrieved Private Key: %d Bytes\n", cert->getPKLength());
|
DEBUG_MSG("Retrieved Private Key: %d Bytes\n", cert->getPKLength());
|
||||||
// DEBUG_MSG("Retrieved Private Key: " + String(cert->getPKLength()) + " Bytes");
|
|
||||||
// for (int i = 0; i < cert->getPKLength(); i++)
|
|
||||||
// Serial.print(cert->getPKData()[i], HEX);
|
|
||||||
// Serial.println();
|
|
||||||
|
|
||||||
DEBUG_MSG("Retrieved Certificate: %d Bytes\n", cert->getCertLength());
|
DEBUG_MSG("Retrieved Certificate: %d Bytes\n", cert->getCertLength());
|
||||||
// for (int i = 0; i < cert->getCertLength(); i++)
|
|
||||||
// Serial.print(cert->getCertData()[i], HEX);
|
|
||||||
// Serial.println();
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
setCPUFast(true);
|
||||||
|
|
||||||
DEBUG_MSG("Creating the certificate. This may take a while. Please wait...\n");
|
DEBUG_MSG("Creating the certificate. This may take a while. Please wait...\n");
|
||||||
yield();
|
yield();
|
||||||
cert = new SSLCert();
|
cert = new SSLCert();
|
||||||
@ -144,6 +145,9 @@ static void taskCreateCert(void *parameter)
|
|||||||
prefs.putBytes("PK", (uint8_t *)cert->getPKData(), cert->getPKLength());
|
prefs.putBytes("PK", (uint8_t *)cert->getPKData(), cert->getPKLength());
|
||||||
prefs.putBytes("cert", (uint8_t *)cert->getCertData(), cert->getCertLength());
|
prefs.putBytes("cert", (uint8_t *)cert->getCertData(), cert->getCertLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setCPUFast(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isCertReady = true;
|
isCertReady = true;
|
||||||
@ -154,6 +158,7 @@ static void taskCreateCert(void *parameter)
|
|||||||
|
|
||||||
void createSSLCert()
|
void createSSLCert()
|
||||||
{
|
{
|
||||||
|
bool runLoop = false;
|
||||||
if (isWifiAvailable() && !isCertReady) {
|
if (isWifiAvailable() && !isCertReady) {
|
||||||
|
|
||||||
// Create a new process just to handle creating the cert.
|
// Create a new process just to handle creating the cert.
|
||||||
@ -161,21 +166,28 @@ void createSSLCert()
|
|||||||
// jm@casler.org (Oct 2020)
|
// jm@casler.org (Oct 2020)
|
||||||
xTaskCreate(taskCreateCert, /* Task function. */
|
xTaskCreate(taskCreateCert, /* Task function. */
|
||||||
"createCert", /* String with name of task. */
|
"createCert", /* String with name of task. */
|
||||||
16384, /* Stack size in bytes. */
|
//16384, /* Stack size in bytes. */
|
||||||
|
8192, /* Stack size in bytes. */
|
||||||
NULL, /* Parameter passed as input of the task */
|
NULL, /* Parameter passed as input of the task */
|
||||||
16, /* Priority of the task. */
|
16, /* Priority of the task. */
|
||||||
NULL); /* Task handle. */
|
NULL); /* Task handle. */
|
||||||
|
|
||||||
DEBUG_MSG("Waiting for SSL Cert to be generated.\n");
|
DEBUG_MSG("Waiting for SSL Cert to be generated.\n");
|
||||||
int seconds = 0;
|
|
||||||
while (!isCertReady) {
|
while (!isCertReady) {
|
||||||
DEBUG_MSG(".");
|
if ((millis() / 500) % 2) {
|
||||||
delay(1000);
|
if (runLoop) {
|
||||||
yield();
|
DEBUG_MSG(".");
|
||||||
esp_task_wdt_reset();
|
|
||||||
seconds++;
|
yield();
|
||||||
if ((seconds == 3) && screen) {
|
esp_task_wdt_reset();
|
||||||
screen->setSSLFrames();
|
|
||||||
|
if (millis() / 1000 >= 3) {
|
||||||
|
screen->setSSLFrames();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
runLoop = false;
|
||||||
|
} else {
|
||||||
|
runLoop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG_MSG("SSL Cert Ready!\n");
|
DEBUG_MSG("SSL Cert Ready!\n");
|
||||||
@ -199,40 +211,6 @@ void initWebServer()
|
|||||||
{
|
{
|
||||||
DEBUG_MSG("Initializing Web Server ...\n");
|
DEBUG_MSG("Initializing Web Server ...\n");
|
||||||
|
|
||||||
#if 0
|
|
||||||
// this seems to be a copypaste dup of taskCreateCert
|
|
||||||
prefs.begin("MeshtasticHTTPS", false);
|
|
||||||
|
|
||||||
size_t pkLen = prefs.getBytesLength("PK");
|
|
||||||
size_t certLen = prefs.getBytesLength("cert");
|
|
||||||
|
|
||||||
DEBUG_MSG("Checking if we have a previously saved SSL Certificate.\n");
|
|
||||||
|
|
||||||
if (pkLen && certLen) {
|
|
||||||
|
|
||||||
uint8_t *pkBuffer = new uint8_t[pkLen];
|
|
||||||
prefs.getBytes("PK", pkBuffer, pkLen);
|
|
||||||
|
|
||||||
uint8_t *certBuffer = new uint8_t[certLen];
|
|
||||||
prefs.getBytes("cert", certBuffer, certLen);
|
|
||||||
|
|
||||||
cert = new SSLCert(certBuffer, certLen, pkBuffer, pkLen);
|
|
||||||
|
|
||||||
DEBUG_MSG("Retrieved Private Key: %d Bytes\n", cert->getPKLength());
|
|
||||||
// DEBUG_MSG("Retrieved Private Key: " + String(cert->getPKLength()) + " Bytes");
|
|
||||||
// for (int i = 0; i < cert->getPKLength(); i++)
|
|
||||||
// Serial.print(cert->getPKData()[i], HEX);
|
|
||||||
// Serial.println();
|
|
||||||
|
|
||||||
DEBUG_MSG("Retrieved Certificate: %d Bytes\n", cert->getCertLength());
|
|
||||||
// for (int i = 0; i < cert->getCertLength(); i++)
|
|
||||||
// Serial.print(cert->getCertData()[i], HEX);
|
|
||||||
// Serial.println();
|
|
||||||
} else {
|
|
||||||
DEBUG_MSG("Web Server started without SSL keys! How did this happen?\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// We can now use the new certificate to setup our server as usual.
|
// We can now use the new certificate to setup our server as usual.
|
||||||
secureServer = new HTTPSServer(cert);
|
secureServer = new HTTPSServer(cert);
|
||||||
insecureServer = new HTTPServer();
|
insecureServer = new HTTPServer();
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "services/gap/ble_svc_gap.h"
|
#include "services/gap/ble_svc_gap.h"
|
||||||
#include "services/gatt/ble_svc_gatt.h"
|
#include "services/gatt/ble_svc_gatt.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
#include <Arduino.h>
|
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
/// We only allow one BLE connection at a time
|
/// We only allow one BLE connection at a time
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "nimble/BluetoothUtil.h"
|
#include "nimble/BluetoothUtil.h"
|
||||||
#include "nimble/NimbleDefs.h"
|
#include "nimble/NimbleDefs.h"
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
// This scratch buffer is used for various bluetooth reads/writes - but it is safe because only one bt operation can be in
|
// This scratch buffer is used for various bluetooth reads/writes - but it is safe because only one bt operation can be in
|
||||||
// proccess at once
|
// proccess at once
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "host/ble_uuid.h"
|
#include "host/ble_uuid.h"
|
||||||
#include "nimble/nimble_port.h"
|
#include "nimble/nimble_port.h"
|
||||||
#include "nimble/nimble_port_freertos.h"
|
#include "nimble/nimble_port_freertos.h"
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -148,14 +148,22 @@ int32_t PositionPlugin::runOnce()
|
|||||||
NodeInfo *node = service.refreshMyNodeInfo(); // should guarantee there is now a position
|
NodeInfo *node = service.refreshMyNodeInfo(); // should guarantee there is now a position
|
||||||
|
|
||||||
if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) {
|
if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) {
|
||||||
|
// The minimum distance to travel before we are able to send a new position packet.
|
||||||
|
const uint32_t distanceTravelMinimum = 30;
|
||||||
|
|
||||||
|
// The minimum time that would pass before we are able to send a new position packet.
|
||||||
|
const uint32_t timeTravelMinimum = 30;
|
||||||
|
|
||||||
|
// Determine the distance in meters between two points on the globe
|
||||||
float distance = GeoCoord::latLongToMeter(lastGpsLatitude * 1e-7, lastGpsLongitude * 1e-7,
|
float distance = GeoCoord::latLongToMeter(lastGpsLatitude * 1e-7, lastGpsLongitude * 1e-7,
|
||||||
node->position.latitude_i * 1e-7, node->position.longitude_i * 1e-7);
|
node->position.latitude_i * 1e-7, node->position.longitude_i * 1e-7);
|
||||||
|
|
||||||
// 2500 is a magic number. 50 is the minumum distance we want to travel before sending another position packet.
|
// Yes, this has a bunch of magic numbers. Sorry. This is to make the scale non-linear.
|
||||||
uint32_t distanceTravel = ((2500 / myNodeInfo.bitrate) >= 50) ? (2500 / myNodeInfo.bitrate) : 50;
|
const float distanceTravelMath = 1203 / (sqrt( pow(myNodeInfo.bitrate, 1.5) / 1.1 ) ) ;
|
||||||
|
uint32_t distanceTravel = (distanceTravelMath >= distanceTravelMinimum) ? distanceTravelMath : distanceTravelMinimum;
|
||||||
|
|
||||||
// 1500 is a magic number. 30 is the minumum interval between position packets
|
// Yes, this has a bunch of magic numbers. Sorry.
|
||||||
uint32_t timeTravel = ((1500 / myNodeInfo.bitrate) >= 30) ? (1500 / myNodeInfo.bitrate) : 30;
|
uint32_t timeTravel = ((1500 / myNodeInfo.bitrate) >= timeTravelMinimum) ? (1500 / myNodeInfo.bitrate) : timeTravelMinimum;
|
||||||
|
|
||||||
// If the distance traveled since the last update is greater than 100 meters
|
// If the distance traveled since the last update is greater than 100 meters
|
||||||
// and it's been at least 60 seconds since the last update
|
// and it's been at least 60 seconds since the last update
|
||||||
|
@ -58,11 +58,16 @@ extern "C" {
|
|||||||
/*
|
/*
|
||||||
* Buttons
|
* Buttons
|
||||||
*/
|
*/
|
||||||
#define PIN_BUTTON1 11
|
|
||||||
|
#ifdef RAK_BASE_5005
|
||||||
|
#define PIN_BUTTON1 9 // Pin for button on E-ink button module or IO expansion
|
||||||
|
#define BUTTON_NEED_PULLUP
|
||||||
|
#endif
|
||||||
#define PIN_BUTTON2 12
|
#define PIN_BUTTON2 12
|
||||||
#define PIN_BUTTON3 24
|
#define PIN_BUTTON3 24
|
||||||
#define PIN_BUTTON4 25
|
#define PIN_BUTTON4 25
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Analog pins
|
* Analog pins
|
||||||
*/
|
*/
|
||||||
@ -147,7 +152,7 @@ static const uint8_t SCK = PIN_SPI_SCK;
|
|||||||
SW1 <-> P0.01 (Arduino GPIO number 1)
|
SW1 <-> P0.01 (Arduino GPIO number 1)
|
||||||
A0 <-> P0.04/AIN2 (Arduino Analog A2
|
A0 <-> P0.04/AIN2 (Arduino Analog A2
|
||||||
A1 <-> P0.31/AIN7 (Arduino Analog A7
|
A1 <-> P0.31/AIN7 (Arduino Analog A7
|
||||||
SPI_CS <-> P0.26 (Arduino GPIO number 26)
|
SPI_CS <-> P0.26 (Arduino GPIO number 26)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// RAK4630 LoRa module
|
// RAK4630 LoRa module
|
||||||
@ -169,8 +174,11 @@ static const uint8_t SCK = PIN_SPI_SCK;
|
|||||||
// #define PIN_GPS_RESET (34)
|
// #define PIN_GPS_RESET (34)
|
||||||
#define PIN_GPS_EN (34)
|
#define PIN_GPS_EN (34)
|
||||||
#define PIN_GPS_PPS (17) // Pulse per second input from the GPS
|
#define PIN_GPS_PPS (17) // Pulse per second input from the GPS
|
||||||
|
|
||||||
|
#ifdef RAK_BASE_5005
|
||||||
#define GPS_RX_PIN PIN_SERIAL1_RX
|
#define GPS_RX_PIN PIN_SERIAL1_RX
|
||||||
#define GPS_TX_PIN PIN_SERIAL1_TX
|
#define GPS_TX_PIN PIN_SERIAL1_TX
|
||||||
|
#endif
|
||||||
|
|
||||||
// Battery
|
// Battery
|
||||||
// The battery sense is hooked to pin A0 (5)
|
// The battery sense is hooked to pin A0 (5)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[VERSION]
|
[VERSION]
|
||||||
major = 1
|
major = 1
|
||||||
minor = 2
|
minor = 2
|
||||||
build = 48
|
build = 49
|
||||||
|
Loading…
Reference in New Issue
Block a user