target.cpp 713 B

1234567891011121314151617181920212223242526272829303132
  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. SensorManager sensors;
  8. bool radio_init() {
  9. rtc_clock.begin();
  10. radio_driver.init();
  11. return true; // success
  12. }
  13. // NOTE: as we are using the WiFi radio, the ESP_IDF will have enabled hardware RNG:
  14. // https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/random.html
  15. class ESP_RNG : public mesh::RNG {
  16. public:
  17. void random(uint8_t* dest, size_t sz) override {
  18. esp_fill_random(dest, sz);
  19. }
  20. };
  21. mesh::LocalIdentity radio_new_identity() {
  22. ESP_RNG rng;
  23. return mesh::LocalIdentity(&rng); // create new random identity
  24. }