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

This commit is contained in:
geeksville
2020-06-03 13:46:31 -07:00
parent a34cfb0ee0
commit 5b1488ddf0
6 changed files with 15 additions and 7 deletions

View File

@@ -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;
}