Skip to content

Commit 0e903de

Browse files
author
Scott Powell
committed
* BUG FIX: same remote login fix as repeater
1 parent dc58f0e commit 0e903de

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

examples/simple_sensor/SensorMesh.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ int SensorMesh::getAGCResetInterval() const {
326326
return ((int)_prefs.agc_reset_interval) * 4000; // milliseconds
327327
}
328328

329-
uint8_t SensorMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data) {
329+
uint8_t SensorMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data, bool is_flood) {
330330
ClientInfo* client;
331331
if (data[0] == 0) { // blank password, just check if sender is in ACL
332332
client = acl.getClient(sender.pub_key, PUB_KEY_SIZE);
@@ -359,6 +359,10 @@ uint8_t SensorMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t*
359359
dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY);
360360
}
361361

362+
if (is_flood) {
363+
client->out_path_len = -1; // need to rediscover out_path
364+
}
365+
362366
uint32_t now = getRTCClock()->getCurrentTimeUnique();
363367
memcpy(reply_data, &now, 4); // response packets always prefixed with timestamp
364368
reply_data[4] = RESP_SERVER_LOGIN_OK;
@@ -451,7 +455,7 @@ void SensorMesh::onAnonDataRecv(mesh::Packet* packet, const uint8_t* secret, con
451455
data[len] = 0; // ensure null terminator
452456
uint8_t reply_len;
453457
if (data[4] == 0 || data[4] >= ' ') { // is password, ie. a login request
454-
reply_len = handleLoginReq(sender, secret, timestamp, &data[4]);
458+
reply_len = handleLoginReq(sender, secret, timestamp, &data[4], packet->isRouteFlood());
455459
//} else if (data[4] == ANON_REQ_TYPE_*) { // future type codes
456460
// TODO
457461
} else {

examples/simple_sensor/SensorMesh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class SensorMesh : public mesh::Mesh, public CommonCLICallbacks {
148148
uint8_t pending_sf;
149149
uint8_t pending_cr;
150150

151-
uint8_t handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data);
151+
uint8_t handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data, bool is_flood);
152152
uint8_t handleRequest(uint8_t perms, uint32_t sender_timestamp, uint8_t req_type, uint8_t* payload, size_t payload_len);
153153
mesh::Packet* createSelfAdvert();
154154

0 commit comments

Comments
 (0)