Allow packet and nodenums to be 32 bits long (but don't change yet)

1.2-legacy
geeksville 2020-06-03 13:46:31 -07:00
rodzic a34cfb0ee0
commit 5b1488ddf0
6 zmienionych plików z 15 dodań i 7 usunięć

Wyświetl plik

@ -31,6 +31,9 @@ dsr tasks
optimizations / low priority:
- read @cyclomies long email with good ideas on optimizations and reply
- Remove NodeNum assignment algorithm (now that we use 4 byte node nums)
- make android app warn if firmware is too old or too new to talk to
- change nodenums and packetids in protobuf to be fixed32
- low priority: think more careful about reliable retransmit intervals
- make ReliableRouter.pending threadsafe
- bump up PacketPool size for all the new ack/nak/routing packets

Wyświetl plik

@ -9,7 +9,7 @@
typedef uint8_t NodeNum;
typedef uint8_t PacketId; // A packet sequence number
#define NODENUM_BROADCAST 255
#define NODENUM_BROADCAST (sizeof(NodeNum) == 4 ? UINT32_MAX : UINT8_MAX)
#define ERRNO_OK 0
#define ERRNO_NO_INTERFACES 33
#define ERRNO_UNKNOWN 32 // pick something that doesn't conflict with RH_ROUTER_ERROR_UNABLE_TO_DELIVER

Wyświetl plik

@ -178,8 +178,10 @@ void NodeDB::init()
*/
void NodeDB::pickNewNodeNum()
{
// FIXME not the right way to guess node numes
uint8_t r = ourMacAddr[5];
// Pick an initial nodenum based on the macaddr
NodeNum r = sizeof(NodeNum) == 1 ? ourMacAddr[5]
: ((ourMacAddr[2] << 24) | (ourMacAddr[3] << 16) | (ourMacAddr[4] << 8) | ourMacAddr[5]);
if (r == 0xff || r < NUM_RESERVED)
r = NUM_RESERVED; // don't pick a reserved node number

Wyświetl plik

@ -26,7 +26,7 @@ separated by 2.16 MHz with respect to the adjacent channels. Channel zero starts
RadioInterface::RadioInterface() : txQueue(MAX_TX_QUEUE)
{
assert(sizeof(PacketHeader) == 4); // make sure the compiler did what we expected
assert(sizeof(PacketHeader) == 4 || sizeof(PacketHeader) == 16); // make sure the compiler did what we expected
myNodeInfo.num_channels = NUM_CHANNELS;

Wyświetl plik

@ -19,7 +19,9 @@
* wtih the old radiohead implementation.
*/
typedef struct {
uint8_t to, from, id;
NodeNum to, from; // can be 1 byte or four bytes
PacketId id; // can be 1 byte or 4 bytes
/**
* Usage of flags:

Wyświetl plik

@ -51,7 +51,8 @@ PacketId generatePacketId()
static uint32_t i; // Note: trying to keep this in noinit didn't help for working across reboots
static bool didInit = false;
uint32_t numPacketId = 255; // 0 is consider invalid
assert(sizeof(PacketId) == 4 || sizeof(PacketId) == 1); // only supported values
uint32_t numPacketId = sizeof(PacketId) == 1 ? UINT8_MAX : UINT32_MAX; // 0 is consider invalid
if (!didInit) {
didInit = true;
@ -60,7 +61,7 @@ PacketId generatePacketId()
}
i++;
PacketId id = (i % numPacketId) + 1; // return number between 1 and 255 (ie - never zero)
PacketId id = (i % numPacketId) + 1; // return number between 1 and numPacketId (ie - never zero)
myNodeInfo.current_packet_id = id; // Kinda crufty - we keep updating this so the phone can see a current value
return id;
}