Skip to content

Commit 52d5cc6

Browse files
author
Scott Powell
committed
* tidy and minor fix for offline queue deletion
1 parent 28d673e commit 52d5cc6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

examples/companion_radio/MyMesh.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,17 @@ void MyMesh::updateContactFromFrame(ContactInfo &contact, uint32_t& last_mod, co
175175
}
176176
}
177177

178+
bool MyMesh::Frame::isChannelMsg() const {
179+
return buf[0] == RESP_CODE_CHANNEL_MSG_RECV || buf[0] == RESP_CODE_CHANNEL_MSG_RECV_V3;
180+
}
181+
178182
void MyMesh::addToOfflineQueue(const uint8_t frame[], int len) {
179183
if (offline_queue_len >= OFFLINE_QUEUE_SIZE) {
180184
MESH_DEBUG_PRINTLN("WARN: offline_queue is full!");
181185
int pos = 0;
182186
while (pos < offline_queue_len) {
183-
if ((offline_queue[pos].buf[0] == RESP_CODE_CHANNEL_MSG_RECV) ||
184-
offline_queue[pos].buf[0] == RESP_CODE_CHANNEL_MSG_RECV_V3) {
185-
for (int i = pos; i < offline_queue_len; i++) { // delete oldest channel msg from queue
187+
if (offline_queue[pos].isChannelMsg()) {
188+
for (int i = pos; i < offline_queue_len - 1; i++) { // delete oldest channel msg from queue
186189
offline_queue[i] = offline_queue[i + 1];
187190
}
188191
MESH_DEBUG_PRINTLN("INFO: removed oldest channel message from queue.");

examples/companion_radio/MyMesh.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ class MyMesh : public BaseChatMesh, public DataStoreHost {
198198
struct Frame {
199199
uint8_t len;
200200
uint8_t buf[MAX_FRAME_SIZE];
201+
202+
bool isChannelMsg() const;
201203
};
202204
int offline_queue_len;
203205
Frame offline_queue[OFFLINE_QUEUE_SIZE];

0 commit comments

Comments
 (0)