target.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <Arduino.h>
  2. #include "target.h"
  3. #include <helpers/ArduinoHelpers.h>
  4. #include <helpers/sensors/MicroNMEALocationProvider.h>
  5. WioTrackerL1Board board;
  6. RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
  7. WRAPPER_CLASS radio_driver(radio, board);
  8. VolatileRTCClock fallback_clock;
  9. AutoDiscoverRTCClock rtc_clock(fallback_clock);
  10. #ifdef ENV_INCLUDE_GPS
  11. MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
  12. EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
  13. #else
  14. EnvironmentSensorManager sensors = EnvironmentSensorManager();
  15. #endif
  16. #ifdef DISPLAY_CLASS
  17. DISPLAY_CLASS display;
  18. MomentaryButton user_btn(PIN_USER_BTN, 1000, true, false, false);
  19. MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false);
  20. MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false);
  21. MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, false);
  22. #endif
  23. bool radio_init() {
  24. rtc_clock.begin(Wire);
  25. return radio.std_init(&SPI);
  26. }
  27. uint32_t radio_get_rng_seed() {
  28. return radio.random(0x7FFFFFFF);
  29. }
  30. void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
  31. radio.setFrequency(freq);
  32. radio.setSpreadingFactor(sf);
  33. radio.setBandwidth(bw);
  34. radio.setCodingRate(cr);
  35. }
  36. void radio_set_tx_power(uint8_t dbm) {
  37. radio.setOutputPower(dbm);
  38. }
  39. mesh::LocalIdentity radio_new_identity() {
  40. RadioNoiseListener rng(radio);
  41. return mesh::LocalIdentity(&rng); // create new random identity
  42. }