fixed serial output for NeighborInfo

additional small cosmetics
This commit is contained in:
tuxphone 2024-05-31 22:52:42 +02:00
parent 5e743cd1f0
commit 23f3ff0392
2 changed files with 34 additions and 23 deletions

View File

@ -464,10 +464,11 @@ void printVariants(void){
MSG("*** Error ***\n\r");
return;
}
MSG("(last sent by 0x%x) Number of neighbors=%d\n\r", np.last_sent_by_id, np.neighbors_count);
MSG("(last sent by %8X) Number of neighbors=%d\n\r", np.last_sent_by_id, np.neighbors_count);
for (uint8_t i = 0; i < np.neighbors_count; i++) {
MSG("[0x%X, ", np.neighbors[i].node_id);
MSGFLOAT("snr=%.2f]\n\r", np.neighbors[i].snr);
MSG("[%8X, ", np.neighbors[i].node_id);
MSGFLOAT("snr=", np.neighbors[i].snr);
MSG("]\n\r");
}
return;
}
@ -516,7 +517,7 @@ bool PacketQueueClass::pop(void) {
if (this->Count == 0) return false;
uint8_t idx = MAX_TX_QUEUE;
for (uint8_t i=0 ;i < (MAX_TX_QUEUE -1); i++ ){
if (Queue[i].size != 0) { // first not empty entry
if (this->Queue[i].size != 0) { // first not empty entry
idx = i;
break;
}
@ -526,12 +527,14 @@ bool PacketQueueClass::pop(void) {
return false;
}
for (uint8_t i=idx; i<(MAX_TX_QUEUE -1); i++) {
if ( (Queue[i].size != 0) && (Queue[idx].packetTime < Queue[i].packetTime) ) idx = i; // find oldest packet
if ( (this->Queue[i].size != 0) && (this->Queue[idx].packetTime < this->Queue[i].packetTime) ) {
idx = i; // find oldest packet
}
}
PacketToSend.packetTime = millis(); // start timer. after 1 minute, drop packet
PacketToSend.size = Queue[idx].size;
memcpy(PacketToSend.buf, Queue[idx].buf, Queue[idx].size);
Queue[idx].size = 0;
PacketToSend.size = this->Queue[idx].size;
memcpy(PacketToSend.buf, this->Queue[idx].buf, this->Queue[idx].size);
this->Queue[idx].size = 0;
this->Count -= 1;
return true;
}
@ -539,8 +542,10 @@ bool PacketQueueClass::pop(void) {
void PacketQueueClass::clear(void) {
for (uint8_t i = 0; i<(MAX_TX_QUEUE - 1); i++) {
this->Queue[i].size = 0; // mark as "deleted"
this->Count = 0;
this->Queue[i].packetTime = 0;
memset(this->Queue[i].buf, 0, sizeof(this->Queue[i].buf));
}
this->Count = 0;
}
// idStoreClass Definitions

View File

@ -16,10 +16,9 @@
#define CC_MAX_POWER 22 // TX power setting. Absolute Max for CubeCell is 22, enforced by RadioLib.
#define MAX_ID_LIST 64 // number of stored packet IDs to prevent unnecesary repeating
#define MAX_NODE_LIST 20 // number of stored known nodes
#define MAX_TX_QUEUE 8 // max number of packets which can be waiting for transmission
#define MAX_RHPACKETLEN 256
#define MAX_ID_LIST 64 // number of stored packet IDs to prevent unnecesary repeating
#define MAX_NODE_LIST 20 // number of stored known nodes
#define MAX_TX_QUEUE 8 // max number of packets which can be waiting for transmission
/// 16 bytes of random PSK for our _public_ default channel that all devices power up on (AES128)
/// Meshtastic default key (AQ==):
@ -35,6 +34,17 @@ static const uint8_t mypsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59,
#define MSGFLOAT(a,b)
#endif
#define PACKET_FLAGS_HOP_LIMIT_MASK 0x07
#define PACKET_FLAGS_WANT_ACK_MASK 0x08
#define PACKET_FLAGS_VIA_MQTT_MASK 0x10
#define PACKET_FLAGS_HOP_START_MASK 0xE0
#define PACKET_FLAGS_HOP_START_SHIFT 5
#include <RadioLib.h>
/**************/
#ifdef CUBECELL
// Heltec borked the Arduino.h
#ifdef __cplusplus
#undef min
@ -46,19 +56,12 @@ static const uint8_t mypsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59,
using std::min;
#endif /* __cplusplus */
#define PACKET_FLAGS_HOP_LIMIT_MASK 0x07
#define PACKET_FLAGS_WANT_ACK_MASK 0x08
#define PACKET_FLAGS_VIA_MQTT_MASK 0x10
#define PACKET_FLAGS_HOP_START_MASK 0xE0
#define PACKET_FLAGS_HOP_START_SHIFT 5
#include <RadioLib.h>
#ifdef CUBECELL
#include "cyPm.c" // for reliable sleep we use MCU_deepSleep()
extern uint32_t systime; // CubeCell global system time count, Millis
SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
#endif
#endif // CUBECELL
/****************/
#include <assert.h>
#include <pb.h>
@ -72,6 +75,9 @@ extern "C"
#include <mesh/compression/unishox2.h>
}
*/
#define MAX_RHPACKETLEN 256
// struct to store the raw packet data (buf, size) and the time of receiving
typedef struct {
size_t size;