target.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <Arduino.h>
  2. #include "target.h"
  3. #include <helpers/ArduinoHelpers.h>
  4. ESP32Board board;
  5. ESPNOWRadio radio_driver;
  6. ESP32RTCClock rtc_clock;
  7. #if defined(ENV_INCLUDE_GPS)
  8. MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, (mesh::RTCClock*)&rtc_clock);
  9. EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
  10. #else
  11. EnvironmentSensorManager sensors = EnvironmentSensorManager();
  12. #endif
  13. #ifdef DISPLAY_CLASS
  14. DISPLAY_CLASS display;
  15. #ifdef PIN_USER_BTN
  16. MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true);
  17. #endif
  18. #endif
  19. bool radio_init() {
  20. rtc_clock.begin();
  21. radio_driver.init();
  22. return true; // success
  23. }
  24. // NOTE: as we are using the WiFi radio, the ESP_IDF will have enabled hardware RNG:
  25. // https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/random.html
  26. class ESP_RNG : public mesh::RNG {
  27. public:
  28. void random(uint8_t* dest, size_t sz) override {
  29. esp_fill_random(dest, sz);
  30. }
  31. };
  32. mesh::LocalIdentity radio_new_identity() {
  33. ESP_RNG rng;
  34. return mesh::LocalIdentity(&rng); // create new random identity
  35. }