things4u / ESP-1ch-Gateway

Version 6 of the single channel gateway
MIT License
364 stars 147 forks source link

Fixed integer frequency to string, without using float #100

Open tfuk opened 2 years ago

tfuk commented 2 years ago

I was getting a invalid frequency over the json sent. This is due to using float to convert the Hz integer to Mhz string to be sent out. But floats, even double precision, aren't accurate and it is not necessary to use it when you already has the full information in the integer and only needs to do fixed point conversion, as the float conversion can lead to approximations and loose the accuracy. Before i wasn't able to connect to chirpstack network server, but now it works fine.