rjw | 337e59c | 2023-04-12 11:19:39 +0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <string.h> |
| 3 | #include <liblog/lynq_deflog.h> |
| 4 | #include "rtk_fun.h" |
| 5 | #include "liblynq-rtk.h" |
| 6 | |
| 7 | |
| 8 | lynq_rtk_out_result lib_result_cb = NULL; |
| 9 | lynq_rtk_out_result_nmea lib_nmea_cb = NULL; |
| 10 | lynq_rtk_out_debuginfo lib_debuginfo = NULL; |
| 11 | lynq_rtk_out_postdata lib_postdata = NULL; |
| 12 | lynq_rtk_out_basesdkstatus lib_basesdkstatus = NULL; |
| 13 | lynq_rtk_out_status lib_status = NULL; |
| 14 | |
| 15 | |
| 16 | void librtk_out_result(const rtk_result_info * prtk) |
| 17 | { |
| 18 | /*change rtk_result_info into lynq_result_info*/ |
| 19 | if (NULL == prtk) |
| 20 | { |
| 21 | LYERRLOG("result info is NULL return : error"); |
| 22 | return ; |
| 23 | } |
| 24 | lynq_rtk_result_info result_info; |
| 25 | memset(&result_info,0,sizeof(result_info)); |
| 26 | memcpy(&result_info,prtk,sizeof(result_info)); |
| 27 | lib_result_cb(&result_info); |
| 28 | return ; |
| 29 | } |
| 30 | |
| 31 | void librtk_out_result_nmea(const char * strnmea, const int length) |
| 32 | { |
| 33 | lib_nmea_cb(strnmea,length); |
| 34 | return ; |
| 35 | } |
| 36 | |
| 37 | void librtk_out_debuginfo(const char * pBuff, const int length, const int ilevel) |
| 38 | { |
| 39 | lib_debuginfo(pBuff,length,ilevel); |
| 40 | return ; |
| 41 | } |
| 42 | |
| 43 | void librtk_out_postdata(const unsigned char * pBuff, const int length) |
| 44 | { |
| 45 | lib_postdata(pBuff,length); |
| 46 | return ; |
| 47 | } |
| 48 | |
| 49 | void librtk_out_basesdkstatus(const int status) |
| 50 | { |
| 51 | lib_basesdkstatus(status); |
| 52 | return ; |
| 53 | } |
| 54 | |
| 55 | void librtk_out_status(const int status) |
| 56 | { |
| 57 | lib_status(status); |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | |
| 62 | |
| 63 | void lynq_rtk_lib_version(char * version) |
| 64 | { |
| 65 | if (NULL == version) |
| 66 | { |
| 67 | LYERRLOG("incoming version is NULL, error"); |
| 68 | return ; |
| 69 | } |
| 70 | rtk_version(version); |
| 71 | return ; |
| 72 | } |
| 73 | |
| 74 | void lynq_rtk_init() |
| 75 | { |
| 76 | LYINFLOG("lib rtk init"); |
| 77 | rtk_init(); |
| 78 | return ; |
| 79 | } |
| 80 | |
| 81 | void lynq_rtk_set_userinfo(const char *username,const char *pwd) |
| 82 | { |
| 83 | if (NULL == username || NULL == pwd) |
| 84 | { |
| 85 | LYERRLOG("invalid username or pwd incoming ,error"); |
| 86 | return ; |
| 87 | } |
| 88 | rtk_set_UserInfo(username,pwd); |
| 89 | return ; |
| 90 | } |
| 91 | |
| 92 | void lynq_rtk_set_deviceID(const char* device_id) |
| 93 | { |
| 94 | if (NULL == device_id) |
| 95 | { |
| 96 | LYERRLOG("invalid device_id incoming ,error"); |
| 97 | return ; |
| 98 | } |
| 99 | rtk_set_DeviceID(device_id); |
| 100 | return ; |
| 101 | } |
| 102 | |
| 103 | void lynq_rtk_result_cb_reg(lynq_rtk_out_result result_cb) |
| 104 | { |
| 105 | if (NULL == result_cb) |
| 106 | { |
| 107 | LYERRLOG("invalid lynq_rtk_out_result incoming ,error"); |
| 108 | return ; |
| 109 | } |
| 110 | lib_result_cb = result_cb; |
| 111 | rtk_result_cb(librtk_out_result); |
| 112 | return ; |
| 113 | } |
| 114 | |
| 115 | void lynq_rtk_result_nmea_cb_reg(lynq_rtk_out_result_nmea nmea_cb) |
| 116 | { |
| 117 | if (NULL == nmea_cb) |
| 118 | { |
| 119 | LYERRLOG("invalid lynq_rtk_out_result_nmea incoming ,error"); |
| 120 | return ; |
| 121 | } |
| 122 | lib_nmea_cb = nmea_cb; |
| 123 | rtk_result_nmea_cb(librtk_out_result_nmea); |
| 124 | return ; |
| 125 | } |
| 126 | |
| 127 | void lynq_rtk_config_log_reg(lynq_rtk_out_debuginfo pdebuginfo) |
| 128 | { |
| 129 | if (NULL == pdebuginfo) |
| 130 | { |
| 131 | LYERRLOG("invalid lynq_rtk_out_debuginfo incoming ,error"); |
| 132 | return ; |
| 133 | } |
| 134 | lib_debuginfo = pdebuginfo; |
| 135 | rtk_config_log(librtk_out_debuginfo); |
| 136 | return ; |
| 137 | } |
| 138 | |
| 139 | void lynq_rtk_config_post_reg(lynq_rtk_out_postdata ppostdata) |
| 140 | { |
| 141 | if (NULL == ppostdata) |
| 142 | { |
| 143 | LYERRLOG("invalid lynq_rtk_out_postdata incoming ,error"); |
| 144 | return ; |
| 145 | } |
| 146 | lib_debuginfo = ppostdata; |
| 147 | rtk_config_post(librtk_out_debuginfo); |
| 148 | return ; |
| 149 | } |
| 150 | |
| 151 | void lynq_rtk_base_sdkstatus(lynq_rtk_out_basesdkstatus psdkstatus) |
| 152 | { |
| 153 | if (NULL == psdkstatus) |
| 154 | { |
| 155 | LYERRLOG("invalid lynq_rtk_out_basesdkstatus incoming ,error"); |
| 156 | return ; |
| 157 | } |
| 158 | lib_basesdkstatus = psdkstatus; |
| 159 | rtk_base_sdkstatus(librtk_out_basesdkstatus); |
| 160 | return ; |
| 161 | } |
| 162 | |
| 163 | void lynq_rtk_base_status(lynq_rtk_out_status pstatus) |
| 164 | { |
| 165 | if (NULL == pstatus) |
| 166 | { |
| 167 | LYERRLOG("invalid lynq_rtk_out_status incoming ,error"); |
| 168 | return ; |
| 169 | } |
| 170 | lib_status = pstatus; |
| 171 | rtk_status_update(librtk_out_status); |
| 172 | return ; |
| 173 | } |
| 174 | |
| 175 | void lynq_rtk_rove_addnmea(const unsigned char * pBuff, const int iBuffLen) |
| 176 | { |
| 177 | rtk_rove_addnmea(pBuff,iBuffLen); |
| 178 | return ; |
| 179 | } |
| 180 | |
| 181 | void lynq_rtk_rove_addrawmess(GnssData_ext* data) |
| 182 | { |
| 183 | rtk_rove_addrawmess(data); |
| 184 | return ; |
| 185 | } |
| 186 | |
| 187 | void lynq_rtk_setserverIP(const char* server_ip) |
| 188 | { |
| 189 | rtk_setServerIP(server_ip); |
| 190 | return ; |
| 191 | } |
| 192 | |