target.cpp 959 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <Arduino.h>
  2. #include "target.h"
  3. TDeckBoard board;
  4. #if defined(P_LORA_SCLK)
  5. static SPIClass spi;
  6. RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
  7. #else
  8. RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
  9. #endif
  10. WRAPPER_CLASS radio_driver(radio, board);
  11. ESP32RTCClock fallback_clock;
  12. AutoDiscoverRTCClock rtc_clock(fallback_clock);
  13. MicroNMEALocationProvider gps(Serial1, &rtc_clock);
  14. EnvironmentSensorManager sensors(gps);
  15. #ifdef DISPLAY_CLASS
  16. DISPLAY_CLASS display;
  17. MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
  18. #endif
  19. bool radio_init() {
  20. fallback_clock.begin();
  21. rtc_clock.begin(Wire);
  22. Wire.begin(18, 8);
  23. #if defined(P_LORA_SCLK)
  24. return radio.std_init(&spi);
  25. #else
  26. return radio.std_init();
  27. #endif
  28. }
  29. mesh::LocalIdentity radio_new_identity() {
  30. RadioNoiseListener rng(radio);
  31. return mesh::LocalIdentity(&rng); // create new random identity
  32. }