Add SetHardware sub-commands so a host can probe and configure per-board RF front-end settings: - GetCapabilities (0x1B): uint32 feature bits (AGC, FEM RX, FEM TX) - Set/GetAgcResetInterval (0x1C/0x1D): 0-1020 s, 4 s resolution, 0 disables; default stays 30 s - Set/GetFemState (0x1E/0x1F): apply/value masks for FEM RX (LNA) and TX (PA) gain; all-or-nothing, Unsupported (0x08) if any requested bit is not controllable on this board The AGC scheduler moves from main.cpp into KissModem so it is configurable and unit-tested. FEM changes that arrive mid-TX are deferred until the packet ends, since board setters drive FEM pins directly. MainBoard gains virtual FEM hooks (canControl/set/is for LNA and PA gain). Boards that already implemented these methods privately now expose them as overrides: Heltec V4, V4 R8, T096, Tracker V2, Station G3 and Wio Tracker L1 1W. KISS_FIRMWARE_VERSION bumped to 2.
68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include <helpers/ESP32Board.h>
|
|
#include <driver/rtc_io.h>
|
|
#include "LoRaFEMControl.h"
|
|
|
|
class StationG3Board : public ESP32Board {
|
|
KeyValueStore* _prefs = NULL;
|
|
|
|
public:
|
|
LoRaFEMControl loRaFEMControl;
|
|
|
|
void begin() {
|
|
ESP32Board::begin();
|
|
loRaFEMControl.init();
|
|
|
|
esp_reset_reason_t reason = esp_reset_reason();
|
|
if (reason == ESP_RST_DEEPSLEEP) {
|
|
uint64_t wakeup_source = esp_sleep_get_ext1_wakeup_status();
|
|
if (wakeup_source & (1ULL << P_LORA_DIO_1)) {
|
|
startup_reason = BD_STARTUP_RX_PACKET;
|
|
}
|
|
|
|
rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS);
|
|
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1);
|
|
}
|
|
}
|
|
|
|
void attachDynamicPrefs(KeyValueStore* prefs);
|
|
|
|
bool handleCommand(const char* command, uint32_t sender_timestamp, char* reply) override;
|
|
bool canControlLoRaFemLna() const override { return loRaFEMControl.canControlLNA(); }
|
|
bool setLoRaFemLnaEnabled(bool enable) override;
|
|
bool isLoRaFemLnaEnabled() const override;
|
|
bool canControlLoRaFemPaGain() const override { return loRaFEMControl.canControlPAGain(); }
|
|
bool setLoRaFemPaGainEnabled(bool enable) override;
|
|
bool isLoRaFemPaGainEnabled() const override;
|
|
|
|
void setPrimaryLNAEnable(bool enabled) {
|
|
loRaFEMControl.setLNAEnable(enabled);
|
|
}
|
|
|
|
void setPrimaryPAHighPower(bool enabled) {
|
|
loRaFEMControl.setPAGainEnable(enabled);
|
|
}
|
|
|
|
void onBeforeTransmit() override {
|
|
ESP32Board::onBeforeTransmit();
|
|
loRaFEMControl.setTxModeEnable();
|
|
}
|
|
|
|
void onAfterTransmit() override {
|
|
ESP32Board::onAfterTransmit();
|
|
loRaFEMControl.setRxModeEnable();
|
|
}
|
|
|
|
void powerOff() override;
|
|
|
|
uint16_t getBattMilliVolts() override {
|
|
return 0;
|
|
}
|
|
|
|
const char* getManufacturerName() const override {
|
|
return "Station G3 ESP32";
|
|
}
|
|
};
|