#pragma once #include #include namespace roro::meshtastic { // Radio settings shared by every Meshtastic preset (firmware src/mesh/RadioInterface.h). constexpr uint8_t kSyncWord = 0x2B; constexpr uint16_t kPreambleLength = 16; // The default Channel key ("AQ==", expanded): public, so the default Channel is readable by anyone. extern const uint8_t kDefaultKey[16]; // A modem preset: bandwidth, spreading factor and coding rate (4/cr). Named as Meshtastic shows them. struct Preset { const char* name; float bwKHz; uint8_t sf; uint8_t cr; }; // The presets Meshtastic allows in EU_868, its order, LongFast (the default) first. extern const Preset kEu868Presets[]; extern const size_t kEu868PresetCount; const Preset* findPreset(const char* name); // nullptr when EU_868 doesn't allow it // djb2, as Meshtastic hashes a Channel's name to pick a frequency slot. uint32_t djb2(const char* s); // The byte in every packet header naming its Channel: the name's bytes XORed with the key's. uint8_t channelHash(const char* name, const uint8_t* key, size_t keyLen); // EU_868 is 869.4 to 869.65 MHz: the slot comes from the Channel's name (the preset's name for // an unnamed Channel, which is the default). uint32_t eu868FrequencyHz(const Preset& preset, const char* channelName = nullptr); } // namespace roro::meshtastic