4 * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #include <sys/types.h>
31 #include <core_object.h>
36 #include <type/notification.h>
39 #include <libxml/xmlreader.h>
40 #include <libxml/parser.h>
41 #include <libxml/tree.h>
43 #include <tzplatform_config.h>
47 #include "imc_common.h"
50 #define POSITION_NODE "pos"
51 #define POSITION_NODE_ATTR_XSI "xsi:noNamespaceSchemaLocation"
52 #define POSITION_NODE_ATTR_VAL_XSI "pos.xsd"
53 #define POSITION_NODE_ATTR_XMLNS "xmlns:xsi"
54 #define POSITION_NODE_ATTR_VAL_XMLNS "http://www.w3.org/2001/XMLSchema-instance"
56 #define MAX_NUM_OF_GPS_REF_TIME_ELEMENT 12 // max number of gps satalite
57 #define MAX_NUM_OF_GPS_NAV_ELEMENT 16 // max num of navigation gps element.
58 #define MAX_NUM_OF_GPS_ALMANC_ELEMENTS 64 // Max num of almanc elements.
60 #define NUM_OF_ELEMENTS(array) (sizeof(array) / sizeof(*(array)))
62 static char node_name[128]; // max len of xml node
63 static char node_value[128]; // max len of xml node value.
65 // node type of gps assist data
66 enum gps_assist_element_type {
80 unsigned short bcchCarrier;
82 unsigned long int frameNumber;
83 unsigned short timeSlot;
84 unsigned short bitNumber;
85 } __attribute__((packed)) gps_gsm_time_t;
89 unsigned long int gpsTimeUncertainty;
90 } __attribute__((packed)) gps_utran_gps_unc_t;
94 signed long int driftRate;
95 } __attribute__((packed)) gps_drift_rate_t;
99 unsigned long int cellFrames;
100 unsigned char choice_mode;
101 unsigned long int UtranFdd; // FDD Primary Scrambling Code
102 unsigned long int UtranTdd; // TDD Cell Parameter ID
103 unsigned long int sfn; // SFN
104 } __attribute__((packed)) gps_utran_gps_ref_time_t;
107 gps_utran_gps_ref_time_t UtranGpsRefTime;
108 gps_utran_gps_unc_t UtranGpsUncertainty;
109 unsigned char UtranSfnUncertainty;
110 gps_drift_rate_t UtranDriftRate;
111 } __attribute__((packed)) gps_utran_time_t;
114 unsigned short satID;
115 unsigned short tlmWord;
116 unsigned char antiSpoofFlag;
117 unsigned char alertFlag;
118 unsigned char tmlReservedBits;
119 } __attribute__((packed)) gps_gps_tow_assist_t;
122 unsigned long int gpsTow;
123 unsigned long int gpsWeek;
124 unsigned char nrOfSats;
125 union { // Not supported.
126 gps_gsm_time_t gsm_time;
127 gps_utran_time_t UtranTime;
129 gps_gps_tow_assist_t GpsTowAssist[12];
130 } __attribute__((packed)) gps_ref_time_t;
135 unsigned char shapeType;
136 unsigned char hemisphere;
137 unsigned short altitude;
138 unsigned long int latitude;
139 signed long int longitude;
140 unsigned char directionOfAlt;
141 unsigned char semiMajorUncert;
142 unsigned char semiMinorUncert;
143 unsigned char majorAxis;
144 unsigned char altUncert;
145 unsigned char confidence;
146 } __attribute__((packed)) gps_ref_loc_t;
151 GPS_DGPS_UDRE_SCALE_1_0,
152 GPS_DGPS_UDRE_SCALE_0_75,
153 GPS_DGPS_UDRE_SCALE_0_5,
154 GPS_DGPS_UDRE_SCALE_0_3,
155 GPS_DGPS_UDRE_SCALE_0_2,
156 GPS_DGPS_UDRE_SCALE_0_1,
158 } __attribute__((packed)) gps_dgps_status_e_type;
161 unsigned char satId; // Satellite ID
164 signed short pseudoRangeCor;
165 signed short rangeRateCor;
166 } gps_dgps_sat_list_t;
169 unsigned long int gpsTow;
170 gps_dgps_status_e_type status;
171 unsigned long int numberOfSat;
172 gps_dgps_sat_list_t seqOfSatElement[16];
173 } __attribute__((packed)) gps_dgps_correction_t;
177 unsigned long int rsv1; // 0~838860
178 unsigned long int rsv2; // 0~16777215
179 unsigned long int rsv3; // 0~16777215
180 unsigned long int rsv4; // 0~65535
181 } __attribute__((packed)) gps_navi_subframe_rsv_t;
184 unsigned char ephemCodeOnL2; // 0~3
185 unsigned char ephemUra; // 0~15
186 unsigned char ephemSvHealth; // 0~63
187 unsigned short ephemIodc; // 0~1023
188 unsigned char ephemL2PFlag; // 0~1
189 gps_navi_subframe_rsv_t NavigationSubFrameRsv;
190 signed char ephemTgd; // -128~127
191 unsigned short ephemToc; // 0~37799
192 signed char ephemAf2; // -128~12
193 signed short ephemAf1; // -32768~32767
194 signed long int ephemAf0; // -2097152~2097151
195 signed short ephemCrs; // -32768~32767
196 signed short ephemDeltaN; // -32768~32767
197 signed long int ephemM0; // -2147483648~2147483647
198 signed short ephemCuc; // -32768~32767
199 unsigned long int ephemE; // 0~4294967295
200 signed short ephemCus; // -32768~32767
201 unsigned long int ephemAPowrHalf; // 0~4294967295
202 unsigned short ephemToe; // 0~37799
203 signed char ephemFitFlag; // 0~1
204 unsigned char ephemAoda; // 0~31
205 signed short ephemCic; // -32768~32767
206 signed long int ephemOmegaA0; // -2147483648~2147483647
207 signed short ephemCis; // -32768~32767
208 signed long int ephemI0; // -2147483648~2147483647
209 signed short ephemCrc; // -32768~32767
210 signed long int ephemW; // -2147483648~2147483647
211 signed long int ephemOmegaADot; // -8388608~8388607
212 signed short ephemIDot; // -8192~8191
213 } __attribute__((packed)) gps_navi_ephe_t;
216 GPS_NAVIGATION_MODEL_NEW_SATELLITE_NEW_NAVIGATION,
217 GPS_NAVIGATION_MODEL_EXIST_SATELLITE_EXIST_NAVIGATION,
218 GPS_NAVIGATION_MODEL_EXIST_SATELLITE_NEW_NAVIGATION,
219 GPS_NAVIGATION_MODEL_RESERVED
220 } gps_navigation_sat_status_e_type;
224 gps_navigation_sat_status_e_type NavigationSatStatus;
225 gps_navi_ephe_t NavigationEphemeris;
226 } __attribute__((packed)) gps_navi_sat_info_t;
229 unsigned long int numberOfSat;
230 gps_navi_sat_info_t NavigationSatInfo[16];
231 } __attribute__((packed)) gps_navi_model_t;
235 signed char alfa0; // -128~127
236 signed char alfa1; // -128~127
237 signed char alfa2; // -128~127
238 signed char alfa3; // -128~127
239 signed char beta0; // -128~127
240 signed char beta1; // -128~127
241 signed char beta2; // -128~127
242 signed char beta3; // -128~127
243 } __attribute__((packed)) gps_iono_model_t;
247 signed long int utcA1; // -8388608~8388607
248 signed long int utcA0; // -2147483648~2147483647
249 unsigned char utcTot; // 0~255
250 unsigned char utcWNt; // 0~255
251 signed char utcDeltaTls; // -128~127
252 unsigned char utcWNlsf; // 0~255
253 signed char utcDN; // -128~127
254 signed char utcDeltaTlsf; // -128~127
255 } __attribute__((packed)) gps_utc_model_t;
259 signed char dataId; // only for 3G, 0~3, if this value is -1, it means this value is invalid
261 unsigned short almanacE; // 0~65536
262 unsigned char almanacToa; // 0~255
263 signed short almanacKsii; // -32768~3276
264 signed short almanacOmegaDot; // -32768~3276
265 unsigned char almanacSvHealth; // 0~255
266 unsigned long int almanacAPowerHalf; // 0~16777215
267 signed long int almanacOmega0; // -8388608~8388607
268 signed long int almanacW; // -8388608~8388607
269 signed long int almanacM0; // -8388608~8388607
270 signed short almanacAf0; // -1024~1023
271 signed short almanacAf1; // -1024~1023
272 } __attribute__((packed)) gps_almanac_sat_info_t;
275 unsigned char almanacWNa; // 0~255
276 unsigned long int numberOfSat;
277 gps_almanac_sat_info_t AlmanacSatInfo[64];
278 } __attribute__((packed)) gps_almanac_model_t;
283 signed short doppler0; // -2048~2047 (real value is from -5120 to 5117.5 by step of 2.5)
284 unsigned char doppler1; // 0~63 (real value is from -0.966 to 0.483 by step of 0.023)
285 unsigned char dopplerUncertainty; // 0~7 (12.5, 25, 50, 100, 200)
286 unsigned short codePhase; // 0~1022
287 unsigned char intCodePhase; // 0~19
288 unsigned char gpsBitNumber; // 0~3
289 unsigned char codePhaseSearchWindow; // 0~15 (1023, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192)
290 unsigned char azimuth; // 0~31, 11.25 degree resolution
291 unsigned char elevation; // 0~7, 11.25 degree resolution
292 } __attribute__((packed)) gps_acq_sat_info_t;
295 gps_utran_gps_ref_time_t AcqUtranGpsRefTime;
296 gps_utran_gps_unc_t AcqUtranGpsUncertainty;
297 } __attribute__((packed)) gps_acq_utran_time_t;
300 unsigned long int gpsTow;
302 gps_gsm_time_t gsm_time;
303 gps_acq_utran_time_t AcqUtranTime;
304 } acquisitionTimeInfo; // --- not supported.
305 unsigned long int numberOfSat;
306 gps_acq_sat_info_t lcsAcquisitionSatInfo[16];
307 } __attribute__((packed)) gps_acq_assist_t;
310 unsigned char satId[16];
311 unsigned char numOfSat;
312 } __attribute__((packed)) gps_r_time_int_t;
317 unsigned long int flag;
318 gps_ref_time_t ref_time;
319 gps_ref_loc_t ref_loc;
320 gps_dgps_correction_t dgps_corrections;
321 gps_navi_model_t navi_model;
322 gps_iono_model_t iono_model;
323 gps_utc_model_t utc_model;
324 gps_almanac_model_t almanac;
325 gps_acq_assist_t acq_assist;
326 gps_r_time_int_t r_time_int; // not supported
327 } __attribute__((packed)) gps_assist_data_noti_t; // APGPS - GPS Assist Data Message - Notification
332 } __attribute__((packed)) sat_status_info_t;
334 const sat_status_info_t sat_status_info_table[] = {
335 { "NS_NN-U", 0}, {"NS_NN", 0}, {"ES_NN-U", 1}, {"ES_SN", 2},
340 char *pdoppler_status;
342 } __attribute__((packed)) doppler_status_info_t;
344 const doppler_status_info_t doppler_status_info_table[] = {
345 { "hz12-5", 12.5}, {"hz25", 25}, {"hz50", 50}, {"hz100", 100},
349 // postion measurement data structure.
352 GPS_METHODTYPE_INVALID,
353 GPS_METHODTYPE_MS_ASSISTED,
354 GPS_METHODTYPE_MS_BASED,
355 GPS_METHODTYPE_MS_BASED_PREF,
356 GPS_METHODTYPE_MS_ASSISTED_PREF
362 unsigned char horizontalAccuracy;
363 unsigned char vertcalAccuracy;
364 } __attribute__((packed)) gps_accuracy_t;
366 // gps_use_multi_sets_e_type
368 GPS_MULTIPLESETS_INVALID,
369 GPS_MULTIPLESETS_MULTIPLESETS,
370 GPS_MULTIPLESETS_ONESET
371 } gps_use_multi_sets_e_type;
373 // gps_env_char_e_type
375 GPS_ENVIRONMENT_INVALID,
376 GPS_ENVIRONMENT_BAD_AREA,
377 GPS_ENVIRONMENT_NOT_BAD_AREA,
378 GPS_ENVIRONMENT_MIXED_AREA
379 } gps_env_char_e_type;
381 // gps_cell_timing_wnt_e_type
383 GPS_CELLTIMING_INVALID,
384 GPS_CELLTIMING_WANTED,
385 GPS_CELLTIMING_NOT_WANTED
386 } gps_cell_timing_wnt_e_type;
388 // gps_add_assit_req_e_type
390 GPS_ADDITIONAL_ASSISREQ_INVALID,
391 GPS_ADDITIONAL_ASSISREQ_REQ,
392 GPS_ADDITIONAL_ASSISREQ_NOT_REQ
393 } gps_add_assit_req_e_type;
395 // gps measure position.
397 gps_method_e_type method_type;
398 gps_accuracy_t accuracy;
399 unsigned char rsp_time;
400 gps_use_multi_sets_e_type use_multi_sets;
401 gps_env_char_e_type environment_char;
402 gps_cell_timing_wnt_e_type cell_timing_wnt;
403 gps_add_assit_req_e_type add_assist_req;
404 } __attribute__((packed)) gps_measure_position_indi_t;
407 // APGPS - Measure Position message - confirm
409 GPS_MSR_POS_RES_LOCATION,
410 GPS_MSR_POS_RES_GPS_MEASUREMENTS,
411 GPS_MSR_POS_RES_AID_REQ,
412 GPS_MSR_POS_RES_ERROR
413 } gps_msr_pos_res_e_type;
416 unsigned char sat_id;
418 } __attribute__((packed)) gps_sat_info_t;
421 unsigned char beginWeek;
422 unsigned char endWeek;
423 unsigned char beginTow;
424 unsigned char endTow;
425 } __attribute__((packed)) gps_ext_ephe_chk_t;
428 unsigned long int assistanceFlag;
429 unsigned short gpsWeek;
430 unsigned char gpsToe;
432 unsigned char toeLimit;
433 gps_sat_info_t satInfo[15];
434 unsigned char gpsExtendedEphemeris;
435 gps_ext_ephe_chk_t extEphemerisChk;
436 } __attribute__((packed)) gps_assistance_data_t;
438 // Measure Position message
440 unsigned char satId; // Satellite ID
441 unsigned char cno; // 0~63, unit of dB-Hz
442 signed short doppler; // -32768~32767, Hz and scale factor 0.2
443 unsigned short wholeChips; // 0~1022
444 unsigned short fracChips; // 0~1024
445 unsigned char lcsMultiPath;
446 unsigned char pseuRangeRmsErr; // 0~63
447 } __attribute__((packed)) gps_measuremet_element_t;
450 unsigned long int gpsTow; // /< GPS time of week [msec]
451 unsigned short gpsWeek; // /< GPS week [0 .. 1023]
452 unsigned char nrOfSats; // /< number of satellites [1 .. 16]
453 gps_measuremet_element_t GpsMeasure[16];
454 } __attribute__((packed)) gps_measure_t;
457 signed long int latitude;
458 signed long int longitude;
459 } __attribute__((packed)) gps_ellipsoid_po_t;
462 gps_ellipsoid_po_t point;
463 unsigned char uncertainRadius;
464 } __attribute__((packed)) gps_po_unc_circle_t;
467 gps_ellipsoid_po_t point;
468 unsigned char semiMajorAxis;
469 unsigned char semiMinorAxis;
470 unsigned char orientationAngle;
471 unsigned char confidence;
472 } __attribute__((packed)) gps_po_unc_ellipse_t;
475 gps_ellipsoid_po_t point;
476 signed short altitude;
477 unsigned char semiMajorAxis;
478 unsigned char semiMinorAxis;
479 unsigned char orientationAngle;
480 unsigned char uncertainAltitude;
481 unsigned char confidence;
482 } __attribute__((packed)) gps_po_alt_unc_ellipse_t;
485 gps_ellipsoid_po_t point;
486 unsigned short innerRadius;
487 unsigned char uncertainRadius;
488 unsigned char offsetAngle;
489 unsigned char includedAngle;
490 unsigned char confidence;
491 } __attribute__((packed)) gps_ellipsoid_arc_t;
494 gps_ellipsoid_po_t point;
495 signed short altitude;
496 } __attribute__((packed)) gps_ellipsoid_alt_t;
499 unsigned char noOfPoints;
500 gps_ellipsoid_po_t points[15];
501 } __attribute__((packed)) gps_polygon_t;
505 unsigned char shape_type;
506 gps_po_unc_circle_t p_unc_clrcle;
507 gps_po_unc_ellipse_t p_unc_ellipse;
508 gps_po_alt_unc_ellipse_t p_alt_unc_ellipse;
509 gps_ellipsoid_arc_t ellipsoid_arc;
510 gps_ellipsoid_po_t ellipsoid_po;
511 gps_ellipsoid_alt_t ellipsoid_alt;
512 gps_polygon_t polygon;
513 } __attribute__((packed)) gps_loc_info_t;
517 unsigned long int gpsTow; // /< GPS time of week [msec]
518 unsigned short gpsWeek; // /< GPS week [0 .. 1023]
519 unsigned char fixType; // /< Fix type. 2D(0x01) or 3D(0x02)
520 gps_loc_info_t measured_loc_info;
521 } __attribute__((packed)) gps_measure_loc_info_t;
525 unsigned long int cellFrames;
526 unsigned char choice_mode;
527 unsigned long int UtranFdd; // FDD Primary Scrambling Code
528 unsigned long int UtranTdd; // TDD Cell Parameter ID
529 unsigned long int sfn; // SFN
530 } __attribute__((packed)) gps_utrangps_ref_time_t;
533 unsigned char result; // 0x00 : SUCCESS, 0x01 : Fail
534 gps_msr_pos_res_e_type response_type; // should be 4 byte
535 gps_measure_t gps_measure;
536 gps_measure_loc_info_t loc_info;
537 gps_assistance_data_t measured_assit_data;
538 gps_utrangps_ref_time_t UtranGpsRefTime; // only for 3G
539 } __attribute__((packed)) gps_measure_position_confirm_t; // APGPS - Measure Position message - confirm
546 static t_element elements[] = {
547 {"ref_time", REF_TIME},
548 {"location_parameters", LOCATION_PARM},
549 {"DGPS_corrections", DGPS_CORRECTION},
550 {"nav_model_elem", NAV_MODEL_ELEM},
551 {"ionospheric_model", IONOSPHERIC_MODEL},
552 {"UTC_model", UTC_MODEL},
553 {"almanac", ALMANAC},
554 {"acqu_assist", ACQU_ASSIST},
557 static inline int _modem_sat_status_info_2_tel_sat_info(char *sat_info)
561 for (count = 0; count < (int) (sizeof(sat_status_info_table) / sizeof(sat_status_info_t)); count++) {
562 if (g_strcmp0(sat_status_info_table[count].psat_status, sat_info) == 0)
563 return (sat_status_info_table[count].stat_status);
568 static inline int _modem_acqa_assit_doppler_2_tel_doppler(char *doppler_info)
572 for (count = 0; count < (int) (sizeof(doppler_status_info_table) / sizeof(doppler_status_info_t)); count++) {
573 if (g_strcmp0(doppler_status_info_table[count].pdoppler_status, doppler_info) == 0)
574 return (doppler_status_info_table[count].doppler_status);
579 static int _gps_element_compare(char *element[], char *element_str, int nelem)
583 for (count = 0; count < nelem; count++) {
584 if (g_strcmp0(element[count], element_str) == 0)
591 static enum gps_assist_element_type _get_element_type(char *element_str)
595 for (index = 0; index < sizeof(elements) / sizeof(t_element); index++) {
596 if (g_strcmp0(elements[index].name, element_str) == 0)
597 return elements[index].type;
601 static void _parse_ref_time_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist, gboolean GPS_TOW_assist, int count)
605 static char *element[] = {"GPS_TOW_msec", "GPS_week", "sat_id", "tlm_word", "anti_sp", "alert", "tlm_res"};
608 if (count < 0 || count >= MAX_NUM_OF_GPS_REF_TIME_ELEMENT) {
609 err("invalid count");
612 nelem = (int) NUM_OF_ELEMENTS(element);
613 node_count = _gps_element_compare(element, element_str, nelem);
615 if (node_count == 0) {
616 gpsdata_assist->ref_time.gpsTow = atoi(element_value);
617 dbg("gpsTow - %d\n", gpsdata_assist->ref_time.gpsTow);
618 gpsdata_assist->dgps_corrections.gpsTow = gpsdata_assist->ref_time.gpsTow;
620 } else if (node_count == 1) {
621 gpsdata_assist->ref_time.gpsWeek = atoi(element_value);
622 dbg("gpsWeek - %d\n", gpsdata_assist->ref_time.gpsWeek);
626 if (GPS_TOW_assist) {
627 switch (node_count) {
630 gpsdata_assist->ref_time.GpsTowAssist[count].satID = atoi(element_value);
631 dbg("GpsTowAssist[%d].satID = %d\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].satID);
632 gpsdata_assist->ref_time.nrOfSats = count + 1;
638 gpsdata_assist->ref_time.GpsTowAssist[count].tlmWord = atoi(element_value);
639 dbg("GpsTowAssist[%d]-tlmWord = %d\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].tlmWord);
640 gpsdata_assist->ref_time.nrOfSats = count + 1;
646 gpsdata_assist->ref_time.GpsTowAssist[count].antiSpoofFlag = *element_value;
647 dbg("GpsTowAssist[%d]-antiSpoofFlag = 0x%X\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].antiSpoofFlag);
648 gpsdata_assist->ref_time.nrOfSats = count + 1;
654 gpsdata_assist->ref_time.GpsTowAssist[count].alertFlag = *element_value;
655 dbg("GpsTowAssist[%d]-alertFlag = 0x%X\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].alertFlag);
656 gpsdata_assist->ref_time.nrOfSats = count + 1;
662 gpsdata_assist->ref_time.GpsTowAssist[count].tmlReservedBits = *element_value;
663 dbg("GpsTowAssist[%d]-tmlReservedBits = 0x%X\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].tmlReservedBits);
664 gpsdata_assist->ref_time.nrOfSats = count + 1;
669 err("Invalid gps element");
674 static void _parse_location_parameters(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
676 // unsigned char shapeType; and unsigned char hemisphere not supported.
678 static char *element[] = {
679 "north", "degrees", "height_above_surface", "height", "longitude", "uncert_semi_major", "uncert_semi_minor",
680 "orient_major", "confidence", "uncert_alt"
683 int nelem = (int) NUM_OF_ELEMENTS(element);
686 count = _gps_element_compare(element, element_str, nelem);
693 // gpsdata_assist.ref_loc.latitude_data.north = atoi(element_str_text);
694 // dbg("gpsdata_assist.ref_loc.latitude_data.north - %d\n",gpsdata_assist.ref_loc.latitude_data.north);
700 gpsdata_assist->ref_loc.latitude = atoi(element_value);
701 dbg("latitude_data.degrees - %d\n", gpsdata_assist->ref_loc.latitude);
707 // gpsdata_assist.ref_loc.altitude_data.height_above_surface = atoi(element_str_text);
708 // dbg("altitude_data.height_above_surface - %d\n",gpsdata_assist.ref_loc.altitude_data.height_above_surface);
714 gpsdata_assist->ref_loc.altitude = atoi(element_value); // todo- need to confirm
715 dbg("altitude_data.height - %d\n", gpsdata_assist->ref_loc.altitude);
721 gpsdata_assist->ref_loc.longitude = atoi(element_value);
722 dbg("longitude - %d\n", gpsdata_assist->ref_loc.longitude);
728 gpsdata_assist->ref_loc.semiMajorUncert = *element_value;
729 dbg("semiMajorUncert - 0x%X\n", gpsdata_assist->ref_loc.semiMajorUncert);
735 gpsdata_assist->ref_loc.semiMinorUncert = *element_value;
736 dbg("uncert_semi_minor - 0x%X\n", gpsdata_assist->ref_loc.semiMinorUncert);
742 gpsdata_assist->ref_loc.majorAxis = *element_value;
743 dbg("orient_major - 0x%X\n", gpsdata_assist->ref_loc.majorAxis);
749 gpsdata_assist->ref_loc.confidence = *element_value;
750 dbg("confidence - 0x%X\n", gpsdata_assist->ref_loc.confidence);
756 gpsdata_assist->ref_loc.altUncert = *element_value;
757 dbg("altUncert - 0x%X\n", gpsdata_assist->ref_loc.altUncert);
762 err("invalid element");
766 static void _parse_dgps_correction_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
770 if (g_strcmp0(element_str, "sat_id") == 0) {
771 gpsdata_assist->dgps_corrections.seqOfSatElement[0].satId = *element_value;
772 dbg("seqOfSatElement[0].satId - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].satId);
773 } else if (g_strcmp0(element_str, "IODE") == 0) {
774 gpsdata_assist->dgps_corrections.seqOfSatElement[0].iode = atoi(element_value);
775 dbg("seqOfSatElement[0].iode - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].iode);
776 } else if (g_strcmp0(element_str, "UDRE") == 0) {
777 gpsdata_assist->dgps_corrections.seqOfSatElement[0].udre = *element_value;
778 dbg("seqOfSatElement[0].udre- %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].udre);
779 } else if (g_strcmp0(element_str, "PRC") == 0) {
780 gpsdata_assist->dgps_corrections.seqOfSatElement[0].pseudoRangeCor = atoi(element_value);
781 dbg("seqOfSatElement[0].pseudoRangeCor - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].pseudoRangeCor);
782 } else if (g_strcmp0(element_str, "RRC") == 0) {
783 gpsdata_assist->dgps_corrections.seqOfSatElement[0].rangeRateCor = atoi(element_value);
784 dbg("seqOfSatElement[0].rangeRateCor - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].rangeRateCor);
788 static void _parse_ionospheric_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
790 static char *element[] = {"alfa0", "alfa1", "alfa2", "alfa3", "beta0", "beta1", "beta2", "beta3" };
791 int nelem = (int) NUM_OF_ELEMENTS(element);
794 count = _gps_element_compare(element, element_str, nelem);
799 gpsdata_assist->iono_model.alfa0 = *element_value;
800 dbg("alfa0 - 0x%X\n", gpsdata_assist->iono_model.alfa0);
806 gpsdata_assist->iono_model.alfa1 = *element_value;
807 dbg("alfa1 - 0x%X\n", gpsdata_assist->iono_model.alfa1);
813 gpsdata_assist->iono_model.alfa2 = *element_value;
814 dbg("alfa2 - 0x%X\n", gpsdata_assist->iono_model.alfa2);
820 gpsdata_assist->iono_model.alfa3 = *element_value;
821 dbg("alfa3 - 0x%X\n", gpsdata_assist->iono_model.alfa3);
827 gpsdata_assist->iono_model.beta0 = *element_value;
828 dbg("beta0 - 0x%X\n", gpsdata_assist->iono_model.beta0);
834 gpsdata_assist->iono_model.beta1 = *element_value;
835 dbg("beta1 -0x%X\n", gpsdata_assist->iono_model.beta1);
841 gpsdata_assist->iono_model.beta2 = *element_value;
842 dbg("beta2 - 0x%X\n", gpsdata_assist->iono_model.beta2);
848 gpsdata_assist->iono_model.beta3 = *element_value;
849 dbg("beta3 - 0x%X\n", gpsdata_assist->iono_model.beta3);
854 err("invalid gps element");
858 static void _parse_utc_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
860 static char *element[] = {"a1", "a0", "tot", "wnt", "dtls", "wnlsf", "dn", "dtlsf"};
861 int nelem = (int) NUM_OF_ELEMENTS(element);
864 count = _gps_element_compare(element, element_str, nelem);
870 gpsdata_assist->utc_model.utcA1 = atoi(element_value);
871 dbg("utcA1 - %d\n", gpsdata_assist->utc_model.utcA1);
877 gpsdata_assist->utc_model.utcA0 = atoi(element_value);
878 dbg("utcA0 - %d\n", gpsdata_assist->utc_model.utcA0);
884 gpsdata_assist->utc_model.utcTot = *element_value;
885 dbg("utcTot - 0x%X\n", gpsdata_assist->utc_model.utcTot);
891 gpsdata_assist->utc_model.utcWNt = *element_value;
892 dbg("utcWNt - 0x%X\n", gpsdata_assist->utc_model.utcWNt);
898 gpsdata_assist->utc_model.utcDeltaTls = *element_value;
899 dbg("utcDeltaTls -0x%X\n", gpsdata_assist->utc_model.utcDeltaTls);
905 gpsdata_assist->utc_model.utcWNlsf = *element_value;
906 dbg("utcWNlsf - 0x%X\n", gpsdata_assist->utc_model.utcWNlsf);
912 gpsdata_assist->utc_model.utcDN = *element_value;
913 dbg("utcDN - 0x%X\n", gpsdata_assist->utc_model.utcDN);
919 gpsdata_assist->utc_model.utcDeltaTlsf = *element_value;
920 dbg("utcDeltaTlsf - 0x%X\n", gpsdata_assist->utc_model.utcDeltaTlsf);
925 err("invalid gps element");
929 static void _parse_almanc_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist,
930 gboolean alm_elem, int count)
934 static char *element[] = {
935 "wna", "data_id", "sat_id", "alm_ecc", "alm_toa", "alm_ksii", "alm_omega_dot", "alm_sv_health", "alm_power_half",
936 "alm_omega0", "alm_omega", "alm_m0", "alm_af0", "alm_af1"
940 if (count < 0 || count >= MAX_NUM_OF_GPS_ALMANC_ELEMENTS) {
941 dbg("invalid count");
944 nelem = (int) NUM_OF_ELEMENTS(element);
946 node_count = _gps_element_compare(element, element_str, nelem);
947 if (node_count == 0) {
948 gpsdata_assist->almanac.almanacWNa = *element_value;
949 dbg("almanacWNa - %d\n", gpsdata_assist->almanac.almanacWNa);
954 switch (node_count) {
957 gpsdata_assist->almanac.AlmanacSatInfo[count].dataId = *element_value;
958 dbg("AlmanacSatInfo[%d].data_id - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].dataId);
964 gpsdata_assist->almanac.AlmanacSatInfo[count].satId = *element_value;
965 dbg("AlmanacSatInfo[%d].sat_id - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].satId);
971 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacE = atoi(element_value);
972 dbg("AlmanacSatInfo[%d].almanacE - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacE);
978 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacToa = *element_value;
979 dbg("AlmanacSatInfo[%d].almanacToa - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacToa);
985 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacKsii = *element_value;
986 dbg("AlmanacSatInfo[%d].almanacKsii - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacKsii);
992 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmegaDot = *element_value;
993 dbg("AlmanacSatInfo[%d].almanacOmegaDot - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmegaDot);
999 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacSvHealth = *element_value;
1000 dbg("AlmanacSatInfo[%d].almanacSvHealth - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacSvHealth);
1006 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAPowerHalf = atoi(element_value);
1007 dbg("AlmanacSatInfo[%d].almanacAPowerHalf - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAPowerHalf);
1013 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmega0 = atoi(element_value);
1014 dbg("AlmanacSatInfo[%d].almanacOmega0 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmega0);
1020 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacW = atoi(element_value);
1021 dbg("AlmanacSatInfo[%d].almanacW - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacW);
1027 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacM0 = atoi(element_value);
1028 dbg("AlmanacSatInfo[%d].almanacM0 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacM0);
1034 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf0 = atoi(element_value);
1035 dbg("AlmanacSatInfo[%d].almanacAf0 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf0);
1041 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf1 = atoi(element_value);
1042 dbg("AlmanacSatInfo[%d].almanacAf1 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf1);
1047 err("invalid gps element");
1053 static void _parse_acqu_assist_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
1055 static char *element[] = {"tow_msec", "sat_id", "dopl0", "dopl1", "code_ph", "code_ph_int", "GPS_bitno", "srch_w", "az", "elev"};
1056 int nelem = (int) NUM_OF_ELEMENTS(element);
1059 count = _gps_element_compare(element, element_str, nelem);
1064 gpsdata_assist->acq_assist.gpsTow = atoi(element_value);
1065 dbg("acq_assist.gpsTow - %d\n", gpsdata_assist->acq_assist.gpsTow);
1069 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].satId = *element_value;
1070 dbg("lcsAcquisitionSatInfo[0].satId - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].satId);
1074 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler0 = atoi(element_value);
1075 dbg("lcsAcquisitionSatInfo[0].dopl0 - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler0);
1079 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler1 = *element_value;
1080 dbg("lcsAcquisitionSatInfo[0].doppler1 - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler1);
1084 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhase = atoi(element_value);
1085 dbg("lcsAcquisitionSatInfo[0].codePhase - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhase);
1089 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].intCodePhase = *element_value;
1090 dbg("lcsAcquisitionSatInfo[0].intCodePhase - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].intCodePhase);
1094 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].gpsBitNumber = *element_value;
1095 dbg("lcsAcquisitionSatInfo[0].GPS_bitno - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].gpsBitNumber);
1099 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhaseSearchWindow = *element_value;
1100 dbg("lcsAcquisitionSatInfo[0].codePhaseSearchWindow - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhaseSearchWindow);
1104 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].azimuth = *element_value;
1105 dbg("lcsAcquisitionSatInfo[0].azimuth - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].azimuth);
1109 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].elevation = *element_value;
1110 dbg("lcsAcquisitionSatInfo[0].elevation - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].elevation);
1114 err("invalid gps element");
1118 static void _parse_nav_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t
1119 *gpsdata_assist, gboolean ephem_and_clock, int element_count)
1121 static char *element[] = {
1122 "sat_id", "l2_code", "ura", "sv_health", "iodc", "l2p_flag", "esr1", "esr2", "esr3", "esr4", "tgd", "toc", "af2", "af0",
1123 "crs", "delta_n", "m0", "cuc", "ecc", "cus", "power_half", "toe", "fit_flag", "aoda", "cic", "omega0", "cis", "i0", "crc", "omega", "idot", "omega_dot"
1126 int nelem = (int) NUM_OF_ELEMENTS(element);
1129 if (element_count < 0 || element_count >= MAX_NUM_OF_GPS_NAV_ELEMENT) {
1130 err("invalid count");
1133 count = _gps_element_compare(element, element_str, nelem);
1137 gpsdata_assist->navi_model.NavigationSatInfo[element_count].satId = *element_value;
1138 dbg("NavigationSatInfo[%d].satId - 0x%X\n", element_count, gpsdata_assist->navi_model.NavigationSatInfo[element_count].satId);
1142 if (ephem_and_clock) {
1145 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCodeOnL2 = *element_value;
1149 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemUra = *element_value;
1153 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemSvHealth = *element_value;
1157 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemIodc = atoi(element_value);
1161 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemL2PFlag = *element_value;
1165 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv1 = atoi(element_value);
1169 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv2 = atoi(element_value);
1173 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv3 = atoi(element_value);
1177 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv4 = atoi(element_value);
1181 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemTgd = *element_value;
1185 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemToc = atoi(element_value);
1189 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAf2 = *element_value;
1193 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAf1 = atoi(element_value);
1197 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAf0 = atoi(element_value);
1201 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCrs = atoi(element_value);
1205 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemDeltaN = atoi(element_value);
1209 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemM0 = atoi(element_value);
1213 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCuc = atoi(element_value);
1217 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemE = atoi(element_value);
1221 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCus = atoi(element_value);
1225 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAPowrHalf = atoi(element_value);
1229 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemToe = atoi(element_value);
1233 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemFitFlag = *element_value;
1237 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAoda = *element_value;
1241 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCic = atoi(element_value);
1245 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemI0 = atoi(element_value);
1249 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCrc = atoi(element_value);
1253 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemW = atoi(element_value);
1257 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemIDot = atoi(element_value);
1261 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemOmegaADot = atoi(element_value);
1262 dbg("NavigationSatInfo[%d].NavigationEphemeris.ephemOmegaADot - 0x%X\n", element_count, gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemOmegaADot);
1266 err("invalid gps element");
1271 // Set coordinate elements : <latitude> <longitude> <altitude>
1272 static void _set_coordinate(xmlNodePtr node, gps_ellipsoid_po_t *point, int isalt, int altitude)
1274 // <parent_node> .. .. (xmlNodePtr node)
1275 // <coordinate> <latitude> <north>0</north> <degrees>0</degrees> </latitude> <longitude>0</longitude> </coordinate>
1276 // <altitude> <height_above_surface>0</height_above_surface> <height>0</height> </altitude>
1277 // .. .. <\parent_node>
1279 xmlNodePtr coordinate_node = NULL, temp_node = NULL;
1281 memset(node_name, 0x00, sizeof(node_name));
1282 memset(node_value, 0x00, sizeof(node_value));
1284 sprintf(node_name, "%s", "coordinate");
1285 coordinate_node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
1287 sprintf(node_name, "%s", "latitude");
1288 temp_node = xmlNewChild(coordinate_node, NULL, BAD_CAST node_name, NULL);
1290 sprintf(node_name, "%s", "north");
1291 sprintf(node_value, "%d", 0);
1292 xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1294 sprintf(node_name, "%s", "degrees");
1295 sprintf(node_value, "%d", (int) point->latitude);
1296 xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1298 sprintf(node_name, "%s", "longitude");
1299 sprintf(node_value, "%d", (int) point->longitude);
1300 xmlNewChild(coordinate_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1303 sprintf(node_name, "%s", "altitude");
1304 temp_node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
1305 sprintf(node_name, "%s", "height_above_surface");
1306 sprintf(node_value, "%d", 0);
1307 xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1308 sprintf(node_name, "%s", "height");
1309 sprintf(node_value, "%d", altitude);
1310 xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1317 static void _set_loc_info_ellipse_elements(xmlNodePtr node, void *elliplse, int is_unc_ellipse)
1319 gps_po_unc_ellipse_t *p_unc_ellipse;
1320 gps_po_alt_unc_ellipse_t *p_alt_unc_ellipse;
1321 unsigned char semiMajorAxis, semiMinorAxis, orientationAngle, confidence;
1323 memset(node_name, 0x00, sizeof(node_name));
1324 memset(node_value, 0x00, sizeof(node_value));
1326 if (is_unc_ellipse) {
1327 p_unc_ellipse = (gps_po_unc_ellipse_t *) elliplse;
1328 semiMajorAxis = p_unc_ellipse->semiMajorAxis;
1329 semiMinorAxis = p_unc_ellipse->semiMinorAxis;
1330 orientationAngle = p_unc_ellipse->orientationAngle;
1331 confidence = p_unc_ellipse->confidence;
1333 p_alt_unc_ellipse = (gps_po_alt_unc_ellipse_t *) elliplse;
1334 semiMajorAxis = p_alt_unc_ellipse->semiMajorAxis;
1335 semiMinorAxis = p_alt_unc_ellipse->semiMinorAxis;
1336 orientationAngle = p_alt_unc_ellipse->orientationAngle;
1337 confidence = p_alt_unc_ellipse->confidence;
1340 sprintf(node_name, "%s", "uncert_semi_major");
1341 sprintf(node_value, "%d", semiMajorAxis);
1342 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1344 sprintf(node_name, "%s", "uncert_semi_minor");
1345 sprintf(node_value, "%d", semiMinorAxis);
1346 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1348 sprintf(node_name, "%s", "orient_major");
1349 sprintf(node_value, "%d", orientationAngle);
1350 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1352 sprintf(node_name, "%s", "confidence");
1353 sprintf(node_value, "%d", confidence);
1354 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1357 static xmlChar* _generate_confirm_measure_pos_xml_text(gps_measure_position_confirm_t *gps_measure_position_confirm)
1359 xmlDocPtr doc = NULL;
1360 xmlNodePtr root_node = NULL, node = NULL;
1361 xmlNodePtr gps_msr_node = NULL, shape_data_node = NULL, loc_child_node = NULL;
1362 xmlChar *xml = NULL;
1363 int count = 0, altitude, size;
1366 Creates a new XML document
1367 ================================================================================================================================
1370 <?xml version="1.0"?>
1371 <pos xsi:noNamespaceSchemaLocation="pos.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
1374 <tow_msec></tow_msec>
1377 <sat_id></sat_id><carr2_noise></carr2_noise><dopl></dopl><whole_chips></whole_chips><fract_chips></fract_chips>
1378 <multi_path literal="xx"></multi_path> <psr_rms_err></psr_rms_err>
1382 <time_of_fix></time_of_fix><
1383 <location_parameters>
1387 <latitude><north></north><degrees></degrees></latitude><longitude></longitude>
1390 <ellipsoid_point_uncert_circle>
1391 <uncert_circle></uncert_circle>
1393 <latitude> <> <\> ...</latitude> <longitude></longitude>
1395 </ellipsoid_point_uncert_circle>
1396 <ellipsoid_point_uncert_ellipse>
1398 <latitude><> <\>..<longitude></longitude>
1400 <uncert_ellipse><uncert_semi_major></uncert_semi_major><uncert_semi_minor></uncert_semi_minor>
1401 <orient_major></orient_major><confidence></confidence></uncert_ellipse>
1402 </ellipsoid_point_uncert_ellipse>
1405 <latitude><> <\>...</latitude><longitude></longitude>
1408 <ellipsoid_point_alt>
1410 <latitude><> <\>..</latitude><longitude></longitude>
1413 <height_above_surface></height_above_surface><height></height>
1415 </ellipsoid_point_alt>
1416 <ellipsoid_point_alt_uncertellipse>
1418 <latitude> <> <\>.. ..</latitude><longitude></longitude>
1421 <height_above_surface></height_above_surface><height></height>
1423 <uncert_semi_major></uncert_semi_major><uncert_semi_minor></uncert_semi_minor><orient_major></orient_major>
1424 <confidence></confidence><uncert_alt></uncert_alt>
1425 </ellipsoid_point_alt_uncertellipse>
1428 <latitude><> <\> .. </latitude><longitude></longitude>
1430 <inner_rad></inner_rad>
1431 <uncert_rad></uncert_rad><offset_angle></offset_angle><included_angle></included_angle>
1432 <confidence></confidence>
1435 </location_parameters>
1441 ================================================================================================================================
1444 doc = xmlNewDoc(BAD_CAST "1.0");
1447 memset(node_name, 0x00, sizeof(node_name));
1448 memset(node_value, 0x00, sizeof(node_value));
1450 sprintf(node_name, "%s", POSITION_NODE);
1451 // Creation of a new node element
1452 root_node = xmlNewNode(NULL, BAD_CAST node_name);
1453 // Set the root element of the document
1454 xmlDocSetRootElement(doc, root_node);
1455 sprintf(node_name, "%s", POSITION_NODE_ATTR_XSI);
1456 sprintf(node_value, "%s", POSITION_NODE_ATTR_VAL_XSI);
1457 // Create a new property carried by a node
1458 xmlNewProp(root_node, BAD_CAST node_name, BAD_CAST node_value);
1460 sprintf(node_name, "%s", POSITION_NODE_ATTR_XMLNS);
1461 sprintf(node_value, "%s", POSITION_NODE_ATTR_VAL_XMLNS);
1462 xmlNewProp(root_node, BAD_CAST node_name, BAD_CAST node_value);
1465 // Creation of a new child element, added at the end of @parent children list
1466 sprintf(node_name, "%s", "GPS_meas");
1467 gps_msr_node = xmlNewChild(root_node, NULL, BAD_CAST node_name, NULL);
1469 sprintf(node_name, "%s", "ref_time_only");
1470 node = xmlNewChild(gps_msr_node, NULL, BAD_CAST node_name, NULL);
1472 sprintf(node_name, "%s", "tow_msec");
1473 sprintf(node_value, "%d", (int) gps_measure_position_confirm->gps_measure.gpsTow);
1474 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1476 // creatation of <meas_params> elements.
1477 for (count = 0; count < gps_measure_position_confirm->gps_measure.nrOfSats; count++) {
1478 xmlNodePtr multipath_node = NULL;
1479 sprintf(node_name, "%s", "meas_params");
1480 node = xmlNewChild(gps_msr_node, NULL, BAD_CAST node_name, NULL);
1482 sprintf(node_name, "%s", "sat_id");
1483 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].satId);
1484 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1486 sprintf(node_name, "%s", "carr2_noise");
1487 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].cno);
1488 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1490 sprintf(node_name, "%s", "dopl");
1491 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].doppler);
1492 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1494 sprintf(node_name, "%s", "whole_chips");
1495 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].wholeChips);
1496 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1498 sprintf(node_name, "%s", "fract_chips");
1499 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].fracChips);
1500 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1502 sprintf(node_name, "%s", "multi_path");
1503 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].lcsMultiPath);
1504 multipath_node = xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1505 xmlNewProp(multipath_node, BAD_CAST "literal", BAD_CAST "not_measured");
1507 sprintf(node_name, "%s", "psr_rms_err");
1508 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].pseuRangeRmsErr);
1509 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1513 sprintf(node_name, "%s", "location");
1514 node = xmlNewChild(root_node, NULL, BAD_CAST node_name, NULL);
1516 sprintf(node_name, "%s", "time_of_fix");
1517 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.fixType);
1518 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1520 // location_parameters
1521 sprintf(node_name, "%s", "location_parameters");
1522 node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
1525 sprintf(node_name, "%s", "shape_data");
1526 shape_data_node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
1529 sprintf(node_name, "%s", "ellipsoid_point");
1530 node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1532 _set_coordinate(node, &(gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_po), 0, 0);
1534 // ellipsoid_point_uncert_circle
1535 sprintf(node_name, "%s", "ellipsoid_point_uncert_circle");
1536 node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1537 sprintf(node_name, "%s", "uncert_circle");
1538 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_clrcle.uncertainRadius);
1539 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1540 // set coordinate parameters.
1541 _set_coordinate(node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_clrcle.point), 0, 0);
1543 // ellipsoid_point_uncert_ellipse
1544 sprintf(node_name, "%s", "ellipsoid_point_uncert_ellipse");
1545 loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1546 // set coordinate parameters.
1547 _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_clrcle.point), 0, 0);
1549 sprintf(node_name, "%s", "uncert_ellipse");
1550 node = xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, NULL);
1551 // set location ellipse parametes.
1552 _set_loc_info_ellipse_elements(node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_ellipse), 1);
1554 sprintf(node_name, "%s", "polygon");
1555 loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1556 for (count = 0; count < gps_measure_position_confirm->loc_info.measured_loc_info.polygon.noOfPoints; count++) {
1557 // set coordinate parameters.
1558 _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.polygon.points[count]), 0, 0);
1561 // ellipsoid_point_alt
1562 sprintf(node_name, "%s", "ellipsoid_point_alt");
1563 loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1564 altitude = gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_alt.altitude;
1565 // set coordinate parameters.
1566 _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_alt.point), 1, altitude);
1568 // ellipsoid_point_alt_uncertellipse
1569 sprintf(node_name, "%s", "ellipsoid_point_alt_uncertellipse");
1570 loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1571 altitude = gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse.altitude;
1572 // set coordinate parameters.
1573 _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse.point), 1, altitude);
1574 // set location ellipse parametes.
1575 _set_loc_info_ellipse_elements(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse), 0);
1577 sprintf(node_name, "%s", "uncert_alt");
1578 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse.uncertainAltitude);
1579 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1581 // ellipsoid_point_alt_uncertellipse
1582 sprintf(node_name, "%s", "ellips_arc");
1583 loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1584 _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.point), 0, 0);
1586 sprintf(node_name, "%s", "inner_rad");
1587 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.innerRadius);
1588 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1590 sprintf(node_name, "%s", "uncert_rad");
1591 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.uncertainRadius);
1592 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1594 sprintf(node_name, "%s", "offset_angle");
1595 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.offsetAngle);
1596 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1598 sprintf(node_name, "%s", "included_angle");
1599 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.includedAngle);
1600 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1602 sprintf(node_name, "%s", "confidence");
1603 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.confidence);
1604 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1606 // 3. assist data /msr_assist_data
1607 sprintf(node_name, "%s", "assist_data");
1608 node = xmlNewChild(root_node, NULL, BAD_CAST node_name, NULL);
1609 sprintf(node_name, "%s", "msr_assist_data");
1610 xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
1612 // Dump an XML document in memory and return the #xmlChar * and it's size in bytes
1613 xmlDocDumpMemory(doc, &xml, &size);
1614 dbg("xmlcontetnt:\n");
1615 dbg("%s", (char *) xml);
1616 // Free up all the structures used by a document, tree included.
1623 static gboolean on_notification_gps_measure_position_from_modem(CoreObject *o, char *file_name, void *user_data)
1625 char *node = NULL, *node_value = NULL;
1626 char *attribute = NULL;
1627 char *attr_value = NULL;
1628 gps_measure_position_indi_t gps_measure_position_indi;
1629 gboolean rep_quant = FALSE;
1630 xmlTextReaderPtr reader;
1632 memset(&gps_measure_position_indi, 0x00, sizeof(gps_measure_position_indi));
1633 reader = xmlReaderForFile(file_name, NULL, 0);
1635 while (xmlTextReaderRead(reader)) {
1636 switch (xmlTextReaderNodeType(reader)) {
1637 case XML_READER_TYPE_ELEMENT:
1639 node = (char *) xmlTextReaderConstName(reader);
1640 dbg("Element: %s", node);
1642 // Read attribute value.
1643 while (xmlTextReaderMoveToNextAttribute(reader)) {
1644 attribute = (char *) xmlTextReaderConstName(reader);
1645 dbg("Attribute value - %s\n", attribute);
1646 attr_value = (char *) xmlTextReaderConstValue(reader);
1647 dbg("=\"%s\"\n", attr_value);
1649 if (g_strcmp0(node, "mult_sets") == 0) {
1650 if (g_strcmp0(attribute, "literal") == 0) {
1651 if (g_strcmp0(attr_value, "one") == 0)
1652 gps_measure_position_indi.use_multi_sets = GPS_MULTIPLESETS_ONESET;
1653 else if (g_strcmp0(attr_value, "multiple") == 0)
1654 gps_measure_position_indi.use_multi_sets = GPS_MULTIPLESETS_MULTIPLESETS;
1656 dbg("gps_measure_position_indi.use_multi_sets - 0x%x\n", gps_measure_position_indi.use_multi_sets);
1657 } else if (g_strcmp0(node, "rep_quant") == 0) {
1659 if (g_strcmp0(attribute, "addl_assist_data_req") == 0) {
1660 if (g_strcmp0(attr_value, "true") == 0)
1661 gps_measure_position_indi.add_assist_req = GPS_ADDITIONAL_ASSISREQ_REQ;
1663 gps_measure_position_indi.add_assist_req = GPS_ADDITIONAL_ASSISREQ_NOT_REQ;
1664 } else if (g_strcmp0(attribute, "gps_timing_of_cell_wanted") == 0) {
1665 if (g_strcmp0(attr_value, "true") == 0)
1666 gps_measure_position_indi.cell_timing_wnt = GPS_CELLTIMING_WANTED;
1668 gps_measure_position_indi.cell_timing_wnt = GPS_CELLTIMING_NOT_WANTED;
1671 } // end of attribute check
1673 if (g_strcmp0(node, "ms_assisted") == 0) {
1674 gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_ASSISTED;
1675 } else if (g_strcmp0(node, "ms_assisted_no_accuracy") == 0) {
1676 gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_ASSISTED;
1677 } else if (g_strcmp0(node, "ms_based") == 0) {
1678 gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_BASED;
1679 } else if (g_strcmp0(node, "ms_based_pref") == 0) {
1680 gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_BASED_PREF;
1681 } else if (g_strcmp0(node, "ms_assisted_pref") == 0) {
1682 gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_ASSISTED_PREF;
1685 xmlTextReaderMoveToElement(reader);
1689 case XML_READER_TYPE_TEXT:
1691 node_value = (char *) xmlTextReaderConstValue(reader);
1692 dbg("element-value: %s", node_value);
1693 if (node_value != NULL) {
1694 if (g_strcmp0(node, "resp_time_seconds") == 0) {
1695 gps_measure_position_indi.rsp_time = *node_value;
1696 dbg("gps_measure_position_indi.rsp_time - 0x%x", gps_measure_position_indi.rsp_time);
1698 if (rep_quant == TRUE) {
1699 if (g_strcmp0(node, "hor_acc") == 0)
1700 gps_measure_position_indi.accuracy.horizontalAccuracy = *node_value;
1701 else if (g_strcmp0(node, "vert_acc") == 0)
1702 gps_measure_position_indi.accuracy.vertcalAccuracy = *node_value;
1709 xmlFreeTextReader(reader);
1712 tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)),(tcore_object_ref_plugin(o)),
1713 TCORE_NOTIFICATION_GPS_MEASURE_POSITION, sizeof(gps_measure_position_indi), &gps_measure_position_indi);
1718 static gboolean on_notification_imc_gps_assist_data(CoreObject *o, const void *event_info, void *user_data)
1721 gps_assist_data_noti_t gps_data_assist;
1722 char *node = NULL, *node_value = NULL;
1723 char *attribute = NULL, *attr_value = NULL;
1724 enum gps_assist_element_type node_type = -1, set_element_type = -1;
1725 int nav_model_node_count = -1;
1726 int alm_node_count = -1;
1727 int gps_tow_assist_count = -1;
1728 char *line = NULL, *pos = NULL;
1729 char *xml_line = NULL;
1731 xmlTextReaderPtr reader;
1732 gboolean _gps_assist_data = FALSE, gps_tow_assist = FALSE;
1733 gboolean ephem_and_clock = FALSE, alm_elem = FALSE;
1734 const char *path = NULL;
1739 Example:GPS assist XML data will be in below format.
1740 ================================================================================================================================
1741 +CPOSR:<?xml version="1.0" encoding="UTF-8"?>
1742 <pos xsi:noNamespaceSchemaLocation="pos.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
1746 <GPS_time> <> <\>..<\GPS_time> <GPS_TOW_assist*> <> <\> ..<\GPS_TOW_assist>
1749 <location_parameters>
1750 <shape_data> <ellipsoid_point_alt_uncertellipse> </coordinate> <> <\>...</coordinate> <altitude> <\altitude>
1751 <uncert_semi_major> </uncert_semi_major> <uncert_semi_minor> </uncert_semi_minor> <orient_major> </orient_major> <confidence> </confidence>
1752 <uncert_alt> </uncert_alt> </ellipsoid_point_alt_uncertellipse> </shape_data>
1753 </location_parameters>
1756 <sat_id> </sat_id> <IODE> </IODE> <UDRE></UDRE> <PRC></PRC> <RRC></RRC>
1760 <sat_id> </sat_id> <sat_status literal="xx"></sat_status>
1761 <ephem_and_clock?> <l2_code></l2_code> <> <\> .. .. <\ephem_and_clock>
1764 <ionospheric_model> <alfa0> </alfa0> <alfa1> </alfa1> <alfa2> </alfa2> <alfa3></alfa3>
1765 <beta0></beta0> <beta1></beta1> <beta2></beta2> <beta3> </beta3>
1766 </ionospheric_model>
1769 <a1></a1><a0></a0><tot></tot><wnt></wnt> <dtls></dtls> <wnlsf></wnlsf> <dn></dn><dtlsf></dtlsf>
1772 <wna>0</wna> <alm_elem*> <> <\> ...<\alm_elem>
1776 <tow_msec></tow_msec> <sat_info> <> <\> ... <\sat_info>
1782 ================================================================================================================================
1785 memset((void *) &gps_data_assist, 0x00, sizeof(gps_data_assist));
1786 xml_line = (char *) ((GSList *) event_info)->data;
1788 if (g_str_has_prefix((char *) xml_line, "+CPOSR:")) {
1789 dbg("notification line with prefix");
1790 pos = (char *) xml_line + strlen("+CPOSR:");
1792 pos = (char *) xml_line;
1794 line = g_strdup((char *) pos);
1796 path = tzplatform_mkpath(TZ_SYS_ROOT, "sample.xml");
1798 if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, S_IRWXU)) == -1) {
1799 err("Cannot open file\n");
1803 // write gps xml data into file.
1804 if (write(fd, (const void *) line, strlen(line)) == -1) {
1805 err("Cannot write into file\n");
1810 // free the memory pointed to by line.
1813 dbg("read xml file");
1814 reader = xmlReaderForFile(path, NULL, 0);
1816 while (xmlTextReaderRead(reader)) {
1817 // Get the node type of the current node
1818 switch (xmlTextReaderNodeType(reader)) {
1819 case XML_READER_TYPE_ELEMENT:
1821 // Read the qualified name of the node.
1822 node = (char *) xmlTextReaderConstName(reader);
1823 dbg("Element: %s\n ", node);
1825 // check type of sub element of <GPS_assist>
1826 set_element_type = _get_element_type(node);
1827 if ((int) set_element_type != -1) // ignore negative value as excepted element type not set.
1828 node_type = set_element_type;
1830 dbg("xml node type : %d", node_type);
1832 // Check for position measurement data.
1833 if (g_strcmp0(node, "pos_meas") == 0) {
1834 // Deallocate all the resources associated to the reader
1835 xmlFreeTextReader(reader);
1837 dbg("gps postion measurement notification ");
1838 // GPS position measurement notification.
1839 ret = on_notification_gps_measure_position_from_modem(o, path, user_data);
1842 if (access(path, F_OK) == 0) {
1844 dbg("file removed");
1849 // Moves the position of the current instance to the next attribute associated with the current node.
1850 while (xmlTextReaderMoveToNextAttribute(reader)) {
1851 // Read the qualified name of the node
1852 attribute = (char *) xmlTextReaderConstName(reader);
1853 dbg("attribute value - %s\n", attribute);
1855 // Provides the text value of the node if present.
1856 attr_value = (char *) xmlTextReaderConstValue(reader);
1857 dbg("=\"%s\"\n", attr_value);
1859 // Read attribute value of <nav_model_elem>
1860 if (node_type == NAV_MODEL_ELEM) {
1861 if (g_strcmp0(node, "sat_status") == 0 && g_strcmp0(attribute, "literal") == 0) {
1862 gps_data_assist.navi_model.NavigationSatInfo[nav_model_node_count].NavigationSatStatus = _modem_sat_status_info_2_tel_sat_info(attr_value);
1863 dbg("navigation sat status of nav model element - %d\n", gps_data_assist.navi_model.NavigationSatInfo[nav_model_node_count].NavigationSatStatus);
1866 // Read attribute value of <acqu_assist>
1867 else if (node_type == ACQU_ASSIST) {
1868 if (g_strcmp0(node, "dopl1_uncert") == 0 && g_strcmp0(attribute, "literal") == 0) {
1869 gps_data_assist.acq_assist.lcsAcquisitionSatInfo[0].dopplerUncertainty = _modem_acqa_assit_doppler_2_tel_doppler(attr_value);
1870 dbg("doppler uncertainty of acqu assist data- %d", gps_data_assist.acq_assist.lcsAcquisitionSatInfo[0].dopplerUncertainty);
1873 } // end of attribute check.
1875 // check GPS data is having GPS_assist data.
1876 if (g_strcmp0(node, "GPS_assist") == 0) {
1877 _gps_assist_data = TRUE;
1880 if (_gps_assist_data == TRUE) {
1881 // number of GPS_TOW_assist elements.
1882 if (g_strcmp0(node, "GPS_TOW_assist") == 0) {
1883 gps_tow_assist_count++;
1884 gps_tow_assist = TRUE;
1885 } else if (g_strcmp0(node, "nav_model_elem") == 0) {
1886 // number of nav_model_elem.
1887 nav_model_node_count++;
1888 } else if (g_strcmp0(node, "alm_elem") == 0) {
1889 // number of alm_elem elements.
1891 dbg("alm_elem_count - %d", alm_node_count);
1892 if (node_type == ALMANAC)
1894 } else if (g_strcmp0(node, "ephem_and_clock") == 0 && node_type == NAV_MODEL_ELEM) {
1895 ephem_and_clock = TRUE;
1899 xmlTextReaderMoveToElement(reader);
1900 } // end of reading node type.
1903 case XML_READER_TYPE_TEXT:
1905 // Provides the text value of the node if present
1906 node_value = (char *) xmlTextReaderConstValue(reader);
1907 dbg("node_value: %s\n", node_value);
1909 if (node_value != NULL) {
1910 switch (node_type) {
1912 _parse_ref_time_gps_elements(node, node_value, &gps_data_assist, gps_tow_assist, gps_tow_assist_count);
1916 _parse_location_parameters(node, node_value, &gps_data_assist);
1919 case DGPS_CORRECTION:
1920 _parse_dgps_correction_gps_elements(node, node_value, &gps_data_assist);
1923 case NAV_MODEL_ELEM:
1924 _parse_nav_model_gps_elements(node, node_value, &gps_data_assist, ephem_and_clock, nav_model_node_count);
1927 case IONOSPHERIC_MODEL:
1928 _parse_ionospheric_model_gps_elements(node, node_value, &gps_data_assist);
1932 _parse_utc_model_gps_elements(node, node_value, &gps_data_assist);
1936 _parse_almanc_model_gps_elements(node, node_value, &gps_data_assist, alm_elem, alm_node_count);
1940 _parse_acqu_assist_gps_elements(node, node_value, &gps_data_assist);
1944 err("invalid element");
1947 } // end of reading node value.
1950 } // end of parsing.
1952 // Deallocate all the resources associated to the reader
1953 xmlFreeTextReader(reader);
1958 if (access(path, F_OK) == 0) {
1960 dbg("file removed");
1963 tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)),(tcore_object_ref_plugin(o)),
1964 TCORE_NOTIFICATION_GPS_ASSIST_DATA, sizeof(gps_data_assist), &gps_data_assist);
1969 static gboolean on_notification_imc_reset_assist_data(CoreObject *o, const void *event_info, void *user_data)
1972 tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)),(tcore_object_ref_plugin(o)),
1973 TCORE_NOTIFICATION_GPS_RESET_ASSIST_DATA, 0, NULL);
1980 static void on_response_imc_gps_confirm_measure_pos(TcorePending *p, guint data_len, const void *data, void *user_data)
1982 //GPS server does not except confirmation for GPS measure position request.
1983 const TcoreAtResponse *at_resp = data;
1984 ImcRespCbData *resp_cb_data = user_data;
1988 if (at_resp && at_resp->success) {
1989 dbg("Confirm measure position - [OK]");
1991 err("Confirm measure position - [NOK]");
1994 imc_destroy_resp_cb_data(resp_cb_data);
1997 /* GPS Operations */
1999 * Operation - confirm measure position
2002 * AT-Command: AT+CPOS=<cr>
2003 * text is entered <ctrl-z/ESC>
2009 * +CME ERROR: <error>
2012 static TelReturn imc_gps_confirm_measure_pos (CoreObject *co, const TelGpsDataInfo *gps_data,
2013 TcoreObjectResponseCallback cb, void *cb_data)
2015 ImcRespCbData *resp_cb_data = NULL;
2016 char *cmd_str = NULL;
2017 xmlChar *xml = NULL;
2018 gps_measure_position_confirm_t gps_measure_pos_confirm;
2021 memcpy(&gps_measure_pos_confirm, gps_data->data, gps_data->data_len);
2023 xml = _generate_confirm_measure_pos_xml_text(&gps_measure_pos_confirm);
2025 err("xml text generation failed");
2026 return TEL_RETURN_FAILURE;
2030 cmd_str = g_strdup_printf("AT+CPOS%s%s\x1A", "\r", xml);
2032 resp_cb_data = imc_create_resp_cb_data(cb, cb_data, NULL, 0);
2034 /* Send Request to modem */
2035 ret = tcore_at_prepare_and_send_request(co,
2037 TCORE_AT_COMMAND_TYPE_NO_RESULT,
2038 TCORE_PENDING_PRIORITY_DEFAULT,
2040 on_response_imc_gps_confirm_measure_pos, resp_cb_data,
2041 on_send_imc_request, NULL,
2042 (guint)0, NULL, NULL);
2044 IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Confirm Measure Position");
2053 static TelReturn imc_gps_set_frequency_aiding (CoreObject *co, gboolean state,
2054 TcoreObjectResponseCallback cb, void *cb_data)
2056 return TEL_RETURN_OPERATION_NOT_SUPPORTED;
2060 static TcoreGpsOps imc_gps_ops = {
2061 .confirm_measure_pos = imc_gps_confirm_measure_pos,
2062 .set_frequency_aiding = imc_gps_set_frequency_aiding
2065 gboolean imc_gps_init(TcorePlugin *p, CoreObject *co)
2069 /* Set operations */
2070 tcore_gps_set_ops(co, &imc_gps_ops);
2073 tcore_object_override_callback(co, "+CPOSR", on_notification_imc_gps_assist_data, NULL);
2074 tcore_object_override_callback(co, "+XCPOSR", on_notification_imc_reset_assist_data, NULL);
2080 void imc_gps_exit(TcorePlugin *p, CoreObject *co)