mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
sensecap_indicator: initial espnow support
This commit is contained in:
parent
5ae574b426
commit
45ab0e8cf7
6 changed files with 433 additions and 0 deletions
56
variants/sensecap_indicator-espnow/target.cpp
Normal file
56
variants/sensecap_indicator-espnow/target.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
|
||||
ESP32Board board;
|
||||
|
||||
ESPNOWRadio radio_driver;
|
||||
|
||||
ESP32RTCClock rtc_clock;
|
||||
#if defined(ENV_INCLUDE_GPS)
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, (mesh::RTCClock*)&rtc_clock);
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||
#else
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager();
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#ifdef PIN_USER_BTN
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
rtc_clock.begin();
|
||||
|
||||
radio_driver.init();
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
void radio_set_tx_power(uint8_t dbm) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
ESP_RNG rng;
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue