From 9a18f98948d0aadf2a634ea73076d723d3d38691 Mon Sep 17 00:00:00 2001 From: geeksville Date: Tue, 15 Sep 2020 17:08:16 -0700 Subject: [PATCH] document the channel name -> channel number hash algorithm --- mesh.proto | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mesh.proto b/mesh.proto index 965104c..f419106 100644 --- a/mesh.proto +++ b/mesh.proto @@ -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;