mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-08 02:47:35 +00:00
Allow overriding the default Serial console output settings (#2528)
* Implement override_console_serial_port * It's opposite day in Logictown * Try to use native serial types for platforms * Fix for s3 * Trunk * Screw it... just declare as Print and handle init * Alright, chatty kathy * Missed a spot * I'll take "Kill that FIXME" for 800, Alex * Badunkadunk * Refactor out a lot of duplicated code * Boogers * Okay I probably should stop changing everything
This commit is contained in:
@@ -239,7 +239,7 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)
|
||||
meshtastic_NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
|
||||
assert(node);
|
||||
|
||||
if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) {
|
||||
if (hasValidPosition(node)) {
|
||||
if (positionModule) {
|
||||
LOG_INFO("Sending position ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel);
|
||||
positionModule->sendOurPosition(dest, wantReplies, node->channel);
|
||||
|
||||
@@ -584,10 +584,10 @@ void NodeDB::saveToDisk(int saveWhat)
|
||||
}
|
||||
}
|
||||
|
||||
const meshtastic_NodeInfo *NodeDB::readNextInfo()
|
||||
const meshtastic_NodeInfo *NodeDB::readNextInfo(uint32_t &readIndex)
|
||||
{
|
||||
if (readPointer < *numNodes)
|
||||
return &nodes[readPointer++];
|
||||
if (readIndex < *numNodes)
|
||||
return &nodes[readIndex++];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -46,8 +46,6 @@ class NodeDB
|
||||
meshtastic_NodeInfo *nodes;
|
||||
pb_size_t *numNodes;
|
||||
|
||||
uint32_t readPointer = 0;
|
||||
|
||||
public:
|
||||
bool updateGUI = false; // we think the gui should definitely be redrawn, screen will clear this once handled
|
||||
meshtastic_NodeInfo *updateGUIforNode = NULL; // if currently showing this node, we think you should update the GUI
|
||||
@@ -104,11 +102,8 @@ class NodeDB
|
||||
their denial?)
|
||||
*/
|
||||
|
||||
/// Called from bluetooth when the user wants to start reading the node DB from scratch.
|
||||
void resetReadPointer() { readPointer = 0; }
|
||||
|
||||
/// Allow the bluetooth layer to read our next nodeinfo record, or NULL if done reading
|
||||
const meshtastic_NodeInfo *readNextInfo();
|
||||
const meshtastic_NodeInfo *readNextInfo(uint32_t &readIndex);
|
||||
|
||||
/// pick a provisional nodenum we hope no one is using
|
||||
void pickNewNodeNum();
|
||||
@@ -217,6 +212,13 @@ inline uint32_t getConfiguredOrDefaultMs(uint32_t configuredInterval, uint32_t d
|
||||
return defaultInterval * 1000;
|
||||
}
|
||||
|
||||
/// Sometimes we will have Position objects that only have a time, so check for
|
||||
/// valid lat/lon
|
||||
static inline bool hasValidPosition(const meshtastic_NodeInfo *n)
|
||||
{
|
||||
return n->has_position && (n->position.latitude_i != 0 || n->position.longitude_i != 0);
|
||||
}
|
||||
|
||||
/** The current change # for radio settings. Starts at 0 on boot and any time the radio settings
|
||||
* might have changed is incremented. Allows others to detect they might now be on a new channel.
|
||||
*/
|
||||
|
||||
@@ -40,9 +40,8 @@ void PhoneAPI::handleStartConfig()
|
||||
state = STATE_SEND_MY_INFO;
|
||||
|
||||
LOG_INFO("Starting API client config\n");
|
||||
nodeInfoForPhone = NULL; // Don't keep returning old nodeinfos
|
||||
nodeDB.resetReadPointer(); // FIXME, this read pointer should be moved out of nodeDB and into this class - because
|
||||
// this will break once we have multiple instances of PhoneAPI running independently
|
||||
nodeInfoForPhone = NULL; // Don't keep returning old nodeinfos
|
||||
resetReadIndex();
|
||||
}
|
||||
|
||||
void PhoneAPI::close()
|
||||
@@ -373,7 +372,7 @@ bool PhoneAPI::available()
|
||||
|
||||
case STATE_SEND_NODEINFO:
|
||||
if (!nodeInfoForPhone)
|
||||
nodeInfoForPhone = nodeDB.readNextInfo();
|
||||
nodeInfoForPhone = nodeDB.readNextInfo(readIndex);
|
||||
return true; // Always say we have something, because we might need to advance our state machine
|
||||
|
||||
case STATE_SEND_PACKETS: {
|
||||
|
||||
@@ -58,6 +58,9 @@ class PhoneAPI
|
||||
|
||||
/// Use to ensure that clients don't get confused about old messages from the radio
|
||||
uint32_t config_nonce = 0;
|
||||
uint32_t readIndex = 0;
|
||||
|
||||
void resetReadIndex() { readIndex = 0; }
|
||||
|
||||
public:
|
||||
PhoneAPI();
|
||||
|
||||
Reference in New Issue
Block a user