mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-01 03:39:18 +00:00
Merge branch 'master' into nrf52-Rollup
This commit is contained in:
commit
323f81eaba
@ -1 +1 @@
|
|||||||
Subproject commit 636212824a446194b73b02ca5c6c15cd61d3e007
|
Subproject commit 256f11954b7c8fcb9dc4481771c24559925bf32a
|
@ -57,7 +57,6 @@ namespace graphics
|
|||||||
|
|
||||||
// This means the *visible* area (sh1106 can address 132, but shows 128 for example)
|
// This means the *visible* area (sh1106 can address 132, but shows 128 for example)
|
||||||
#define IDLE_FRAMERATE 1 // in fps
|
#define IDLE_FRAMERATE 1 // in fps
|
||||||
#define COMPASS_DIAM 44
|
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
#define NUM_EXTRA_FRAMES 3 // text message and debug frame
|
#define NUM_EXTRA_FRAMES 3 // text message and debug frame
|
||||||
@ -98,7 +97,7 @@ static uint16_t displayWidth, displayHeight;
|
|||||||
#define SCREEN_WIDTH displayWidth
|
#define SCREEN_WIDTH displayWidth
|
||||||
#define SCREEN_HEIGHT displayHeight
|
#define SCREEN_HEIGHT displayHeight
|
||||||
|
|
||||||
#if defined(USE_EINK) || defined(ILI9341_DRIVER)
|
#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS)
|
||||||
// The screen is bigger so use bigger fonts
|
// The screen is bigger so use bigger fonts
|
||||||
#define FONT_SMALL ArialMT_Plain_16
|
#define FONT_SMALL ArialMT_Plain_16
|
||||||
#define FONT_MEDIUM ArialMT_Plain_24
|
#define FONT_MEDIUM ArialMT_Plain_24
|
||||||
@ -669,6 +668,26 @@ static bool hasPosition(NodeInfo *n)
|
|||||||
return n->has_position && (n->position.latitude_i != 0 || n->position.longitude_i != 0);
|
return n->has_position && (n->position.latitude_i != 0 || n->position.longitude_i != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint16_t getCompassDiam(OLEDDisplay *display)
|
||||||
|
{
|
||||||
|
uint16_t diam = 0;
|
||||||
|
// get the smaller of the 2 dimensions and subtract 20
|
||||||
|
if(display->getWidth() > display->getHeight()) {
|
||||||
|
diam = display->getHeight();
|
||||||
|
// if 2/3 of the other size would be smaller, use that
|
||||||
|
if (diam > (display->getWidth() * 2 / 3)) {
|
||||||
|
diam = display->getWidth() * 2 / 3;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
diam = display->getWidth();
|
||||||
|
if (diam > (display->getHeight() * 2 / 3)) {
|
||||||
|
diam = display->getHeight() * 2 / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return diam - 20;
|
||||||
|
};
|
||||||
|
|
||||||
/// We will skip one node - the one for us, so we just blindly loop over all
|
/// We will skip one node - the one for us, so we just blindly loop over all
|
||||||
/// nodes
|
/// nodes
|
||||||
static size_t nodeIndex;
|
static size_t nodeIndex;
|
||||||
@ -685,7 +704,7 @@ static void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t comp
|
|||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
arrowPoints[i]->rotate(headingRadian);
|
arrowPoints[i]->rotate(headingRadian);
|
||||||
arrowPoints[i]->scale(COMPASS_DIAM * 0.6);
|
arrowPoints[i]->scale(getCompassDiam(display) * 0.6);
|
||||||
arrowPoints[i]->translate(compassX, compassY);
|
arrowPoints[i]->translate(compassX, compassY);
|
||||||
}
|
}
|
||||||
drawLine(display, tip, tail);
|
drawLine(display, tip, tail);
|
||||||
@ -707,7 +726,7 @@ static void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t com
|
|||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
// North on compass will be negative of heading
|
// North on compass will be negative of heading
|
||||||
rosePoints[i]->rotate(-myHeading);
|
rosePoints[i]->rotate(-myHeading);
|
||||||
rosePoints[i]->scale(COMPASS_DIAM);
|
rosePoints[i]->scale(getCompassDiam(display));
|
||||||
rosePoints[i]->translate(compassX, compassY);
|
rosePoints[i]->translate(compassX, compassY);
|
||||||
}
|
}
|
||||||
drawLine(display, N1, N3);
|
drawLine(display, N1, N3);
|
||||||
@ -772,7 +791,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||||||
const char *fields[] = {username, distStr, signalStr, lastStr, NULL};
|
const char *fields[] = {username, distStr, signalStr, lastStr, NULL};
|
||||||
|
|
||||||
// coordinates for the center of the compass/circle
|
// coordinates for the center of the compass/circle
|
||||||
int16_t compassX = x + SCREEN_WIDTH - COMPASS_DIAM / 2 - 5, compassY = y + SCREEN_HEIGHT / 2;
|
int16_t compassX = x + SCREEN_WIDTH - getCompassDiam(display) / 2 - 5, compassY = y + SCREEN_HEIGHT / 2;
|
||||||
bool hasNodeHeading = false;
|
bool hasNodeHeading = false;
|
||||||
|
|
||||||
if (ourNode && hasPosition(ourNode)) {
|
if (ourNode && hasPosition(ourNode)) {
|
||||||
@ -813,7 +832,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||||||
// Debug info for gps lock errors
|
// Debug info for gps lock errors
|
||||||
// DEBUG_MSG("ourNode %d, ourPos %d, theirPos %d\n", !!ourNode, ourNode && hasPosition(ourNode), hasPosition(node));
|
// DEBUG_MSG("ourNode %d, ourPos %d, theirPos %d\n", !!ourNode, ourNode && hasPosition(ourNode), hasPosition(node));
|
||||||
display->drawString(compassX - FONT_HEIGHT_SMALL / 4, compassY - FONT_HEIGHT_SMALL / 2, "?");
|
display->drawString(compassX - FONT_HEIGHT_SMALL / 4, compassY - FONT_HEIGHT_SMALL / 2, "?");
|
||||||
display->drawCircle(compassX, compassY, COMPASS_DIAM / 2);
|
display->drawCircle(compassX, compassY, getCompassDiam(display) / 2);
|
||||||
|
|
||||||
// Must be after distStr is populated
|
// Must be after distStr is populated
|
||||||
drawColumns(display, x, y, fields);
|
drawColumns(display, x, y, fields);
|
||||||
|
@ -233,6 +233,8 @@ void setup()
|
|||||||
delay(1);
|
delay(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// We need to scan here to decide if we have a screen for nodeDB.init()
|
||||||
|
scanI2Cdevice();
|
||||||
#ifdef RAK4630
|
#ifdef RAK4630
|
||||||
// scanEInkDevice();
|
// scanEInkDevice();
|
||||||
#endif
|
#endif
|
||||||
@ -273,10 +275,12 @@ void setup()
|
|||||||
power->setup(); // Must be after status handler is installed, so that handler gets notified of the initial configuration
|
power->setup(); // Must be after status handler is installed, so that handler gets notified of the initial configuration
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Move the scanning I2C device to the back of power initialization.
|
* Repeat the scanning for I2C devices after power initialization.
|
||||||
* Some boards need to be powered on to correctly scan to the device address, such as t-beam-s3-core
|
* Boards with an PMU need to be powered on to correctly scan to the device address, such as t-beam-s3-core
|
||||||
*/
|
*/
|
||||||
|
if ((HW_VENDOR == HardwareModel_LILYGO_TBEAM_S3_CORE) || (HW_VENDOR == HardwareModel_TBEAM)) {
|
||||||
scanI2Cdevice();
|
scanI2Cdevice();
|
||||||
|
}
|
||||||
|
|
||||||
// Init our SPI controller (must be before screen and lora)
|
// Init our SPI controller (must be before screen and lora)
|
||||||
initSPI();
|
initSPI();
|
||||||
|
@ -699,11 +699,23 @@ NodeInfo *NodeDB::getOrCreateNode(NodeNum n)
|
|||||||
|
|
||||||
if (!info) {
|
if (!info) {
|
||||||
if (*numNodes >= MAX_NUM_NODES) {
|
if (*numNodes >= MAX_NUM_NODES) {
|
||||||
screen->print("error: node_db full!\n");
|
screen->print("warning: node_db full! erasing oldest entry\n");
|
||||||
DEBUG_MSG("ERROR! could not create new node, node_db is full! (%d nodes)", *numNodes);
|
// look for oldest node and erase it
|
||||||
return NULL;
|
uint32_t oldest = UINT32_MAX;
|
||||||
|
int oldestIndex = -1;
|
||||||
|
for (int i = 0; i < *numNodes; i++) {
|
||||||
|
if (nodes[i].last_heard < oldest) {
|
||||||
|
oldest = nodes[i].last_heard;
|
||||||
|
oldestIndex = i;
|
||||||
}
|
}
|
||||||
// add the node
|
}
|
||||||
|
// Shove the remaining nodes down the chain
|
||||||
|
for (int i = oldestIndex; i < *numNodes - 1; i++) {
|
||||||
|
nodes[i] = nodes[i + 1];
|
||||||
|
}
|
||||||
|
(*numNodes)--;
|
||||||
|
}
|
||||||
|
// add the node at the end
|
||||||
info = &nodes[(*numNodes)++];
|
info = &nodes[(*numNodes)++];
|
||||||
|
|
||||||
// everything is missing except the nodenum
|
// everything is missing except the nodenum
|
||||||
|
@ -58,12 +58,12 @@ bool ReliableRouter::shouldFilterReceived(MeshPacket *p)
|
|||||||
* this way if an ACK is dropped and a packet is resent we'll ACK the resent packet
|
* this way if an ACK is dropped and a packet is resent we'll ACK the resent packet
|
||||||
* make sure wasSeenRecently _doesn't_ update
|
* make sure wasSeenRecently _doesn't_ update
|
||||||
* finding the channel requires decoding the packet. */
|
* finding the channel requires decoding the packet. */
|
||||||
if (p->want_ack && (p->to == getNodeNum()) && wasSeenRecently(p, false)) {
|
if (p->want_ack && (p->to == getNodeNum()) && wasSeenRecently(p, false) && !MeshModule::currentReply) {
|
||||||
if (perhapsDecode(p)) {
|
if (perhapsDecode(p)) {
|
||||||
sendAckNak(Routing_Error_NONE, getFrom(p), p->id, p->channel);
|
sendAckNak(Routing_Error_NONE, getFrom(p), p->id, p->channel);
|
||||||
DEBUG_MSG("acking a repeated want_ack packet\n");
|
DEBUG_MSG("acking a repeated want_ack packet\n");
|
||||||
}
|
}
|
||||||
} else if (wasSeenRecently(p, false) && p->hop_limit == HOP_RELIABLE) {
|
} else if (wasSeenRecently(p, false) && p->hop_limit == HOP_RELIABLE && !MeshModule::currentReply) {
|
||||||
// retransmission on broadcast has hop_limit still equal to HOP_RELIABLE
|
// retransmission on broadcast has hop_limit still equal to HOP_RELIABLE
|
||||||
DEBUG_MSG("Resending implicit ack for a repeated floodmsg\n");
|
DEBUG_MSG("Resending implicit ack for a repeated floodmsg\n");
|
||||||
MeshPacket *tosend = packetPool.allocCopy(*p);
|
MeshPacket *tosend = packetPool.allocCopy(*p);
|
||||||
@ -94,7 +94,7 @@ void ReliableRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
|||||||
// - not DSR routing)
|
// - not DSR routing)
|
||||||
if (p->want_ack) {
|
if (p->want_ack) {
|
||||||
if (MeshModule::currentReply)
|
if (MeshModule::currentReply)
|
||||||
DEBUG_MSG("Someone else has replied to this message, no need for a 2nd ack\n");
|
DEBUG_MSG("Some other module has replied to this message, no need for a 2nd ack\n");
|
||||||
else
|
else
|
||||||
sendAckNak(Routing_Error_NONE, getFrom(p), p->id, p->channel);
|
sendAckNak(Routing_Error_NONE, getFrom(p), p->id, p->channel);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ typedef struct _AdminMessage {
|
|||||||
/* Get the Canned Message Module messages in the response to this message. */
|
/* Get the Canned Message Module messages in the response to this message. */
|
||||||
char get_canned_message_module_messages_response[201];
|
char get_canned_message_module_messages_response[201];
|
||||||
/* Request the node to send device metadata (firmware, protobuf version, etc) */
|
/* Request the node to send device metadata (firmware, protobuf version, etc) */
|
||||||
uint32_t get_device_metadata_request;
|
bool get_device_metadata_request;
|
||||||
/* Device metadata response */
|
/* Device metadata response */
|
||||||
DeviceMetadata get_device_metadata_response;
|
DeviceMetadata get_device_metadata_response;
|
||||||
/* Set the owner for this node */
|
/* Set the owner for this node */
|
||||||
@ -94,6 +94,9 @@ typedef struct _AdminMessage {
|
|||||||
bool confirm_set_channel;
|
bool confirm_set_channel;
|
||||||
/* TODO: REPLACE */
|
/* TODO: REPLACE */
|
||||||
bool confirm_set_radio;
|
bool confirm_set_radio;
|
||||||
|
/* Tell the node to reboot into the OTA Firmware in this many seconds (or <0 to cancel reboot)
|
||||||
|
Only Implemented for ESP32 Devices. This needs to be issued to send a new main firmware via bluetooth. */
|
||||||
|
int32_t reboot_ota_seconds;
|
||||||
/* This message is only supported for the simulator porduino build.
|
/* This message is only supported for the simulator porduino build.
|
||||||
If received the simulator will exit successfully. */
|
If received the simulator will exit successfully. */
|
||||||
bool exit_simulator;
|
bool exit_simulator;
|
||||||
@ -150,6 +153,7 @@ extern "C" {
|
|||||||
#define AdminMessage_confirm_set_module_config_tag 65
|
#define AdminMessage_confirm_set_module_config_tag 65
|
||||||
#define AdminMessage_confirm_set_channel_tag 66
|
#define AdminMessage_confirm_set_channel_tag 66
|
||||||
#define AdminMessage_confirm_set_radio_tag 67
|
#define AdminMessage_confirm_set_radio_tag 67
|
||||||
|
#define AdminMessage_reboot_ota_seconds_tag 95
|
||||||
#define AdminMessage_exit_simulator_tag 96
|
#define AdminMessage_exit_simulator_tag 96
|
||||||
#define AdminMessage_reboot_seconds_tag 97
|
#define AdminMessage_reboot_seconds_tag 97
|
||||||
#define AdminMessage_shutdown_seconds_tag 98
|
#define AdminMessage_shutdown_seconds_tag 98
|
||||||
@ -169,7 +173,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_module_config_response,g
|
|||||||
X(a, STATIC, ONEOF, BOOL, (payload_variant,get_all_channel_request,get_all_channel_request), 9) \
|
X(a, STATIC, ONEOF, BOOL, (payload_variant,get_all_channel_request,get_all_channel_request), 9) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (payload_variant,get_canned_message_module_messages_request,get_canned_message_module_messages_request), 10) \
|
X(a, STATIC, ONEOF, BOOL, (payload_variant,get_canned_message_module_messages_request,get_canned_message_module_messages_request), 10) \
|
||||||
X(a, STATIC, ONEOF, STRING, (payload_variant,get_canned_message_module_messages_response,get_canned_message_module_messages_response), 11) \
|
X(a, STATIC, ONEOF, STRING, (payload_variant,get_canned_message_module_messages_response,get_canned_message_module_messages_response), 11) \
|
||||||
X(a, STATIC, ONEOF, UINT32, (payload_variant,get_device_metadata_request,get_device_metadata_request), 12) \
|
X(a, STATIC, ONEOF, BOOL, (payload_variant,get_device_metadata_request,get_device_metadata_request), 12) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_device_metadata_response,get_device_metadata_response), 13) \
|
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_device_metadata_response,get_device_metadata_response), 13) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_owner,set_owner), 32) \
|
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_owner,set_owner), 32) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_channel,set_channel), 33) \
|
X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_channel,set_channel), 33) \
|
||||||
@ -180,6 +184,7 @@ X(a, STATIC, ONEOF, BOOL, (payload_variant,confirm_set_config,confirm_s
|
|||||||
X(a, STATIC, ONEOF, BOOL, (payload_variant,confirm_set_module_config,confirm_set_module_config), 65) \
|
X(a, STATIC, ONEOF, BOOL, (payload_variant,confirm_set_module_config,confirm_set_module_config), 65) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (payload_variant,confirm_set_channel,confirm_set_channel), 66) \
|
X(a, STATIC, ONEOF, BOOL, (payload_variant,confirm_set_channel,confirm_set_channel), 66) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (payload_variant,confirm_set_radio,confirm_set_radio), 67) \
|
X(a, STATIC, ONEOF, BOOL, (payload_variant,confirm_set_radio,confirm_set_radio), 67) \
|
||||||
|
X(a, STATIC, ONEOF, INT32, (payload_variant,reboot_ota_seconds,reboot_ota_seconds), 95) \
|
||||||
X(a, STATIC, ONEOF, BOOL, (payload_variant,exit_simulator,exit_simulator), 96) \
|
X(a, STATIC, ONEOF, BOOL, (payload_variant,exit_simulator,exit_simulator), 96) \
|
||||||
X(a, STATIC, ONEOF, INT32, (payload_variant,reboot_seconds,reboot_seconds), 97) \
|
X(a, STATIC, ONEOF, INT32, (payload_variant,reboot_seconds,reboot_seconds), 97) \
|
||||||
X(a, STATIC, ONEOF, INT32, (payload_variant,shutdown_seconds,shutdown_seconds), 98) \
|
X(a, STATIC, ONEOF, INT32, (payload_variant,shutdown_seconds,shutdown_seconds), 98) \
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
#include "Channels.h"
|
#include "Channels.h"
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
|
#include "BleOta.h"
|
||||||
|
#endif
|
||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@ -103,6 +106,21 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
|
|||||||
rebootAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
rebootAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case AdminMessage_reboot_ota_seconds_tag: {
|
||||||
|
int32_t s = r->reboot_ota_seconds;
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
|
if (BleOta::getOtaAppVersion().isEmpty()) {
|
||||||
|
DEBUG_MSG("No OTA firmware available, scheduling regular reboot in %d seconds\n", s);
|
||||||
|
}else{
|
||||||
|
BleOta::switchToOtaApp();
|
||||||
|
DEBUG_MSG("Rebooting to OTA in %d seconds\n", s);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
DEBUG_MSG("Not on ESP32, scheduling regular reboot in %d seconds\n", s);
|
||||||
|
#endif
|
||||||
|
rebootAtMsec = (s < 0) ? 0 : (millis() + s * 1000);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case AdminMessage_shutdown_seconds_tag: {
|
case AdminMessage_shutdown_seconds_tag: {
|
||||||
int32_t s = r->shutdown_seconds;
|
int32_t s = r->shutdown_seconds;
|
||||||
DEBUG_MSG("Shutdown in %d seconds\n", s);
|
DEBUG_MSG("Shutdown in %d seconds\n", s);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "graphics/fonts/OLEDDisplayFontsRU.h"
|
#include "graphics/fonts/OLEDDisplayFontsRU.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_EINK) || defined(ILI9341_DRIVER)
|
#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS)
|
||||||
// The screen is bigger so use bigger fonts
|
// The screen is bigger so use bigger fonts
|
||||||
#define FONT_SMALL ArialMT_Plain_16
|
#define FONT_SMALL ArialMT_Plain_16
|
||||||
#define FONT_MEDIUM ArialMT_Plain_24
|
#define FONT_MEDIUM ArialMT_Plain_24
|
||||||
@ -203,7 +203,7 @@ void CannedMessageModule::sendText(NodeNum dest, const char *message, bool wantR
|
|||||||
p->decoded.payload.size++;
|
p->decoded.payload.size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_MSG("Sending message id=%d, msg=%.*s\n", p->id, p->decoded.payload.size, p->decoded.payload.bytes);
|
DEBUG_MSG("Sending message id=%d, dest=%x, msg=%.*s\n", p->id, p->to, p->decoded.payload.size, p->decoded.payload.bytes);
|
||||||
|
|
||||||
service.sendToMesh(p);
|
service.sendToMesh(p);
|
||||||
}
|
}
|
||||||
@ -266,19 +266,23 @@ int32_t CannedMessageModule::runOnce()
|
|||||||
e.frameChanged = true;
|
e.frameChanged = true;
|
||||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
|
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
|
||||||
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_UP) {
|
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_UP) {
|
||||||
|
if (this->messagesCount > 0) {
|
||||||
this->currentMessageIndex = getPrevIndex();
|
this->currentMessageIndex = getPrevIndex();
|
||||||
this->freetext = ""; // clear freetext
|
this->freetext = ""; // clear freetext
|
||||||
this->cursor = 0;
|
this->cursor = 0;
|
||||||
this->destSelect = false;
|
this->destSelect = false;
|
||||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
|
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
|
||||||
DEBUG_MSG("MOVE UP (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
|
DEBUG_MSG("MOVE UP (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
|
||||||
|
}
|
||||||
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_DOWN) {
|
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_ACTION_DOWN) {
|
||||||
|
if (this->messagesCount > 0) {
|
||||||
this->currentMessageIndex = this->getNextIndex();
|
this->currentMessageIndex = this->getNextIndex();
|
||||||
this->freetext = ""; // clear freetext
|
this->freetext = ""; // clear freetext
|
||||||
this->cursor = 0;
|
this->cursor = 0;
|
||||||
this->destSelect = false;
|
this->destSelect = false;
|
||||||
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
|
this->runState = CANNED_MESSAGE_RUN_STATE_ACTIVE;
|
||||||
DEBUG_MSG("MOVE DOWN (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
|
DEBUG_MSG("MOVE DOWN (%d):%s\n", this->currentMessageIndex, this->getCurrentMessage());
|
||||||
|
}
|
||||||
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
|
} else if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
|
||||||
e.frameChanged = true;
|
e.frameChanged = true;
|
||||||
switch (this->payload) {
|
switch (this->payload) {
|
||||||
@ -287,19 +291,15 @@ int32_t CannedMessageModule::runOnce()
|
|||||||
size_t numNodes = nodeDB.getNumNodes();
|
size_t numNodes = nodeDB.getNumNodes();
|
||||||
if(this->dest == NODENUM_BROADCAST) {
|
if(this->dest == NODENUM_BROADCAST) {
|
||||||
this->dest = nodeDB.getNodeNum();
|
this->dest = nodeDB.getNodeNum();
|
||||||
DEBUG_MSG("Replacing NodeNum_BROADCAST with %x\n",nodeDB.getNodeNum());
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < numNodes; i++) {
|
for (unsigned int i = 0; i < numNodes; i++) {
|
||||||
DEBUG_MSG("Considering %x\n",nodeDB.getNodeByIndex(i)->num);
|
|
||||||
if (nodeDB.getNodeByIndex(i)->num == this->dest) {
|
if (nodeDB.getNodeByIndex(i)->num == this->dest) {
|
||||||
DEBUG_MSG("Match - advance %i-\n",i);
|
|
||||||
this->dest = (i > 0) ? nodeDB.getNodeByIndex(i-1)->num : nodeDB.getNodeByIndex(numNodes-1)->num;
|
this->dest = (i > 0) ? nodeDB.getNodeByIndex(i-1)->num : nodeDB.getNodeByIndex(numNodes-1)->num;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this->dest == nodeDB.getNodeNum()) {
|
if(this->dest == nodeDB.getNodeNum()) {
|
||||||
this->dest = NODENUM_BROADCAST;
|
this->dest = NODENUM_BROADCAST;
|
||||||
DEBUG_MSG("Replacing %x with NodeNum_BROADCAST\n",nodeDB.getNodeNum());
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (this->cursor > 0) {
|
if (this->cursor > 0) {
|
||||||
@ -312,19 +312,15 @@ int32_t CannedMessageModule::runOnce()
|
|||||||
size_t numNodes = nodeDB.getNumNodes();
|
size_t numNodes = nodeDB.getNumNodes();
|
||||||
if(this->dest == NODENUM_BROADCAST) {
|
if(this->dest == NODENUM_BROADCAST) {
|
||||||
this->dest = nodeDB.getNodeNum();
|
this->dest = nodeDB.getNodeNum();
|
||||||
DEBUG_MSG("Replacing NodeNum_BROADCAST with %x\n",nodeDB.getNodeNum());
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < numNodes; i++) {
|
for (unsigned int i = 0; i < numNodes; i++) {
|
||||||
DEBUG_MSG("Considering %x\n",nodeDB.getNodeByIndex(i)->num);
|
|
||||||
if (nodeDB.getNodeByIndex(i)->num == this->dest) {
|
if (nodeDB.getNodeByIndex(i)->num == this->dest) {
|
||||||
DEBUG_MSG("Match - advance %i+\n",i);
|
|
||||||
this->dest = (i < numNodes-1) ? nodeDB.getNodeByIndex(i+1)->num : nodeDB.getNodeByIndex(0)->num;
|
this->dest = (i < numNodes-1) ? nodeDB.getNodeByIndex(i+1)->num : nodeDB.getNodeByIndex(0)->num;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this->dest == nodeDB.getNodeNum()) {
|
if(this->dest == nodeDB.getNodeNum()) {
|
||||||
this->dest = NODENUM_BROADCAST;
|
this->dest = NODENUM_BROADCAST;
|
||||||
DEBUG_MSG("Replacing %x with NodeNum_BROADCAST\n",nodeDB.getNodeNum());
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (this->cursor < this->freetext.length()) {
|
if (this->cursor < this->freetext.length()) {
|
||||||
@ -457,6 +453,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
display->drawStringMaxWidth(0 + x, 0 + y + FONT_HEIGHT_SMALL, x + display->getWidth(), cannedMessageModule->drawWithCursor(cannedMessageModule->freetext, cannedMessageModule->cursor));
|
display->drawStringMaxWidth(0 + x, 0 + y + FONT_HEIGHT_SMALL, x + display->getWidth(), cannedMessageModule->drawWithCursor(cannedMessageModule->freetext, cannedMessageModule->cursor));
|
||||||
} else {
|
} else {
|
||||||
|
if (this->messagesCount > 0) {
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawString(0 + x, 0 + y, cannedMessageModule->getPrevMessage());
|
display->drawString(0 + x, 0 + y, cannedMessageModule->getPrevMessage());
|
||||||
@ -466,6 +463,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
display->drawString(0 + x, 0 + y + FONT_HEIGHT_MEDIUM, cannedMessageModule->getNextMessage());
|
display->drawString(0 + x, 0 + y + FONT_HEIGHT_MEDIUM, cannedMessageModule->getNextMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CannedMessageModule::loadProtoForModule()
|
void CannedMessageModule::loadProtoForModule()
|
||||||
{
|
{
|
||||||
|
46
src/platform/esp32/BleOta.cpp
Normal file
46
src/platform/esp32/BleOta.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#include "Arduino.h"
|
||||||
|
#include "BleOta.h"
|
||||||
|
#include <esp_ota_ops.h>
|
||||||
|
|
||||||
|
static const String MESHTASTIC_OTA_APP_PROJECT_NAME("Meshtastic-OTA");
|
||||||
|
|
||||||
|
const esp_partition_t* BleOta::findEspOtaAppPartition() {
|
||||||
|
const esp_partition_t *part
|
||||||
|
= esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1, nullptr);
|
||||||
|
|
||||||
|
esp_app_desc_t app_desc;
|
||||||
|
esp_err_t ret = ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_get_partition_description(part, &app_desc));
|
||||||
|
|
||||||
|
if (ret != ESP_OK || MESHTASTIC_OTA_APP_PROJECT_NAME != app_desc.project_name) {
|
||||||
|
part
|
||||||
|
= esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_OTA_1,
|
||||||
|
nullptr);
|
||||||
|
ret = ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_get_partition_description(part, &app_desc));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == ESP_OK && MESHTASTIC_OTA_APP_PROJECT_NAME == app_desc.project_name) {
|
||||||
|
return part;
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String BleOta::getOtaAppVersion() {
|
||||||
|
const esp_partition_t *part = findEspOtaAppPartition();
|
||||||
|
esp_app_desc_t app_desc;
|
||||||
|
esp_err_t ret = ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_get_partition_description(part, &app_desc));
|
||||||
|
String version;
|
||||||
|
if (ret == ESP_OK) {
|
||||||
|
version = app_desc.version;
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BleOta::switchToOtaApp() {
|
||||||
|
bool success = false;
|
||||||
|
const esp_partition_t *part = findEspOtaAppPartition();
|
||||||
|
if (part) {
|
||||||
|
success = (ESP_ERROR_CHECK_WITHOUT_ABORT(esp_ota_set_boot_partition(part)) == ESP_OK);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
18
src/platform/esp32/BleOta.h
Normal file
18
src/platform/esp32/BleOta.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef BLEOTA_H
|
||||||
|
#define BLEOTA_H
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
class BleOta {
|
||||||
|
public:
|
||||||
|
explicit BleOta() {};
|
||||||
|
|
||||||
|
static String getOtaAppVersion();
|
||||||
|
static bool switchToOtaApp();
|
||||||
|
|
||||||
|
private:
|
||||||
|
String mUserAgent;
|
||||||
|
static const esp_partition_t *findEspOtaAppPartition();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //BLEOTA_H
|
@ -171,6 +171,8 @@ void SimRadio::onNotify(uint32_t notification)
|
|||||||
// Packet has been sent, count it toward our TX airtime utilization.
|
// Packet has been sent, count it toward our TX airtime utilization.
|
||||||
uint32_t xmitMsec = getPacketTime(txp);
|
uint32_t xmitMsec = getPacketTime(txp);
|
||||||
airTime->logAirtime(TX_LOG, xmitMsec);
|
airTime->logAirtime(TX_LOG, xmitMsec);
|
||||||
|
|
||||||
|
delay(xmitMsec); // Model the time it is busy sending
|
||||||
completeSending();
|
completeSending();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,6 +209,9 @@ void SimRadio::startSend(MeshPacket * txp)
|
|||||||
|
|
||||||
void SimRadio::startReceive(MeshPacket *p) {
|
void SimRadio::startReceive(MeshPacket *p) {
|
||||||
isReceiving = true;
|
isReceiving = true;
|
||||||
|
size_t length = getPacketLength(p);
|
||||||
|
uint32_t xmitMsec = getPacketTime(length);
|
||||||
|
delay(xmitMsec); // Model the time it is busy receiving
|
||||||
handleReceiveInterrupt(p);
|
handleReceiveInterrupt(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user