fix: review pass - Discover's late replies dropped and its way back usable, the Gallery's newest first and faster, the network clock's toast

- Discover: a reply after its try timed out, was stopped or was overtaken
  went on to the normal handling and became the contact's route (and sent
  a path back); the last tags sent are kept and a late reply is dropped.
  Leaving Route on the L2 stops a discovery as it stops a trace.
- Discover: a route whose reply came back another way offers that way too
  (L2 There / Back, L1 a Back row), turned round into a route there, so a
  trace checks it; the Discover button no longer sits on its group.
- Screenshots: numbered one past the highest (one pass over the folder,
  not a stat per number), so one taken after a delete is still the newest.
- Gallery: the newest 300 kept whatever order the folder lists them in;
  BMP rows read in the file's order and several at a time; the thumbnail
  buffer sized to the page; the folder read once per visit; a failed
  open frees or restores the picture.
- NTP: the slot the router's server goes in emptied before joining, so a
  cached address isn't taken for it; "Clock set from the network" judged
  against the clock a tick before (SNTP has set the system time already).
- Sim: sim_scroll up stops at the top.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-29 16:30:19 +01:00
co-authored by Claude Opus 5.5
parent e154a4e721
commit 3a26a8bee7
11 changed files with 171 additions and 65 deletions
+12 -4
View File
@@ -1079,6 +1079,8 @@ uint32_t MyMesh::sendPathDiscovery(const uint8_t* pub_key, DiscoverCallback cb,
uint32_t tag, est;
if (sendDiscoveryReq(*recipient, tag, est) == MSG_SEND_FAILED) return 0;
_ui_discovery = tag;
_ui_disc_sent[_ui_disc_next] = tag;
_ui_disc_next = (_ui_disc_next + 1) % UI_DISC_KEEP;
_discover_cb = cb;
if (est_timeout) *est_timeout = est;
return tag;
@@ -1089,10 +1091,16 @@ bool MyMesh::onContactPathRecv(ContactInfo& contact, uint8_t* in_path, uint8_t i
uint32_t tag;
memcpy(&tag, extra, 4);
if (_ui_discovery && tag == _ui_discovery) { // this device's own (sendPathDiscovery())
_ui_discovery = 0;
if (_discover_cb && mesh::Packet::isValidPathLen(in_path_len) && mesh::Packet::isValidPathLen(out_path_len))
_discover_cb(contact.id.pub_key, out_path, out_path_len, in_path, in_path_len);
// This device's own (sendPathDiscovery()): to the editor while it waits
// for it; late (timed out, stopped, an earlier try's) only dropped.
for (int k = 0; k < UI_DISC_KEEP; k++) {
if (!tag || _ui_disc_sent[k] != tag) continue;
_ui_disc_sent[k] = 0;
if (tag == _ui_discovery) {
_ui_discovery = 0;
if (_discover_cb && mesh::Packet::isValidPathLen(in_path_len) && mesh::Packet::isValidPathLen(out_path_len))
_discover_cb(contact.id.pub_key, out_path, out_path_len, in_path, in_path_len);
}
return false; // DON'T send reciprocal path, nor take it: the user picks
}