You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.4 KiB

4 years ago
4 years ago
4 years ago
  1. /**
  2. * @file TinyGsmGPS.tpp
  3. * @author Volodymyr Shymanskyy
  4. * @license LGPL-3.0
  5. * @copyright Copyright (c) 2016 Volodymyr Shymanskyy
  6. * @date Nov 2016
  7. */
  8. #ifndef SRC_TINYGSMGPS_H_
  9. #define SRC_TINYGSMGPS_H_
  10. #include "TinyGsmCommon.h"
  11. #define TINY_GSM_MODEM_HAS_GPS
  12. template <class modemType>
  13. class TinyGsmGPS {
  14. public:
  15. /*
  16. * GPS/GNSS/GLONASS location functions
  17. */
  18. bool enableGPS() {
  19. return thisModem().enableGPSImpl();
  20. }
  21. bool disableGPS() {
  22. return thisModem().disableGPSImpl();
  23. }
  24. String getGPSraw() {
  25. return thisModem().getGPSrawImpl();
  26. }
  27. bool getGPS(float* lat, float* lon, float* speed = 0, float* alt = 0,
  28. int* vsat = 0, int* usat = 0, float* accuracy = 0, int* year = 0,
  29. int* month = 0, int* day = 0, int* hour = 0, int* minute = 0,
  30. int* second = 0) {
  31. return thisModem().getGPSImpl(lat, lon, speed, alt, vsat, usat, accuracy,
  32. year, month, day, hour, minute, second);
  33. }
  34. bool getGPSTime(int* year, int* month, int* day, int* hour, int* minute,
  35. int* second) {
  36. float lat = 0;
  37. float lon = 0;
  38. return thisModem().getGPSImpl(&lat, &lon, 0, 0, 0, 0, 0, year, month, day,
  39. hour, minute, second);
  40. }
  41. String setGNSSMode(uint8_t mode, bool dpo) {
  42. return thisModem().setGNSSModeImpl(mode, dpo);
  43. }
  44. uint8_t getGNSSMode() {
  45. return thisModem().getGNSSModeImpl();
  46. }
  47. /*
  48. * CRTP Helper
  49. */
  50. protected:
  51. inline const modemType& thisModem() const {
  52. return static_cast<const modemType&>(*this);
  53. }
  54. inline modemType& thisModem() {
  55. return static_cast<modemType&>(*this);
  56. }
  57. /*
  58. * GPS/GNSS/GLONASS location functions
  59. */
  60. bool enableGPSImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED;
  61. bool disableGPSImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED;
  62. String getGPSrawImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED;
  63. bool getGPSImpl(float* lat, float* lon, float* speed = 0, float* alt = 0,
  64. int* vsat = 0, int* usat = 0, float* accuracy = 0,
  65. int* year = 0, int* month = 0, int* day = 0, int* hour = 0,
  66. int* minute = 0,
  67. int* second = 0) TINY_GSM_ATTR_NOT_IMPLEMENTED;
  68. String setGNSSModeImpl(uint8_t mode, bool dpo) TINY_GSM_ATTR_NOT_IMPLEMENTED;
  69. uint8_t getGNSSModeImpl() TINY_GSM_ATTR_NOT_IMPLEMENTED;
  70. };
  71. #endif // SRC_TINYGSMGPS_H_