diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index c6a16f9d..6fb52d19 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -111,6 +111,7 @@ static uint32_t _atoi(const char* sp) { #define RESP_CODE_CONTACT_MSG_RECV 7 // a reply to CMD_SYNC_NEXT_MESSAGE #define RESP_CODE_CHANNEL_MSG_RECV 8 // a reply to CMD_SYNC_NEXT_MESSAGE #define RESP_CODE_CURR_TIME 9 // a reply to CMD_GET_DEVICE_TIME +#define RESP_CODE_NO_MORE_MESSAGES 10 // a reply to CMD_SYNC_NEXT_MESSAGE // these are _pushed_ to client app at any time #define PUSH_CODE_ADVERT 0x80 @@ -571,7 +572,7 @@ public: uint32_t secs; memcpy(&secs, &cmd_frame[1], 4); uint32_t curr = getRTCClock()->getCurrentTime(); - if (secs > curr) { + if (secs >= curr) { getRTCClock()->setCurrentTime(secs); writeOKFrame(); } else { @@ -612,6 +613,9 @@ public: int out_len; if ((out_len = getFromOfflineQueue(out_frame)) > 0) { _serial->writeFrame(out_frame, out_len); + } else { + out_frame[0] = RESP_CODE_NO_MORE_MESSAGES; + _serial->writeFrame(out_frame, 1); } } else if (cmd_frame[0] == CMD_SET_RADIO_PARAMS) { int i = 1; diff --git a/platformio.ini b/platformio.ini index 68b8ebd8..8b06a147 100644 --- a/platformio.ini +++ b/platformio.ini @@ -112,8 +112,8 @@ build_flags = ${Heltec_lora32_v3.build_flags} -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=1 -; -D MESH_PACKET_LOGGING=1 -; -D MESH_DEBUG=1 +; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 +; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v3.build_src_filter} +<../examples/companion_radio/main.cpp> lib_deps = ${Heltec_lora32_v3.lib_deps} @@ -303,8 +303,8 @@ build_flags = ${LilyGo_T3S3_sx1262.build_flags} -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=1 -; -D MESH_PACKET_LOGGING=1 -; -D MESH_DEBUG=1 +; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 +; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} +<../examples/companion_radio/main.cpp> lib_deps = ${LilyGo_T3S3_sx1262.lib_deps} @@ -406,8 +406,8 @@ build_flags = ${rak4631.build_flags} -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=1 -; -D MESH_PACKET_LOGGING=1 -; -D MESH_DEBUG=1 +; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 +; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${rak4631.build_src_filter} +<../examples/companion_radio/main.cpp> lib_deps = ${rak4631.lib_deps} diff --git a/src/helpers/BaseChatMesh.cpp b/src/helpers/BaseChatMesh.cpp index 26b3928d..10047026 100644 --- a/src/helpers/BaseChatMesh.cpp +++ b/src/helpers/BaseChatMesh.cpp @@ -309,7 +309,7 @@ ContactsIterator BaseChatMesh::startContactsIterator() { } bool ContactsIterator::hasNext(const BaseChatMesh* mesh, ContactInfo& dest) { - if (next_idx >= mesh->num_contacts) return false; + if (next_idx >= mesh->getNumContacts()) return false; dest = mesh->contacts[next_idx++]; return true; diff --git a/src/helpers/esp32/SerialBLEInterface.cpp b/src/helpers/esp32/SerialBLEInterface.cpp index 6e86785d..03131459 100644 --- a/src/helpers/esp32/SerialBLEInterface.cpp +++ b/src/helpers/esp32/SerialBLEInterface.cpp @@ -181,7 +181,7 @@ size_t SerialBLEInterface::checkRecvFrame(uint8_t dest[]) { pTxCharacteristic->setValue(send_queue[0].buf, send_queue[0].len); pTxCharacteristic->notify(); - BLE_DEBUG_PRINTLN("writeBytes: sz=%d", (uint32_t)send_queue[0].len); + BLE_DEBUG_PRINTLN("writeBytes: sz=%d, hdr=%d", (uint32_t)send_queue[0].len, (uint32_t) send_queue[0].buf[0]); send_queue_len--; for (int i = 0; i < send_queue_len; i++) { // delete top item from queue @@ -193,6 +193,8 @@ size_t SerialBLEInterface::checkRecvFrame(uint8_t dest[]) { size_t len = recv_queue[0].len; // take from top of queue memcpy(dest, recv_queue[0].buf, len); + BLE_DEBUG_PRINTLN("readBytes: sz=%d, hdr=%d", len, (uint32_t) dest[0]); + recv_queue_len--; for (int i = 0; i < recv_queue_len; i++) { // delete top item from queue recv_queue[i] = recv_queue[i + 1];