lorawan icon indicating copy to clipboard operation
lorawan copied to clipboard

Refactor all frequencies from MHz (double) to Hz (uint32_t)

Open non-det-alle opened this issue 4 months ago • 2 comments

In the LoRaWAN MAC protocol specifications, in the LoRa devices PHY hardware abstraction layer libraries, in the gateways' packet forwarder protocol code and in the network server configurations and internal representation, frequency values are encoded using 4 bytes (and in Hz). However, the module currently uses MHz values in floating point form to represent frequencies.

Aligning with real implementations slightly simplifies encoding and prevent floating point arithmetic issues. From personal experience, I once got a bug because multiplying frequency * 0.01 instead of frequency / 100 returned a .99999999-like value, and as a consequence all comparisons to retrieve the correct LogicalLoraChannel object yielded false.

This PR converts the type of frequency values used throughout the module from double to uint32_t, and it appends Hz to names of class members and function signature parameters representing frequencies (i.e. ending up in the API documentation).

This PR is an effort to break #135 into more digestible pieces.

non-det-alle avatar Oct 21 '24 12:10 non-det-alle