* companion radio: new RESP_CODE_NO_MORE_MESSAGES response
This commit is contained in:
@@ -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_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_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_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
|
// these are _pushed_ to client app at any time
|
||||||
#define PUSH_CODE_ADVERT 0x80
|
#define PUSH_CODE_ADVERT 0x80
|
||||||
@@ -571,7 +572,7 @@ public:
|
|||||||
uint32_t secs;
|
uint32_t secs;
|
||||||
memcpy(&secs, &cmd_frame[1], 4);
|
memcpy(&secs, &cmd_frame[1], 4);
|
||||||
uint32_t curr = getRTCClock()->getCurrentTime();
|
uint32_t curr = getRTCClock()->getCurrentTime();
|
||||||
if (secs > curr) {
|
if (secs >= curr) {
|
||||||
getRTCClock()->setCurrentTime(secs);
|
getRTCClock()->setCurrentTime(secs);
|
||||||
writeOKFrame();
|
writeOKFrame();
|
||||||
} else {
|
} else {
|
||||||
@@ -612,6 +613,9 @@ public:
|
|||||||
int out_len;
|
int out_len;
|
||||||
if ((out_len = getFromOfflineQueue(out_frame)) > 0) {
|
if ((out_len = getFromOfflineQueue(out_frame)) > 0) {
|
||||||
_serial->writeFrame(out_frame, out_len);
|
_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) {
|
} else if (cmd_frame[0] == CMD_SET_RADIO_PARAMS) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ build_flags =
|
|||||||
${Heltec_lora32_v3.build_flags}
|
${Heltec_lora32_v3.build_flags}
|
||||||
-D MAX_CONTACTS=100
|
-D MAX_CONTACTS=100
|
||||||
-D MAX_GROUP_CHANNELS=1
|
-D MAX_GROUP_CHANNELS=1
|
||||||
; -D MESH_PACKET_LOGGING=1
|
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||||
; -D MESH_DEBUG=1
|
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||||
build_src_filter = ${Heltec_lora32_v3.build_src_filter} +<../examples/companion_radio/main.cpp>
|
build_src_filter = ${Heltec_lora32_v3.build_src_filter} +<../examples/companion_radio/main.cpp>
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${Heltec_lora32_v3.lib_deps}
|
${Heltec_lora32_v3.lib_deps}
|
||||||
@@ -303,8 +303,8 @@ build_flags =
|
|||||||
${LilyGo_T3S3_sx1262.build_flags}
|
${LilyGo_T3S3_sx1262.build_flags}
|
||||||
-D MAX_CONTACTS=100
|
-D MAX_CONTACTS=100
|
||||||
-D MAX_GROUP_CHANNELS=1
|
-D MAX_GROUP_CHANNELS=1
|
||||||
; -D MESH_PACKET_LOGGING=1
|
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||||
; -D MESH_DEBUG=1
|
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||||
build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} +<../examples/companion_radio/main.cpp>
|
build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} +<../examples/companion_radio/main.cpp>
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${LilyGo_T3S3_sx1262.lib_deps}
|
${LilyGo_T3S3_sx1262.lib_deps}
|
||||||
@@ -406,8 +406,8 @@ build_flags =
|
|||||||
${rak4631.build_flags}
|
${rak4631.build_flags}
|
||||||
-D MAX_CONTACTS=100
|
-D MAX_CONTACTS=100
|
||||||
-D MAX_GROUP_CHANNELS=1
|
-D MAX_GROUP_CHANNELS=1
|
||||||
; -D MESH_PACKET_LOGGING=1
|
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
|
||||||
; -D MESH_DEBUG=1
|
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
|
||||||
build_src_filter = ${rak4631.build_src_filter} +<../examples/companion_radio/main.cpp>
|
build_src_filter = ${rak4631.build_src_filter} +<../examples/companion_radio/main.cpp>
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${rak4631.lib_deps}
|
${rak4631.lib_deps}
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ ContactsIterator BaseChatMesh::startContactsIterator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ContactsIterator::hasNext(const BaseChatMesh* mesh, ContactInfo& dest) {
|
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++];
|
dest = mesh->contacts[next_idx++];
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ size_t SerialBLEInterface::checkRecvFrame(uint8_t dest[]) {
|
|||||||
pTxCharacteristic->setValue(send_queue[0].buf, send_queue[0].len);
|
pTxCharacteristic->setValue(send_queue[0].buf, send_queue[0].len);
|
||||||
pTxCharacteristic->notify();
|
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--;
|
send_queue_len--;
|
||||||
for (int i = 0; i < send_queue_len; i++) { // delete top item from queue
|
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
|
size_t len = recv_queue[0].len; // take from top of queue
|
||||||
memcpy(dest, recv_queue[0].buf, len);
|
memcpy(dest, recv_queue[0].buf, len);
|
||||||
|
|
||||||
|
BLE_DEBUG_PRINTLN("readBytes: sz=%d, hdr=%d", len, (uint32_t) dest[0]);
|
||||||
|
|
||||||
recv_queue_len--;
|
recv_queue_len--;
|
||||||
for (int i = 0; i < recv_queue_len; i++) { // delete top item from queue
|
for (int i = 0; i < recv_queue_len; i++) { // delete top item from queue
|
||||||
recv_queue[i] = recv_queue[i + 1];
|
recv_queue[i] = recv_queue[i + 1];
|
||||||
|
|||||||
Reference in New Issue
Block a user