59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
enum class DeviceRole : uint8_t {
|
|
Sender = 0,
|
|
Receiver = 1
|
|
};
|
|
|
|
enum class PayloadType : uint8_t {
|
|
MeterData = 0,
|
|
TestCode = 1,
|
|
TimeSync = 2
|
|
};
|
|
|
|
constexpr uint8_t PROTOCOL_VERSION = 1;
|
|
|
|
// Pin definitions
|
|
constexpr uint8_t PIN_LORA_SCK = 5;
|
|
constexpr uint8_t PIN_LORA_MISO = 19;
|
|
constexpr uint8_t PIN_LORA_MOSI = 27;
|
|
constexpr uint8_t PIN_LORA_NSS = 18;
|
|
constexpr uint8_t PIN_LORA_RST = 23;
|
|
constexpr uint8_t PIN_LORA_DIO0 = 26;
|
|
|
|
constexpr uint8_t PIN_OLED_SDA = 21;
|
|
constexpr uint8_t PIN_OLED_SCL = 22;
|
|
constexpr uint8_t PIN_OLED_RST = 16;
|
|
constexpr uint8_t OLED_I2C_ADDR = 0x3C;
|
|
constexpr uint8_t OLED_WIDTH = 128;
|
|
constexpr uint8_t OLED_HEIGHT = 64;
|
|
|
|
constexpr uint8_t PIN_BAT_ADC = 35;
|
|
|
|
constexpr uint8_t PIN_ROLE = 13;
|
|
constexpr uint8_t PIN_OLED_CTRL = 14;
|
|
|
|
constexpr uint8_t PIN_METER_RX = 34;
|
|
|
|
// LoRa settings
|
|
constexpr long LORA_FREQUENCY = 433E6;
|
|
constexpr uint8_t LORA_SPREADING_FACTOR = 12;
|
|
constexpr long LORA_BANDWIDTH = 125E3;
|
|
constexpr uint8_t LORA_CODING_RATE = 5;
|
|
constexpr uint8_t LORA_SYNC_WORD = 0x34;
|
|
|
|
// Timing
|
|
constexpr uint32_t SENDER_WAKE_INTERVAL_SEC = 30;
|
|
constexpr uint32_t TIME_SYNC_INTERVAL_SEC = 60;
|
|
constexpr uint32_t OLED_PAGE_INTERVAL_MS = 10000;
|
|
constexpr uint32_t OLED_AUTO_OFF_MS = 10UL * 60UL * 1000UL;
|
|
|
|
constexpr uint8_t NUM_SENDERS = 1;
|
|
inline constexpr uint16_t EXPECTED_SENDER_IDS[NUM_SENDERS] = {
|
|
0xF19C
|
|
};
|
|
|
|
DeviceRole detect_role();
|