target.cpp 1.1 KB

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