Skip to content

Commit c740550

Browse files
authored
Merge branch 'develop' into InkHUD-Fixes
2 parents cb3ce1b + 6f22417 commit c740550

File tree

8 files changed

+533
-65
lines changed

8 files changed

+533
-65
lines changed

protobufs

src/mesh/PhoneAPI.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ void PhoneAPI::handleStartConfig()
5757
#endif
5858
}
5959

60+
// Allow subclasses to prepare for high-throughput config traffic
61+
onConfigStart();
62+
6063
// even if we were already connected - restart our state machine
6164
if (config_nonce == SPECIAL_NONCE_ONLY_NODES) {
6265
// If client only wants node info, jump directly to sending nodes
@@ -71,7 +74,7 @@ void PhoneAPI::handleStartConfig()
7174
spiLock->unlock();
7275
LOG_DEBUG("Got %d files in manifest", filesManifest.size());
7376

74-
LOG_INFO("Start API client config");
77+
LOG_INFO("Start API client config millis=%u", millis());
7578
// Protect against concurrent BLE callbacks: they run in NimBLE's FreeRTOS task and also touch nodeInfoQueue.
7679
{
7780
concurrency::LockGuard guard(&nodeInfoMutex);
@@ -453,7 +456,10 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
453456
break;
454457

455458
case STATE_SEND_OTHER_NODEINFOS: {
456-
LOG_DEBUG("Send known nodes");
459+
if (readIndex == 2) { // readIndex==2 will be true for the first non-us node
460+
LOG_INFO("Start sending nodeinfos millis=%u", millis());
461+
}
462+
457463
meshtastic_NodeInfo infoToSend = {};
458464
{
459465
concurrency::LockGuard guard(&nodeInfoMutex);
@@ -470,13 +476,22 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
470476
if (infoToSend.num != 0) {
471477
// Just in case we stored a different user.id in the past, but should never happen going forward
472478
sprintf(infoToSend.user.id, "!%08x", infoToSend.num);
473-
LOG_DEBUG("nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s", infoToSend.num, infoToSend.last_heard,
474-
infoToSend.user.id, infoToSend.user.long_name);
479+
480+
// Logging this really slows down sending nodes on initial connection because the serial console is so slow, so only
481+
// uncomment if you really need to:
482+
// LOG_INFO("nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s", nodeInfoForPhone.num, nodeInfoForPhone.last_heard,
483+
// nodeInfoForPhone.user.id, nodeInfoForPhone.user.long_name);
484+
485+
// Occasional progress logging. (readIndex==2 will be true for the first non-us node)
486+
if (readIndex == 2 || readIndex % 20 == 0) {
487+
LOG_DEBUG("nodeinfo: %d/%d", readIndex, nodeDB->getNumMeshNodes());
488+
}
489+
475490
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_node_info_tag;
476491
fromRadioScratch.node_info = infoToSend;
477492
prefetchNodeInfos();
478493
} else {
479-
LOG_DEBUG("Done sending nodeinfo");
494+
LOG_DEBUG("Done sending %d of %d nodeinfos millis=%u", readIndex, nodeDB->getNumMeshNodes(), millis());
480495
concurrency::LockGuard guard(&nodeInfoMutex);
481496
nodeInfoQueue.clear();
482497
state = STATE_SEND_FILEMANIFEST;
@@ -558,11 +573,15 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
558573

559574
void PhoneAPI::sendConfigComplete()
560575
{
561-
LOG_INFO("Config Send Complete");
576+
LOG_INFO("Config Send Complete millis=%u", millis());
562577
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_complete_id_tag;
563578
fromRadioScratch.config_complete_id = config_nonce;
564579
config_nonce = 0;
565580
state = STATE_SEND_PACKETS;
581+
582+
// Allow subclasses to know we've entered steady-state so they can lower power consumption
583+
onConfigComplete();
584+
566585
pauseBluetoothLogging = false;
567586
}
568587

src/mesh/PhoneAPI.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class PhoneAPI
136136
bool available();
137137

138138
bool isConnected() { return state != STATE_SEND_NOTHING; }
139+
bool isSendingPackets() { return state == STATE_SEND_PACKETS; }
139140

140141
protected:
141142
/// Our fromradio packet while it is being assembled
@@ -158,6 +159,11 @@ class PhoneAPI
158159
*/
159160
virtual void onNowHasData(uint32_t fromRadioNum) {}
160161

162+
/// Subclasses can use these lifecycle hooks for transport-specific behavior around config/steady-state
163+
/// (i.e. BLE connection params)
164+
virtual void onConfigStart() {}
165+
virtual void onConfigComplete() {}
166+
161167
/// begin a new connection
162168
void handleStartConfig();
163169

src/mesh/generated/meshtastic/mesh.pb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ typedef enum _meshtastic_HardwareModel {
282282
meshtastic_HardwareModel_HELTEC_WIRELESS_TRACKER_V2 = 113,
283283
/* LilyGo T-Watch Ultra */
284284
meshtastic_HardwareModel_T_WATCH_ULTRA = 114,
285+
/* Elecrow ThinkNode M3 */
286+
meshtastic_HardwareModel_THINKNODE_M3 = 115,
285287
/* ------------------------------------------------------------------------------------------------------------------------------------------
286288
Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits.
287289
------------------------------------------------------------------------------------------------------------------------------------------ */

src/mesh/generated/meshtastic/telemetry.pb.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ typedef enum _meshtastic_TelemetrySensorType {
101101
/* SEN5X PM SENSORS */
102102
meshtastic_TelemetrySensorType_SEN5X = 43,
103103
/* TSL2561 light sensor */
104-
meshtastic_TelemetrySensorType_TSL2561 = 44
104+
meshtastic_TelemetrySensorType_TSL2561 = 44,
105+
/* BH1750 light sensor */
106+
meshtastic_TelemetrySensorType_BH1750 = 45
105107
} meshtastic_TelemetrySensorType;
106108

107109
/* Struct definitions */
@@ -438,8 +440,8 @@ extern "C" {
438440

439441
/* Helper constants for enums */
440442
#define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET
441-
#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_TSL2561
442-
#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_TSL2561+1))
443+
#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_BH1750
444+
#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_BH1750+1))
443445

444446

445447

0 commit comments

Comments
 (0)