document the channel name -> channel number hash algorithm

This commit is contained in:
geeksville 2020-09-15 17:08:16 -07:00
parent ce422b7c44
commit 9a18f98948

View file

@ -430,6 +430,21 @@ message ChannelSettings {
A channel number between 1 and 13 (or whatever the max is in the current
region). If ZERO then the rule is "use the old channel name hash based
algoritm to derive the channel number")
If using the hash algorithm the channel number will be: hash(channel_name) %
NUM_CHANNELS (Where num channels depends on the regulatory region).
NUM_CHANNELS_US is 13, for other values see MeshRadio.h in the device code.
// hash a string into an integer - djb2 by Dan Bernstein. -
// http://www.cse.yorku.ca/~oz/hash.html
unsigned long hash(char *str) {
unsigned long hash = 5381; int c;
while ((c = *str++) != 0)
hash = ((hash << 5) + hash) + (unsigned char) c;
return hash;
}
*/
uint32 channel_num = 9;