mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Fix LilyGo_TLora_V2_1_1_6_terminal_chat build
This change addresses two issues. The first is that the LilyGo_TLora_V2_1_1_6_terminal_chat build would try to compile simple_repeater/MyMesh.cpp. All other examples of terminal chat targets are instead building simple_secure_chat/main.cpp . This change would align this build to the rest of the builds. The second issue, found during the course of investigating the first, stems from simple_repeater/MyMesh.cpp using the MAX_NEIGHBOURS #define to control whether the neighbor list is kept. Repeaters that keep this list must define this value, and if the value is not defined, then all neighbor-related functionality is compiled out. However, the code that replies to REQ_TYPE_GET_NEIGHBOURS did not properly check for this #define, and thus any target that compiles simple_repeater/MyMesh.cpp without defining MAX_NEIGHBOURS would get an undefined variable compilation error. As a practical matter though, there are no targets that compile simple_repeater/MyMesh.cpp AND do not define MAX_NEIGHBOURS, except this build due to the first issue. As a result, the second issue is addressed only as a matter of completeness. The expected behavior with this change is that such a repeater would send a valid reply indicating zero known neighbors.
This commit is contained in:
parent
2005977403
commit
3e53df5082
2 changed files with 5 additions and 1 deletions
|
|
@ -292,6 +292,7 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
|
||||||
|
|
||||||
// create copy of neighbours list, skipping empty entries so we can sort it separately from main list
|
// create copy of neighbours list, skipping empty entries so we can sort it separately from main list
|
||||||
int16_t neighbours_count = 0;
|
int16_t neighbours_count = 0;
|
||||||
|
#if MAX_NEIGHBOURS
|
||||||
NeighbourInfo* sorted_neighbours[MAX_NEIGHBOURS];
|
NeighbourInfo* sorted_neighbours[MAX_NEIGHBOURS];
|
||||||
for (int i = 0; i < MAX_NEIGHBOURS; i++) {
|
for (int i = 0; i < MAX_NEIGHBOURS; i++) {
|
||||||
auto neighbour = &neighbours[i];
|
auto neighbour = &neighbours[i];
|
||||||
|
|
@ -327,6 +328,7 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
|
||||||
return a->snr < b->snr; // asc
|
return a->snr < b->snr; // asc
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// build results buffer
|
// build results buffer
|
||||||
int results_count = 0;
|
int results_count = 0;
|
||||||
|
|
@ -341,6 +343,7 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MAX_NEIGHBOURS
|
||||||
// add next neighbour to results
|
// add next neighbour to results
|
||||||
auto neighbour = sorted_neighbours[index + offset];
|
auto neighbour = sorted_neighbours[index + offset];
|
||||||
uint32_t heard_seconds_ago = getRTCClock()->getCurrentTime() - neighbour->heard_timestamp;
|
uint32_t heard_seconds_ago = getRTCClock()->getCurrentTime() - neighbour->heard_timestamp;
|
||||||
|
|
@ -348,6 +351,7 @@ int MyMesh::handleRequest(ClientInfo *sender, uint32_t sender_timestamp, uint8_t
|
||||||
memcpy(&results_buffer[results_offset], &heard_seconds_ago, 4); results_offset += 4;
|
memcpy(&results_buffer[results_offset], &heard_seconds_ago, 4); results_offset += 4;
|
||||||
memcpy(&results_buffer[results_offset], &neighbour->snr, 1); results_offset += 1;
|
memcpy(&results_buffer[results_offset], &neighbour->snr, 1); results_offset += 1;
|
||||||
results_count++;
|
results_count++;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ build_flags =
|
||||||
; -D MESH_PACKET_LOGGING=1
|
; -D MESH_PACKET_LOGGING=1
|
||||||
; -D MESH_DEBUG=1
|
; -D MESH_DEBUG=1
|
||||||
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
|
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter}
|
||||||
+<../examples/simple_repeater>
|
+<../examples/simple_secure_chat/main.cpp>
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${LilyGo_TLora_V2_1_1_6.lib_deps}
|
${LilyGo_TLora_V2_1_1_6.lib_deps}
|
||||||
densaugeo/base64 @ ~1.4.0
|
densaugeo/base64 @ ~1.4.0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue