Files
MeshCore-Solo/variants/generic_espnow/target.cpp
T

45 lines
984 B
C++
Raw Normal View History

2025-03-27 19:34:16 +11:00
#include <Arduino.h>
#include "target.h"
#include <helpers/ArduinoHelpers.h>
ESP32Board board;
ESPNOWRadio radio_driver;
ESP32RTCClock rtc_clock;
2025-05-03 13:14:03 +10:00
SensorManager sensors;
2025-03-27 19:34:16 +11:00
bool radio_init() {
rtc_clock.begin();
radio_driver.init();
2025-03-27 19:34:16 +11:00
return true; // success
}
uint32_t radio_get_rng_seed() {
return millis() + radio_driver.intID(); // TODO: where to get some entropy?
}
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
// no-op
}
2026-01-03 20:35:14 +01:00
void radio_set_tx_power(int8_t dbm) {
2025-03-27 19:34:16 +11:00
radio_driver.setTxPower(dbm);
}
// NOTE: as we are using the WiFi radio, the ESP_IDF will have enabled hardware RNG:
// https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/random.html
class ESP_RNG : public mesh::RNG {
public:
void random(uint8_t* dest, size_t sz) override {
esp_fill_random(dest, sz);
}
};
2025-03-27 19:34:16 +11:00
mesh::LocalIdentity radio_new_identity() {
ESP_RNG rng;
2025-03-27 19:34:16 +11:00
return mesh::LocalIdentity(&rng); // create new random identity
}