target.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #define RADIOLIB_STATIC_ONLY 1
  3. #include <RadioLib.h>
  4. #include <helpers/RadioLibWrappers.h>
  5. #include <RAK4631Board.h>
  6. #include <helpers/CustomSX1262Wrapper.h>
  7. #include <helpers/AutoDiscoverRTCClock.h>
  8. #include <helpers/SensorManager.h>
  9. #if ENV_INCLUDE_GPS
  10. #include <helpers/sensors/LocationProvider.h>
  11. #include <SparkFun_u-blox_GNSS_Arduino_Library.h>
  12. #endif
  13. #ifdef DISPLAY_CLASS
  14. #include <helpers/ui/SSD1306Display.h>
  15. #endif
  16. #define _BV(x) (1 << x)
  17. class RAK4631SensorManager: public SensorManager {
  18. #if ENV_INCLUDE_GPS
  19. bool gps_active = false;
  20. bool gps_detected = false;
  21. LocationProvider * _nmea;
  22. SFE_UBLOX_GNSS ublox_GNSS;
  23. uint32_t disStandbyPin = 0;
  24. void start_gps();
  25. void stop_gps();
  26. void sleep_gps();
  27. void wake_gps();
  28. bool gpsIsAwake(uint32_t ioPin);
  29. #endif
  30. #if ENV_INCLUDE_BME680
  31. bool bme680_active = false;
  32. bool bme680_present = false;
  33. #define SAMPLING_RATE BSEC_SAMPLE_RATE_ULP
  34. #endif
  35. public:
  36. #if ENV_INCLUDE_GPS
  37. RAK4631SensorManager(LocationProvider &nmea): _nmea(&nmea) { }
  38. #else
  39. RAK4631SensorManager() { }
  40. #endif
  41. void loop() override;
  42. bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
  43. int getNumSettings() const override;
  44. const char* getSettingName(int i) const override;
  45. const char* getSettingValue(int i) const override;
  46. bool setSettingValue(const char* name, const char* value) override;
  47. bool begin() override;
  48. };
  49. extern RAK4631Board board;
  50. extern WRAPPER_CLASS radio_driver;
  51. extern AutoDiscoverRTCClock rtc_clock;
  52. extern RAK4631SensorManager sensors;
  53. #ifdef DISPLAY_CLASS
  54. extern DISPLAY_CLASS display;
  55. #endif
  56. enum {
  57. POWERMANAGE_ONLINE = _BV(0),
  58. DISPLAY_ONLINE = _BV(1),
  59. RADIO_ONLINE = _BV(2),
  60. GPS_ONLINE = _BV(3),
  61. PSRAM_ONLINE = _BV(4),
  62. SDCARD_ONLINE = _BV(5),
  63. AXDL345_ONLINE = _BV(6),
  64. BME280_ONLINE = _BV(7),
  65. BMP280_ONLINE = _BV(8),
  66. BME680_ONLINE = _BV(9),
  67. QMC6310_ONLINE = _BV(10),
  68. QMI8658_ONLINE = _BV(11),
  69. PCF8563_ONLINE = _BV(12),
  70. OSC32768_ONLINE = _BV(13),
  71. RAK12500_ONLINE = _BV(14),
  72. };
  73. bool radio_init();
  74. uint32_t radio_get_rng_seed();
  75. void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
  76. void radio_set_tx_power(uint8_t dbm);
  77. mesh::LocalIdentity radio_new_identity();