target.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. T1Board 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. MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock, GPS_RESET, GPS_EN, &board.periph_power);
  18. EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
  19. #else
  20. EnvironmentSensorManager sensors;
  21. #endif
  22. #ifdef DISPLAY_CLASS
  23. DISPLAY_CLASS display(&board.periph_power);
  24. MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
  25. #endif
  26. bool radio_init() {
  27. rtc_clock.begin(Wire);
  28. #if defined(P_LORA_SCLK)
  29. return radio.std_init(&SPI);
  30. #else
  31. return radio.std_init();
  32. #endif
  33. }
  34. mesh::LocalIdentity radio_new_identity() {
  35. RadioNoiseListener rng(radio);
  36. return mesh::LocalIdentity(&rng);
  37. }