quec_gnss_handle.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. 
  2. /*================================================================
  3. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  4. Quectel Wireless Solutions Proprietary and Confidential.
  5. =================================================================*/
  6. /**
  7. ******************************************************************************
  8. * @file quec_gnss_handle.h
  9. * @author lambert.zhao
  10. * @version V1.0.0
  11. * @date 2020/11/25
  12. * @brief This file contains the quec_gnss_handle functions's declaration
  13. ******************************************************************************
  14. */
  15. #ifndef QUEC_GNSS_HANDLE_H_
  16. #define QUEC_GNSS_HANDLE_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #include "quec_proj_config.h"
  21. #include "ql_api_osi.h"
  22. #include "ql_gnss.h"
  23. #include "at_engine.h"
  24. /*===========================================================================
  25. * Macro Definition
  26. ===========================================================================*/
  27. #define QUEC_GNSS_LOCK_TIMEOUT 10000 //10sec
  28. #define QUEC_GNSS_PAM_API_PASS 1 //pam.h api函数返回值,执行成功则返回 1
  29. /*===========================================================================
  30. * Typedef
  31. ===========================================================================*/
  32. /*===========================================================================
  33. * Enum
  34. ===========================================================================*/
  35. typedef enum
  36. {
  37. QUEC_GNSS_PAM_PARAM_HOT = 0, //热启动 对应 unisoc api参数
  38. QUEC_GNSS_PAM_PARAM_COLD, //冷启动
  39. QUEC_GNSS_PAM_PARAM_WARM, //温启动
  40. QUEC_GNSS_PAM_PARAM_FACTORY, //工厂模式,不依赖任何辅助定位数据
  41. QUEC_GNSS_PAM_PARAM_MAX
  42. }quec_gnss_pam_startmode_e;
  43. typedef enum
  44. {
  45. QUEC_AGPS_STATE_START_IND = 0, //开始AGPS(开始注册网络)
  46. QUEC_AGPS_STATE_REG_NW_IND, //已经注网通知
  47. QUEC_AGPS_STATE_DATACALL_IND, //已经datacall拨号通知
  48. QUEC_AGPS_STATE_MAX
  49. }quec_gnss_agps_state_e;
  50. #ifdef CONFIG_QUEC_PROJECT_FEATURE_HD_GNSS
  51. typedef enum
  52. {
  53. QUEC_HD_GNSS_POWER_EVENT_REQ= 4|(QL_COMPONENT_BSP_GNSS<<16),
  54. QUEC_HD_GNSS_ENABLE_IND= 5|(QL_COMPONENT_BSP_GNSS<<16),
  55. QUEC_HD_GNSS_DISABLE_IND= 6|(QL_COMPONENT_BSP_GNSS<<16)
  56. }ql_hd_gnss_event_id_e;
  57. #endif
  58. /*===========================================================================
  59. * data struct
  60. ===========================================================================*/
  61. typedef struct
  62. {
  63. bool bFirstOpenGnss;
  64. bool bNeedUpdatefirm;
  65. bool bHslRetryProcess;
  66. bool bGnssResume;
  67. bool bGnsslocTimer;
  68. uint8_t simid;
  69. uint8_t start_mode;
  70. uint8_t satellite_type;
  71. uint8_t coexist_lte_gnss;
  72. uint16_t gnss_sleep;
  73. uint16_t lte_sleep;
  74. uint16_t output_format;
  75. uint32_t time_interval;
  76. uint32_t fixcount;
  77. }quec_gnss_loc_t;
  78. typedef struct
  79. {
  80. ql_GnssState gnss_state;
  81. quec_gnss_loc_t loc;
  82. ql_gnss_coexist_callback gnss_cb;
  83. ql_mutex_t lock;
  84. bool gnss_firmware_update_success;
  85. bool gnss_first_open_success;
  86. }quec_gnss_op_info_t;
  87. typedef struct
  88. {
  89. uint8_t priority; //lte gnss coexist priority
  90. }quec_coexist_cfg_t;
  91. typedef struct
  92. {
  93. quec_gps_config confg;
  94. loc_calendar_time_s_type time;
  95. unsigned char start_type;
  96. nmeasrc_sentences_cfg nmea_handle_cfg;
  97. quec_gps_outport_config outport;
  98. bool gpsautoflag;
  99. quec_agps_cfg_t agps;
  100. quec_coexist_cfg_t coexist_cfg;
  101. char device_information[100];
  102. uint8_t simid;
  103. ql_mutex_t lock;
  104. ql_gnss_callback_ex callback;
  105. }quec_gps_handle; //此结构体中成员可以任意添加存储
  106. #ifndef CONFIG_QL_OPEN_EXPORT_PKG
  107. typedef struct
  108. {
  109. bool is_at; //at回复flag
  110. ql_dispatch_t *engine; //at回复的dispatch
  111. ql_mutex_t lock;
  112. }quec_gnss_at_resp_t;
  113. #endif
  114. /*===========================================================================
  115. * Functions declaration
  116. ===========================================================================*/
  117. //gnss共用API
  118. int quec_gnss_param_lock(ql_mutex_t mutexRef);
  119. int quec_gnss_param_unlock(ql_mutex_t mutexRef);
  120. void quec_gnss_notify_cb(const ql_event_t *event);
  121. int gpsautocheck(void);
  122. void quec_gnss_power_onff(bool status);
  123. int quec_gps_handle_set(void);
  124. int quec_gps_handle_get(void);
  125. struct nmea_s* nmea_parse(char *sentence, int length, int check_checksum);
  126. int nmea_value_update(struct nmea_s *nmea, ql_gnss_data_t *gps_data);
  127. int ql_get_gnss_info(ql_gnss_data_t *data);
  128. char *strptime(const char *buf, const char *fmt, struct tm *tm);
  129. void nmea_write_pqgsv_addsystemid(unsigned char * nmea_sentence,int len);
  130. //DG芯片内置的相关API
  131. extern quec_gps_handle quec_gps_config_param;
  132. extern quec_gnss_op_info_t gnss_operation_param;
  133. int quec_gnss_get_version_info(void);
  134. int quec_gnss_restart_req(ql_gnss_startmode_e start_mode);
  135. void quec_gnss_pam_cfw_hsl_abort_ind(const ql_event_t *event); //LTE协议栈通知停止gnss功能
  136. void quec_gnss_pam_cfw_hsl_recovery_ind(const ql_event_t *event); //LTE协议栈通知恢复gnss功能
  137. int ql_gnss_location_info_get(ql_gnss_output_info_ind_t * param);
  138. #ifdef CONFIG_QUEC_PROJECT_FEATURE_GNSS_AT
  139. int quec_gnss_set_at_sync_resp_param(void *ctx);
  140. void quec_gnss_at_resp_timeout_cb(ql_at_cmd_t *cmd);
  141. #endif
  142. //外挂华大GNSS的API
  143. QlOSStatus quec_gnss_init(void);
  144. QlOSStatus quec_gnss_config_init(void);
  145. void quec_hd_gnss_notify_cb(ql_gnss_callback_s *callback_s);
  146. int quec_gps_send_cmd(quec_hd_gnss_cmd cmd,unsigned char *data,int len);
  147. void ql_gnss_nmeatype_cfg(uint32 nmea_type);
  148. QlOSStatus quec_gnss_uart_task_init(void);
  149. QlOSStatus quec_gnss_cmd_task_init(void);
  150. nmea_type nmea_get_type(const char *sentence);
  151. void quec_gnss_baud_set(char id,ql_uart_baud_e baudrate);
  152. ql_errcode_gnss ql_gnss_hal_init(ql_uart_baud_e baudrate);
  153. ql_errcode_gnss ql_gnss_open(void);
  154. ql_errcode_gnss ql_gnss_close(void);
  155. int ql_hd_gnss_location_info_get(ql_uart_port_number_e uart_port,unsigned int len);
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159. #endif /* !QUEC_GNSS_HANDLE_H_ */