fixed serial output for NeighborInfo
additional small cosmetics
This commit is contained in:
parent
5e743cd1f0
commit
23f3ff0392
23
src/main.cpp
23
src/main.cpp
|
@ -464,10 +464,11 @@ void printVariants(void){
|
||||||
MSG("*** Error ***\n\r");
|
MSG("*** Error ***\n\r");
|
||||||
return;
|
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++) {
|
for (uint8_t i = 0; i < np.neighbors_count; i++) {
|
||||||
MSG("[0x%X, ", np.neighbors[i].node_id);
|
MSG("[%8X, ", np.neighbors[i].node_id);
|
||||||
MSGFLOAT("snr=%.2f]\n\r", np.neighbors[i].snr);
|
MSGFLOAT("snr=", np.neighbors[i].snr);
|
||||||
|
MSG("]\n\r");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -516,7 +517,7 @@ bool PacketQueueClass::pop(void) {
|
||||||
if (this->Count == 0) return false;
|
if (this->Count == 0) return false;
|
||||||
uint8_t idx = MAX_TX_QUEUE;
|
uint8_t idx = MAX_TX_QUEUE;
|
||||||
for (uint8_t i=0 ;i < (MAX_TX_QUEUE -1); i++ ){
|
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;
|
idx = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -526,12 +527,14 @@ bool PacketQueueClass::pop(void) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (uint8_t i=idx; i<(MAX_TX_QUEUE -1); i++) {
|
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.packetTime = millis(); // start timer. after 1 minute, drop packet
|
||||||
PacketToSend.size = Queue[idx].size;
|
PacketToSend.size = this->Queue[idx].size;
|
||||||
memcpy(PacketToSend.buf, Queue[idx].buf, Queue[idx].size);
|
memcpy(PacketToSend.buf, this->Queue[idx].buf, this->Queue[idx].size);
|
||||||
Queue[idx].size = 0;
|
this->Queue[idx].size = 0;
|
||||||
this->Count -= 1;
|
this->Count -= 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -539,8 +542,10 @@ bool PacketQueueClass::pop(void) {
|
||||||
void PacketQueueClass::clear(void) {
|
void PacketQueueClass::clear(void) {
|
||||||
for (uint8_t i = 0; i<(MAX_TX_QUEUE - 1); i++) {
|
for (uint8_t i = 0; i<(MAX_TX_QUEUE - 1); i++) {
|
||||||
this->Queue[i].size = 0; // mark as "deleted"
|
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
|
// idStoreClass Definitions
|
||||||
|
|
34
src/main.h
34
src/main.h
|
@ -16,10 +16,9 @@
|
||||||
|
|
||||||
#define CC_MAX_POWER 22 // TX power setting. Absolute Max for CubeCell is 22, enforced by RadioLib.
|
#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_ID_LIST 64 // number of stored packet IDs to prevent unnecesary repeating
|
||||||
#define MAX_NODE_LIST 20 // number of stored known nodes
|
#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_TX_QUEUE 8 // max number of packets which can be waiting for transmission
|
||||||
#define MAX_RHPACKETLEN 256
|
|
||||||
|
|
||||||
/// 16 bytes of random PSK for our _public_ default channel that all devices power up on (AES128)
|
/// 16 bytes of random PSK for our _public_ default channel that all devices power up on (AES128)
|
||||||
/// Meshtastic default key (AQ==):
|
/// 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)
|
#define MSGFLOAT(a,b)
|
||||||
#endif
|
#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
|
// Heltec borked the Arduino.h
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#undef min
|
#undef min
|
||||||
|
@ -46,19 +56,12 @@ static const uint8_t mypsk[] = {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59,
|
||||||
using std::min;
|
using std::min;
|
||||||
#endif /* __cplusplus */
|
#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()
|
#include "cyPm.c" // for reliable sleep we use MCU_deepSleep()
|
||||||
extern uint32_t systime; // CubeCell global system time count, Millis
|
extern uint32_t systime; // CubeCell global system time count, Millis
|
||||||
SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
|
||||||
#endif
|
|
||||||
|
#endif // CUBECELL
|
||||||
|
/****************/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <pb.h>
|
#include <pb.h>
|
||||||
|
@ -72,6 +75,9 @@ extern "C"
|
||||||
#include <mesh/compression/unishox2.h>
|
#include <mesh/compression/unishox2.h>
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define MAX_RHPACKETLEN 256
|
||||||
|
|
||||||
// struct to store the raw packet data (buf, size) and the time of receiving
|
// struct to store the raw packet data (buf, size) and the time of receiving
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
Loading…
Reference in New Issue