4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: sharanayya mathapati <sharan.m@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
25 #include <sys/types.h>
32 #include <core_object.h>
36 #include <user_request.h>
40 #include <libxml/xmlreader.h>
41 #include <libxml/parser.h>
42 #include <libxml/tree.h>
43 #include <tzplatform_config.h>
49 #define POSITION_NODE "pos"
50 #define POSITION_NODE_ATTR_XSI "xsi:noNamespaceSchemaLocation"
51 #define POSITION_NODE_ATTR_VAL_XSI "pos.xsd"
52 #define POSITION_NODE_ATTR_XMLNS "xmlns:xsi"
53 #define POSITION_NODE_ATTR_VAL_XMLNS "http://www.w3.org/2001/XMLSchema-instance"
55 #define MAX_NUM_OF_GPS_REF_TIME_ELEMENT 12 // max number of gps satalite
56 #define MAX_NUM_OF_GPS_NAV_ELEMENT 16 // max num of navigation gps element.
57 #define MAX_NUM_OF_GPS_ALMANC_ELEMENTS 64 // Max num of almanc elements.
59 #define NUM_OF_ELEMENTS(array) (sizeof(array) / sizeof(*(array)))
61 static char node_name[128]; // max len of xml node
62 static char node_value[128]; // max len of xml node value.
64 // node type of gps assist data
65 enum gps_assist_element_type {
79 unsigned short bcchCarrier;
81 unsigned long int frameNumber;
82 unsigned short timeSlot;
83 unsigned short bitNumber;
84 } __attribute__((packed)) gps_gsm_time_t;
88 unsigned long int gpsTimeUncertainty;
89 } __attribute__((packed)) gps_utran_gps_unc_t;
93 signed long int driftRate;
94 } __attribute__((packed)) gps_drift_rate_t;
98 unsigned long int cellFrames;
99 unsigned char choice_mode;
100 unsigned long int UtranFdd; // FDD Primary Scrambling Code
101 unsigned long int UtranTdd; // TDD Cell Parameter ID
102 unsigned long int sfn; // SFN
103 } __attribute__((packed)) gps_utran_gps_ref_time_t;
106 gps_utran_gps_ref_time_t UtranGpsRefTime;
107 gps_utran_gps_unc_t UtranGpsUncertainty;
108 unsigned char UtranSfnUncertainty;
109 gps_drift_rate_t UtranDriftRate;
110 } __attribute__((packed)) gps_utran_time_t;
113 unsigned short satID;
114 unsigned short tlmWord;
115 unsigned char antiSpoofFlag;
116 unsigned char alertFlag;
117 unsigned char tmlReservedBits;
118 } __attribute__((packed)) gps_gps_tow_assist_t;
121 unsigned long int gpsTow;
122 unsigned long int gpsWeek;
123 unsigned char nrOfSats;
124 union { // Not supported.
125 gps_gsm_time_t gsm_time;
126 gps_utran_time_t UtranTime;
128 gps_gps_tow_assist_t GpsTowAssist[12];
129 } __attribute__((packed)) gps_ref_time_t;
134 unsigned char shapeType;
135 unsigned char hemisphere;
136 unsigned short altitude;
137 unsigned long int latitude;
138 signed long int longitude;
139 unsigned char directionOfAlt;
140 unsigned char semiMajorUncert;
141 unsigned char semiMinorUncert;
142 unsigned char majorAxis;
143 unsigned char altUncert;
144 unsigned char confidence;
145 } __attribute__((packed)) gps_ref_loc_t;
150 GPS_DGPS_UDRE_SCALE_1_0,
151 GPS_DGPS_UDRE_SCALE_0_75,
152 GPS_DGPS_UDRE_SCALE_0_5,
153 GPS_DGPS_UDRE_SCALE_0_3,
154 GPS_DGPS_UDRE_SCALE_0_2,
155 GPS_DGPS_UDRE_SCALE_0_1,
157 } __attribute__((packed)) gps_dgps_status_e_type;
160 unsigned char satId; // Satellite ID
163 signed short pseudoRangeCor;
164 signed short rangeRateCor;
165 } gps_dgps_sat_list_t;
168 unsigned long int gpsTow;
169 gps_dgps_status_e_type status;
170 unsigned long int numberOfSat;
171 gps_dgps_sat_list_t seqOfSatElement[16];
172 } __attribute__((packed)) gps_dgps_correction_t;
176 unsigned long int rsv1; // 0~838860
177 unsigned long int rsv2; // 0~16777215
178 unsigned long int rsv3; // 0~16777215
179 unsigned long int rsv4; // 0~65535
180 } __attribute__((packed)) gps_navi_subframe_rsv_t;
183 unsigned char ephemCodeOnL2; // 0~3
184 unsigned char ephemUra; // 0~15
185 unsigned char ephemSvHealth; // 0~63
186 unsigned short ephemIodc; // 0~1023
187 unsigned char ephemL2PFlag; // 0~1
188 gps_navi_subframe_rsv_t NavigationSubFrameRsv;
189 signed char ephemTgd; // -128~127
190 unsigned short ephemToc; // 0~37799
191 signed char ephemAf2; // -128~12
192 signed short ephemAf1; // -32768~32767
193 signed long int ephemAf0; // -2097152~2097151
194 signed short ephemCrs; // -32768~32767
195 signed short ephemDeltaN; // -32768~32767
196 signed long int ephemM0; // -2147483648~2147483647
197 signed short ephemCuc; // -32768~32767
198 unsigned long int ephemE; // 0~4294967295
199 signed short ephemCus; // -32768~32767
200 unsigned long int ephemAPowrHalf; // 0~4294967295
201 unsigned short ephemToe; // 0~37799
202 signed char ephemFitFlag; // 0~1
203 unsigned char ephemAoda; // 0~31
204 signed short ephemCic; // -32768~32767
205 signed long int ephemOmegaA0; // -2147483648~2147483647
206 signed short ephemCis; // -32768~32767
207 signed long int ephemI0; // -2147483648~2147483647
208 signed short ephemCrc; // -32768~32767
209 signed long int ephemW; // -2147483648~2147483647
210 signed long int ephemOmegaADot; // -8388608~8388607
211 signed short ephemIDot; // -8192~8191
212 } __attribute__((packed)) gps_navi_ephe_t;
215 GPS_NAVIGATION_MODEL_NEW_SATELLITE_NEW_NAVIGATION,
216 GPS_NAVIGATION_MODEL_EXIST_SATELLITE_EXIST_NAVIGATION,
217 GPS_NAVIGATION_MODEL_EXIST_SATELLITE_NEW_NAVIGATION,
218 GPS_NAVIGATION_MODEL_RESERVED
219 } gps_navigation_sat_status_e_type;
223 gps_navigation_sat_status_e_type NavigationSatStatus;
224 gps_navi_ephe_t NavigationEphemeris;
225 } __attribute__((packed)) gps_navi_sat_info_t;
228 unsigned long int numberOfSat;
229 gps_navi_sat_info_t NavigationSatInfo[16];
230 } __attribute__((packed)) gps_navi_model_t;
234 signed char alfa0; // -128~127
235 signed char alfa1; // -128~127
236 signed char alfa2; // -128~127
237 signed char alfa3; // -128~127
238 signed char beta0; // -128~127
239 signed char beta1; // -128~127
240 signed char beta2; // -128~127
241 signed char beta3; // -128~127
242 } __attribute__((packed)) gps_iono_model_t;
246 signed long int utcA1; // -8388608~8388607
247 signed long int utcA0; // -2147483648~2147483647
248 unsigned char utcTot; // 0~255
249 unsigned char utcWNt; // 0~255
250 signed char utcDeltaTls; // -128~127
251 unsigned char utcWNlsf; // 0~255
252 signed char utcDN; // -128~127
253 signed char utcDeltaTlsf; // -128~127
254 } __attribute__((packed)) gps_utc_model_t;
258 signed char dataId; // only for 3G, 0~3, if this value is -1, it means this value is invalid
260 unsigned short almanacE; // 0~65536
261 unsigned char almanacToa; // 0~255
262 signed short almanacKsii; // -32768~3276
263 signed short almanacOmegaDot; // -32768~3276
264 unsigned char almanacSvHealth; // 0~255
265 unsigned long int almanacAPowerHalf; // 0~16777215
266 signed long int almanacOmega0; // -8388608~8388607
267 signed long int almanacW; // -8388608~8388607
268 signed long int almanacM0; // -8388608~8388607
269 signed short almanacAf0; // -1024~1023
270 signed short almanacAf1; // -1024~1023
271 } __attribute__((packed)) gps_almanac_sat_info_t;
274 unsigned char almanacWNa; // 0~255
275 unsigned long int numberOfSat;
276 gps_almanac_sat_info_t AlmanacSatInfo[64];
277 } __attribute__((packed)) gps_almanac_model_t;
282 signed short doppler0; // -2048~2047 (real value is from -5120 to 5117.5 by step of 2.5)
283 unsigned char doppler1; // 0~63 (real value is from -0.966 to 0.483 by step of 0.023)
284 unsigned char dopplerUncertainty; // 0~7 (12.5, 25, 50, 100, 200)
285 unsigned short codePhase; // 0~1022
286 unsigned char intCodePhase; // 0~19
287 unsigned char gpsBitNumber; // 0~3
288 unsigned char codePhaseSearchWindow; // 0~15 (1023, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192)
289 unsigned char azimuth; // 0~31, 11.25 degree resolution
290 unsigned char elevation; // 0~7, 11.25 degree resolution
291 } __attribute__((packed)) gps_acq_sat_info_t;
294 gps_utran_gps_ref_time_t AcqUtranGpsRefTime;
295 gps_utran_gps_unc_t AcqUtranGpsUncertainty;
296 } __attribute__((packed)) gps_acq_utran_time_t;
299 unsigned long int gpsTow;
301 gps_gsm_time_t gsm_time;
302 gps_acq_utran_time_t AcqUtranTime;
303 } acquisitionTimeInfo; // --- not supported.
304 unsigned long int numberOfSat;
305 gps_acq_sat_info_t lcsAcquisitionSatInfo[16];
306 } __attribute__((packed)) gps_acq_assist_t;
309 unsigned char satId[16];
310 unsigned char numOfSat;
311 } __attribute__((packed)) gps_r_time_int_t;
316 unsigned long int flag;
317 gps_ref_time_t ref_time;
318 gps_ref_loc_t ref_loc;
319 gps_dgps_correction_t dgps_corrections;
320 gps_navi_model_t navi_model;
321 gps_iono_model_t iono_model;
322 gps_utc_model_t utc_model;
323 gps_almanac_model_t almanac;
324 gps_acq_assist_t acq_assist;
325 gps_r_time_int_t r_time_int; // not supported
326 } __attribute__((packed)) gps_assist_data_noti_t; // APGPS - GPS Assist Data Message - Notification
331 } __attribute__((packed)) sat_status_info_t;
333 const sat_status_info_t sat_status_info_table[] = {
334 { "NS_NN-U", 0}, {"NS_NN", 0}, {"ES_NN-U", 1}, {"ES_SN", 2},
339 char *pdoppler_status;
341 } __attribute__((packed)) doppler_status_info_t;
343 const doppler_status_info_t doppler_status_info_table[] = {
344 { "hz12-5", 12.5}, {"hz25", 25}, {"hz50", 50}, {"hz100", 100},
348 // postion measurement data structure.
351 GPS_METHODTYPE_INVALID,
352 GPS_METHODTYPE_MS_ASSISTED,
353 GPS_METHODTYPE_MS_BASED,
354 GPS_METHODTYPE_MS_BASED_PREF,
355 GPS_METHODTYPE_MS_ASSISTED_PREF
361 unsigned char horizontalAccuracy;
362 unsigned char vertcalAccuracy;
363 } __attribute__((packed)) gps_accuracy_t;
365 // gps_use_multi_sets_e_type
367 GPS_MULTIPLESETS_INVALID,
368 GPS_MULTIPLESETS_MULTIPLESETS,
369 GPS_MULTIPLESETS_ONESET
370 } gps_use_multi_sets_e_type;
372 // gps_env_char_e_type
374 GPS_ENVIRONMENT_INVALID,
375 GPS_ENVIRONMENT_BAD_AREA,
376 GPS_ENVIRONMENT_NOT_BAD_AREA,
377 GPS_ENVIRONMENT_MIXED_AREA
378 } gps_env_char_e_type;
380 // gps_cell_timing_wnt_e_type
382 GPS_CELLTIMING_INVALID,
383 GPS_CELLTIMING_WANTED,
384 GPS_CELLTIMING_NOT_WANTED
385 } gps_cell_timing_wnt_e_type;
387 // gps_add_assit_req_e_type
389 GPS_ADDITIONAL_ASSISREQ_INVALID,
390 GPS_ADDITIONAL_ASSISREQ_REQ,
391 GPS_ADDITIONAL_ASSISREQ_NOT_REQ
392 } gps_add_assit_req_e_type;
394 // gps measure position.
396 gps_method_e_type method_type;
397 gps_accuracy_t accuracy;
398 unsigned char rsp_time;
399 gps_use_multi_sets_e_type use_multi_sets;
400 gps_env_char_e_type environment_char;
401 gps_cell_timing_wnt_e_type cell_timing_wnt;
402 gps_add_assit_req_e_type add_assist_req;
403 } __attribute__((packed)) gps_measure_position_indi_t;
406 // APGPS - Measure Position message - confirm
408 GPS_MSR_POS_RES_LOCATION,
409 GPS_MSR_POS_RES_GPS_MEASUREMENTS,
410 GPS_MSR_POS_RES_AID_REQ,
411 GPS_MSR_POS_RES_ERROR
412 } gps_msr_pos_res_e_type;
415 unsigned char sat_id;
417 } __attribute__((packed)) gps_sat_info_t;
420 unsigned char beginWeek;
421 unsigned char endWeek;
422 unsigned char beginTow;
423 unsigned char endTow;
424 } __attribute__((packed)) gps_ext_ephe_chk_t;
427 unsigned long int assistanceFlag;
428 unsigned short gpsWeek;
429 unsigned char gpsToe;
431 unsigned char toeLimit;
432 gps_sat_info_t satInfo[15];
433 unsigned char gpsExtendedEphemeris;
434 gps_ext_ephe_chk_t extEphemerisChk;
435 } __attribute__((packed)) gps_assistance_data_t;
437 // Measure Position message
439 unsigned char satId; // Satellite ID
440 unsigned char cno; // 0~63, unit of dB-Hz
441 signed short doppler; // -32768~32767, Hz and scale factor 0.2
442 unsigned short wholeChips; // 0~1022
443 unsigned short fracChips; // 0~1024
444 unsigned char lcsMultiPath;
445 unsigned char pseuRangeRmsErr; // 0~63
446 } __attribute__((packed)) gps_measuremet_element_t;
449 unsigned long int gpsTow; // /< GPS time of week [msec]
450 unsigned short gpsWeek; // /< GPS week [0 .. 1023]
451 unsigned char nrOfSats; // /< number of satellites [1 .. 16]
452 gps_measuremet_element_t GpsMeasure[16];
453 } __attribute__((packed)) gps_measure_t;
456 signed long int latitude;
457 signed long int longitude;
458 } __attribute__((packed)) gps_ellipsoid_po_t;
461 gps_ellipsoid_po_t point;
462 unsigned char uncertainRadius;
463 } __attribute__((packed)) gps_po_unc_circle_t;
466 gps_ellipsoid_po_t point;
467 unsigned char semiMajorAxis;
468 unsigned char semiMinorAxis;
469 unsigned char orientationAngle;
470 unsigned char confidence;
471 } __attribute__((packed)) gps_po_unc_ellipse_t;
474 gps_ellipsoid_po_t point;
475 signed short altitude;
476 unsigned char semiMajorAxis;
477 unsigned char semiMinorAxis;
478 unsigned char orientationAngle;
479 unsigned char uncertainAltitude;
480 unsigned char confidence;
481 } __attribute__((packed)) gps_po_alt_unc_ellipse_t;
484 gps_ellipsoid_po_t point;
485 unsigned short innerRadius;
486 unsigned char uncertainRadius;
487 unsigned char offsetAngle;
488 unsigned char includedAngle;
489 unsigned char confidence;
490 } __attribute__((packed)) gps_ellipsoid_arc_t;
493 gps_ellipsoid_po_t point;
494 signed short altitude;
495 } __attribute__((packed)) gps_ellipsoid_alt_t;
498 unsigned char noOfPoints;
499 gps_ellipsoid_po_t points[15];
500 } __attribute__((packed)) gps_polygon_t;
504 unsigned char shape_type;
505 gps_po_unc_circle_t p_unc_clrcle;
506 gps_po_unc_ellipse_t p_unc_ellipse;
507 gps_po_alt_unc_ellipse_t p_alt_unc_ellipse;
508 gps_ellipsoid_arc_t ellipsoid_arc;
509 gps_ellipsoid_po_t ellipsoid_po;
510 gps_ellipsoid_alt_t ellipsoid_alt;
511 gps_polygon_t polygon;
512 } __attribute__((packed)) gps_loc_info_t;
516 unsigned long int gpsTow; // /< GPS time of week [msec]
517 unsigned short gpsWeek; // /< GPS week [0 .. 1023]
518 unsigned char fixType; // /< Fix type. 2D(0x01) or 3D(0x02)
519 gps_loc_info_t measured_loc_info;
520 } __attribute__((packed)) gps_measure_loc_info_t;
524 unsigned long int cellFrames;
525 unsigned char choice_mode;
526 unsigned long int UtranFdd; // FDD Primary Scrambling Code
527 unsigned long int UtranTdd; // TDD Cell Parameter ID
528 unsigned long int sfn; // SFN
529 } __attribute__((packed)) gps_utrangps_ref_time_t;
532 unsigned char result; // 0x00 : SUCCESS, 0x01 : Fail
533 gps_msr_pos_res_e_type response_type; // should be 4 byte
534 gps_measure_t gps_measure;
535 gps_measure_loc_info_t loc_info;
536 gps_assistance_data_t measured_assit_data;
537 gps_utrangps_ref_time_t UtranGpsRefTime; // only for 3G
538 } __attribute__((packed)) gps_measure_position_confirm_t; // APGPS - Measure Position message - confirm
545 static t_element elements[] = {
546 {"ref_time", REF_TIME},
547 {"location_parameters", LOCATION_PARM},
548 {"DGPS_corrections", DGPS_CORRECTION},
549 {"nav_model_elem", NAV_MODEL_ELEM},
550 {"ionospheric_model", IONOSPHERIC_MODEL},
551 {"UTC_model", UTC_MODEL},
552 {"almanac", ALMANAC},
553 {"acqu_assist", ACQU_ASSIST},
557 /**************************************************************************
558 * Local Function Prototypes
559 **************************************************************************/
561 static inline int _modem_sat_status_info_2_tel_sat_info(char *sat_info);
563 static inline int _modem_acqa_assit_doppler_2_tel_doppler(char *doppler_info);
565 static int _gps_element_compare(char *element[], char *element_str, int nelem);
567 static enum gps_assist_element_type _get_element_type(char *element_str);
569 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);
571 static void _parse_location_parameters(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist);
573 static void _parse_dgps_correction_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist);
575 static void _parse_ionospheric_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist);
577 static void _parse_utc_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist);
579 static void _parse_almanc_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist, gboolean alm_elem, int count);
581 static void _parse_acqu_assist_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist);
583 static void _parse_nav_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist, gboolean ephem_and_clock, int element_count);
585 static void _set_coordinate(xmlNodePtr node, gps_ellipsoid_po_t *point, int isalt, int altitude);
587 static void _set_loc_info_ellipse_elements(xmlNodePtr node, void *elliplse, int is_unc_ellipse);
589 static xmlChar* _generate_confirm_measure_pos_xml_text(gps_measure_position_confirm_t *gps_measure_position_confirm);
591 static gboolean on_notification_gps_measure_position_from_modem(CoreObject *o, char *file_name, void *user_data);
593 /**************************************************************************
594 * Local Function Definitions
595 **************************************************************************/
597 static inline int _modem_sat_status_info_2_tel_sat_info(char *sat_info)
601 for (count = 0; count < (int) (sizeof(sat_status_info_table) / sizeof(sat_status_info_t)); count++) {
602 if (strcmp(sat_status_info_table[count].psat_status, sat_info) == 0)
603 return (sat_status_info_table[count].stat_status);
608 static inline int _modem_acqa_assit_doppler_2_tel_doppler(char *doppler_info)
612 for (count = 0; count < (int) (sizeof(doppler_status_info_table) / sizeof(doppler_status_info_t)); count++) {
613 if (strcmp(doppler_status_info_table[count].pdoppler_status, doppler_info) == 0)
614 return (doppler_status_info_table[count].doppler_status);
619 static int _gps_element_compare(char *element[], char *element_str, int nelem)
623 for (count = 0; count < nelem; count++) {
624 if (strcmp(element[count], element_str) == 0)
632 static enum gps_assist_element_type _get_element_type(char *element_str)
636 for (index = 0; index < sizeof(elements) / sizeof(t_element); index++) {
637 if (strcmp(elements[index].name, element_str) == 0)
638 return elements[index].type;
643 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)
647 static char *element[] = {"GPS_TOW_msec", "GPS_week", "sat_id", "tlm_word", "anti_sp", "alert", "tlm_res"};
650 if (count < 0 || count >= MAX_NUM_OF_GPS_REF_TIME_ELEMENT) {
651 dbg("invalid count");
654 nelem = (int) NUM_OF_ELEMENTS(element);
655 node_count = _gps_element_compare(element, element_str, nelem);
657 if (node_count == 0) {
658 gpsdata_assist->ref_time.gpsTow = atoi(element_value);
659 dbg("gpsTow - %d\n", gpsdata_assist->ref_time.gpsTow);
660 gpsdata_assist->dgps_corrections.gpsTow = gpsdata_assist->ref_time.gpsTow;
662 } else if (node_count == 1) {
663 gpsdata_assist->ref_time.gpsWeek = atoi(element_value);
664 dbg("gpsWeek - %d\n", gpsdata_assist->ref_time.gpsWeek);
668 if (GPS_TOW_assist) {
669 switch (node_count) {
672 gpsdata_assist->ref_time.GpsTowAssist[count].satID = atoi(element_value);
673 dbg("GpsTowAssist[%d].satID = %d\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].satID);
674 gpsdata_assist->ref_time.nrOfSats = count + 1;
680 gpsdata_assist->ref_time.GpsTowAssist[count].tlmWord = atoi(element_value);
681 dbg("GpsTowAssist[%d]-tlmWord = %d\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].tlmWord);
682 gpsdata_assist->ref_time.nrOfSats = count + 1;
688 gpsdata_assist->ref_time.GpsTowAssist[count].antiSpoofFlag = *element_value;
689 dbg("GpsTowAssist[%d]-antiSpoofFlag = 0x%X\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].antiSpoofFlag);
690 gpsdata_assist->ref_time.nrOfSats = count + 1;
696 gpsdata_assist->ref_time.GpsTowAssist[count].alertFlag = *element_value;
697 dbg("GpsTowAssist[%d]-alertFlag = 0x%X\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].alertFlag);
698 gpsdata_assist->ref_time.nrOfSats = count + 1;
704 gpsdata_assist->ref_time.GpsTowAssist[count].tmlReservedBits = *element_value;
705 dbg("GpsTowAssist[%d]-tmlReservedBits = 0x%X\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].tmlReservedBits);
706 gpsdata_assist->ref_time.nrOfSats = count + 1;
711 dbg("Invalid gps element");
716 static void _parse_location_parameters(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
718 // unsigned char shapeType; and unsigned char hemisphere not supported.
720 static char *element[] = {
721 "north", "degrees", "height_above_surface", "height", "longitude", "uncert_semi_major", "uncert_semi_minor",
722 "orient_major", "confidence", "uncert_alt"
725 int nelem = (int) NUM_OF_ELEMENTS(element);
728 count = _gps_element_compare(element, element_str, nelem);
735 // gpsdata_assist.ref_loc.latitude_data.north = atoi(element_str_text);
736 // dbg("gpsdata_assist.ref_loc.latitude_data.north - %d\n",gpsdata_assist.ref_loc.latitude_data.north);
742 gpsdata_assist->ref_loc.latitude = atoi(element_value);
743 dbg("latitude_data.degrees - %d\n", gpsdata_assist->ref_loc.latitude);
749 // gpsdata_assist.ref_loc.altitude_data.height_above_surface = atoi(element_str_text);
750 // dbg("altitude_data.height_above_surface - %d\n",gpsdata_assist.ref_loc.altitude_data.height_above_surface);
756 gpsdata_assist->ref_loc.altitude = atoi(element_value); // todo- need to confirm
757 dbg("altitude_data.height - %d\n", gpsdata_assist->ref_loc.altitude);
763 gpsdata_assist->ref_loc.longitude = atoi(element_value);
764 dbg("longitude - %d\n", gpsdata_assist->ref_loc.longitude);
770 gpsdata_assist->ref_loc.semiMajorUncert = *element_value;
771 dbg("semiMajorUncert - 0x%X\n", gpsdata_assist->ref_loc.semiMajorUncert);
777 gpsdata_assist->ref_loc.semiMinorUncert = *element_value;
778 dbg("uncert_semi_minor - 0x%X\n", gpsdata_assist->ref_loc.semiMinorUncert);
784 gpsdata_assist->ref_loc.majorAxis = *element_value;
785 dbg("orient_major - 0x%X\n", gpsdata_assist->ref_loc.majorAxis);
791 gpsdata_assist->ref_loc.confidence = *element_value;
792 dbg("confidence - 0x%X\n", gpsdata_assist->ref_loc.confidence);
798 gpsdata_assist->ref_loc.altUncert = *element_value;
799 dbg("altUncert - 0x%X\n", gpsdata_assist->ref_loc.altUncert);
804 dbg("invalid element");
808 static void _parse_dgps_correction_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
812 if (strcmp(element_str, "sat_id") == 0) {
813 gpsdata_assist->dgps_corrections.seqOfSatElement[0].satId = *element_value;
814 dbg("seqOfSatElement[0].satId - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].satId);
815 } else if (strcmp(element_str, "IODE") == 0) {
816 gpsdata_assist->dgps_corrections.seqOfSatElement[0].iode = atoi(element_value);
817 dbg("seqOfSatElement[0].iode - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].iode);
818 } else if (strcmp(element_str, "UDRE") == 0) {
819 gpsdata_assist->dgps_corrections.seqOfSatElement[0].udre = *element_value;
820 dbg("seqOfSatElement[0].udre- %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].udre);
821 } else if (strcmp(element_str, "PRC") == 0) {
822 gpsdata_assist->dgps_corrections.seqOfSatElement[0].pseudoRangeCor = atoi(element_value);
823 dbg("seqOfSatElement[0].pseudoRangeCor - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].pseudoRangeCor);
824 } else if (strcmp(element_str, "RRC") == 0) {
825 gpsdata_assist->dgps_corrections.seqOfSatElement[0].rangeRateCor = atoi(element_value);
826 dbg("seqOfSatElement[0].rangeRateCor - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].rangeRateCor);
830 static void _parse_ionospheric_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
832 static char *element[] = {"alfa0", "alfa1", "alfa2", "alfa3", "beta0", "beta1", "beta2", "beta3" };
833 int nelem = (int) NUM_OF_ELEMENTS(element);
836 count = _gps_element_compare(element, element_str, nelem);
841 gpsdata_assist->iono_model.alfa0 = *element_value;
842 dbg("alfa0 - 0x%X\n", gpsdata_assist->iono_model.alfa0);
848 gpsdata_assist->iono_model.alfa1 = *element_value;
849 dbg("alfa1 - 0x%X\n", gpsdata_assist->iono_model.alfa1);
855 gpsdata_assist->iono_model.alfa2 = *element_value;
856 dbg("alfa2 - 0x%X\n", gpsdata_assist->iono_model.alfa2);
862 gpsdata_assist->iono_model.alfa3 = *element_value;
863 dbg("alfa3 - 0x%X\n", gpsdata_assist->iono_model.alfa3);
869 gpsdata_assist->iono_model.beta0 = *element_value;
870 dbg("beta0 - 0x%X\n", gpsdata_assist->iono_model.beta0);
876 gpsdata_assist->iono_model.beta1 = *element_value;
877 dbg("beta1 -0x%X\n", gpsdata_assist->iono_model.beta1);
883 gpsdata_assist->iono_model.beta2 = *element_value;
884 dbg("beta2 - 0x%X\n", gpsdata_assist->iono_model.beta2);
890 gpsdata_assist->iono_model.beta3 = *element_value;
891 dbg("beta3 - 0x%X\n", gpsdata_assist->iono_model.beta3);
896 dbg("invalid gps element");
900 void _parse_utc_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
902 static char *element[] = {"a1", "a0", "tot", "wnt", "dtls", "wnlsf", "dn", "dtlsf"};
903 int nelem = (int) NUM_OF_ELEMENTS(element);
906 count = _gps_element_compare(element, element_str, nelem);
912 gpsdata_assist->utc_model.utcA1 = atoi(element_value);
913 dbg("utcA1 - %d\n", gpsdata_assist->utc_model.utcA1);
919 gpsdata_assist->utc_model.utcA0 = atoi(element_value);
920 dbg("utcA0 - %d\n", gpsdata_assist->utc_model.utcA0);
926 gpsdata_assist->utc_model.utcTot = *element_value;
927 dbg("utcTot - 0x%X\n", gpsdata_assist->utc_model.utcTot);
933 gpsdata_assist->utc_model.utcWNt = *element_value;
934 dbg("utcWNt - 0x%X\n", gpsdata_assist->utc_model.utcWNt);
940 gpsdata_assist->utc_model.utcDeltaTls = *element_value;
941 dbg("utcDeltaTls -0x%X\n", gpsdata_assist->utc_model.utcDeltaTls);
947 gpsdata_assist->utc_model.utcWNlsf = *element_value;
948 dbg("utcWNlsf - 0x%X\n", gpsdata_assist->utc_model.utcWNlsf);
954 gpsdata_assist->utc_model.utcDN = *element_value;
955 dbg("utcDN - 0x%X\n", gpsdata_assist->utc_model.utcDN);
961 gpsdata_assist->utc_model.utcDeltaTlsf = *element_value;
962 dbg("utcDeltaTlsf - 0x%X\n", gpsdata_assist->utc_model.utcDeltaTlsf);
967 dbg("invalid gps element");
971 static void _parse_almanc_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist,
972 gboolean alm_elem, int count)
976 static char *element[] = {
977 "wna", "data_id", "sat_id", "alm_ecc", "alm_toa", "alm_ksii", "alm_omega_dot", "alm_sv_health", "alm_power_half",
978 "alm_omega0", "alm_omega", "alm_m0", "alm_af0", "alm_af1"
982 if (count < 0 || count >= MAX_NUM_OF_GPS_ALMANC_ELEMENTS) {
983 dbg("invalid count");
986 nelem = (int) NUM_OF_ELEMENTS(element);
988 node_count = _gps_element_compare(element, element_str, nelem);
989 if (node_count == 0) {
990 gpsdata_assist->almanac.almanacWNa = *element_value;
991 dbg("almanacWNa - %d\n", gpsdata_assist->almanac.almanacWNa);
996 switch (node_count) {
999 gpsdata_assist->almanac.AlmanacSatInfo[count].dataId = *element_value;
1000 dbg("AlmanacSatInfo[%d].data_id - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].dataId);
1006 gpsdata_assist->almanac.AlmanacSatInfo[count].satId = *element_value;
1007 dbg("AlmanacSatInfo[%d].sat_id - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].satId);
1013 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacE = atoi(element_value);
1014 dbg("AlmanacSatInfo[%d].almanacE - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacE);
1020 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacToa = *element_value;
1021 dbg("AlmanacSatInfo[%d].almanacToa - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacToa);
1027 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacKsii = *element_value;
1028 dbg("AlmanacSatInfo[%d].almanacKsii - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacKsii);
1034 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmegaDot = *element_value;
1035 dbg("AlmanacSatInfo[%d].almanacOmegaDot - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmegaDot);
1041 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacSvHealth = *element_value;
1042 dbg("AlmanacSatInfo[%d].almanacSvHealth - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacSvHealth);
1048 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAPowerHalf = atoi(element_value);
1049 dbg("AlmanacSatInfo[%d].almanacAPowerHalf - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAPowerHalf);
1055 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmega0 = atoi(element_value);
1056 dbg("AlmanacSatInfo[%d].almanacOmega0 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmega0);
1062 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacW = atoi(element_value);
1063 dbg("AlmanacSatInfo[%d].almanacW - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacW);
1069 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacM0 = atoi(element_value);
1070 dbg("AlmanacSatInfo[%d].almanacM0 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacM0);
1076 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf0 = atoi(element_value);
1077 dbg("AlmanacSatInfo[%d].almanacAf0 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf0);
1083 gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf1 = atoi(element_value);
1084 dbg("AlmanacSatInfo[%d].almanacAf1 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf1);
1089 dbg("invalid gps element");
1095 static void _parse_acqu_assist_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
1097 static char *element[] = {"tow_msec", "sat_id", "dopl0", "dopl1", "code_ph", "code_ph_int", "GPS_bitno", "srch_w", "az", "elev"};
1098 int nelem = (int) NUM_OF_ELEMENTS(element);
1101 count = _gps_element_compare(element, element_str, nelem);
1106 gpsdata_assist->acq_assist.gpsTow = atoi(element_value);
1107 dbg("acq_assist.gpsTow - %d\n", gpsdata_assist->acq_assist.gpsTow);
1111 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].satId = *element_value;
1112 dbg("lcsAcquisitionSatInfo[0].satId - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].satId);
1116 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler0 = atoi(element_value);
1117 dbg("lcsAcquisitionSatInfo[0].dopl0 - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler0);
1121 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler1 = *element_value;
1122 dbg("lcsAcquisitionSatInfo[0].doppler1 - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler1);
1126 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhase = atoi(element_value);
1127 dbg("lcsAcquisitionSatInfo[0].codePhase - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhase);
1131 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].intCodePhase = *element_value;
1132 dbg("lcsAcquisitionSatInfo[0].intCodePhase - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].intCodePhase);
1136 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].gpsBitNumber = *element_value;
1137 dbg("lcsAcquisitionSatInfo[0].GPS_bitno - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].gpsBitNumber);
1141 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhaseSearchWindow = *element_value;
1142 dbg("lcsAcquisitionSatInfo[0].codePhaseSearchWindow - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhaseSearchWindow);
1146 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].azimuth = *element_value;
1147 dbg("lcsAcquisitionSatInfo[0].azimuth - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].azimuth);
1151 gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].elevation = *element_value;
1152 dbg("lcsAcquisitionSatInfo[0].elevation - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].elevation);
1156 dbg("invalid gps element");
1160 static void _parse_nav_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t
1161 *gpsdata_assist, gboolean ephem_and_clock, int element_count)
1163 static char *element[] = {
1164 "sat_id", "l2_code", "ura", "sv_health", "iodc", "l2p_flag", "esr1", "esr2", "esr3", "esr4", "tgd", "toc", "af2", "af0",
1165 "crs", "delta_n", "m0", "cuc", "ecc", "cus", "power_half", "toe", "fit_flag", "aoda", "cic", "omega0", "cis", "i0", "crc", "omega", "idot", "omega_dot"
1168 int nelem = (int) NUM_OF_ELEMENTS(element);
1171 if (element_count < 0 || element_count >= MAX_NUM_OF_GPS_NAV_ELEMENT) {
1172 dbg("invalid count");
1175 count = _gps_element_compare(element, element_str, nelem);
1179 gpsdata_assist->navi_model.NavigationSatInfo[element_count].satId = *element_value;
1180 dbg("NavigationSatInfo[%d].satId - 0x%X\n", element_count, gpsdata_assist->navi_model.NavigationSatInfo[element_count].satId);
1184 if (ephem_and_clock) {
1187 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCodeOnL2 = *element_value;
1191 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemUra = *element_value;
1195 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemSvHealth = *element_value;
1199 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemIodc = atoi(element_value);
1203 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemL2PFlag = *element_value;
1207 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv1 = atoi(element_value);
1211 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv2 = atoi(element_value);
1215 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv3 = atoi(element_value);
1219 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv4 = atoi(element_value);
1223 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemTgd = *element_value;
1227 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemToc = atoi(element_value);
1231 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAf2 = *element_value;
1235 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAf1 = atoi(element_value);
1239 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAf0 = atoi(element_value);
1243 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCrs = atoi(element_value);
1247 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemDeltaN = atoi(element_value);
1251 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemM0 = atoi(element_value);
1255 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCuc = atoi(element_value);
1259 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemE = atoi(element_value);
1263 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCus = atoi(element_value);
1267 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAPowrHalf = atoi(element_value);
1271 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemToe = atoi(element_value);
1275 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemFitFlag = *element_value;
1279 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAoda = *element_value;
1283 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCic = atoi(element_value);
1287 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemI0 = atoi(element_value);
1291 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCrc = atoi(element_value);
1295 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemW = atoi(element_value);
1299 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemIDot = atoi(element_value);
1303 gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemOmegaADot = atoi(element_value);
1304 dbg("NavigationSatInfo[%d].NavigationEphemeris.ephemOmegaADot - 0x%X\n", element_count, gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemOmegaADot);
1308 dbg("invalid gps element");
1314 // Set coordinate elements : <latitude> <longitude> <altitude>
1315 static void _set_coordinate(xmlNodePtr node, gps_ellipsoid_po_t *point, int isalt, int altitude)
1317 // <parent_node> .. .. (xmlNodePtr node)
1318 // <coordinate> <latitude> <north>0</north> <degrees>0</degrees> </latitude> <longitude>0</longitude> </coordinate>
1319 // <altitude> <height_above_surface>0</height_above_surface> <height>0</height> </altitude>
1320 // .. .. <\parent_node>
1322 xmlNodePtr coordinate_node = NULL, temp_node = NULL;
1324 memset(node_name, 0x00, sizeof(node_name));
1325 memset(node_value, 0x00, sizeof(node_value));
1327 sprintf(node_name, "%s", "coordinate");
1328 coordinate_node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
1330 sprintf(node_name, "%s", "latitude");
1331 temp_node = xmlNewChild(coordinate_node, NULL, BAD_CAST node_name, NULL);
1333 sprintf(node_name, "%s", "north");
1334 sprintf(node_value, "%d", 0);
1335 xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1337 sprintf(node_name, "%s", "degrees");
1338 sprintf(node_value, "%d", (int) point->latitude);
1339 xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1341 sprintf(node_name, "%s", "longitude");
1342 sprintf(node_value, "%d", (int) point->longitude);
1343 xmlNewChild(coordinate_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1346 sprintf(node_name, "%s", "altitude");
1347 temp_node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
1348 sprintf(node_name, "%s", "height_above_surface");
1349 sprintf(node_value, "%d", 0);
1350 xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1351 sprintf(node_name, "%s", "height");
1352 sprintf(node_value, "%d", altitude);
1353 xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1358 static void _set_loc_info_ellipse_elements(xmlNodePtr node, void *elliplse, int is_unc_ellipse)
1360 gps_po_unc_ellipse_t *p_unc_ellipse;
1361 gps_po_alt_unc_ellipse_t *p_alt_unc_ellipse;
1362 unsigned char semiMajorAxis, semiMinorAxis, orientationAngle, confidence;
1364 memset(node_name, 0x00, sizeof(node_name));
1365 memset(node_value, 0x00, sizeof(node_value));
1367 if (is_unc_ellipse) {
1368 p_unc_ellipse = (gps_po_unc_ellipse_t *) elliplse;
1369 semiMajorAxis = p_unc_ellipse->semiMajorAxis;
1370 semiMinorAxis = p_unc_ellipse->semiMinorAxis;
1371 orientationAngle = p_unc_ellipse->orientationAngle;
1372 confidence = p_unc_ellipse->confidence;
1374 p_alt_unc_ellipse = (gps_po_alt_unc_ellipse_t *) elliplse;
1375 semiMajorAxis = p_alt_unc_ellipse->semiMajorAxis;
1376 semiMinorAxis = p_alt_unc_ellipse->semiMinorAxis;
1377 orientationAngle = p_alt_unc_ellipse->orientationAngle;
1378 confidence = p_alt_unc_ellipse->confidence;
1381 sprintf(node_name, "%s", "uncert_semi_major");
1382 sprintf(node_value, "%d", semiMajorAxis);
1383 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1385 sprintf(node_name, "%s", "uncert_semi_minor");
1386 sprintf(node_value, "%d", semiMinorAxis);
1387 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1389 sprintf(node_name, "%s", "orient_major");
1390 sprintf(node_value, "%d", orientationAngle);
1391 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1393 sprintf(node_name, "%s", "confidence");
1394 sprintf(node_value, "%d", confidence);
1395 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1398 static xmlChar* _generate_confirm_measure_pos_xml_text(gps_measure_position_confirm_t *gps_measure_position_confirm)
1400 xmlDocPtr doc = NULL;
1401 xmlNodePtr root_node = NULL, node = NULL;
1402 xmlNodePtr gps_msr_node = NULL, shape_data_node = NULL, loc_child_node = NULL;
1403 xmlChar *xml = NULL;
1404 int count = 0, altitude, size;
1407 Creates a new XML document
1408 ================================================================================================================================
1411 <?xml version="1.0"?>
1412 <pos xsi:noNamespaceSchemaLocation="pos.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
1415 <tow_msec></tow_msec>
1418 <sat_id></sat_id><carr2_noise></carr2_noise><dopl></dopl><whole_chips></whole_chips><fract_chips></fract_chips>
1419 <multi_path literal="xx"></multi_path> <psr_rms_err></psr_rms_err>
1423 <time_of_fix></time_of_fix><
1424 <location_parameters>
1428 <latitude><north></north><degrees></degrees></latitude><longitude></longitude>
1431 <ellipsoid_point_uncert_circle>
1432 <uncert_circle></uncert_circle>
1434 <latitude> <> <\> ...</latitude> <longitude></longitude>
1436 </ellipsoid_point_uncert_circle>
1437 <ellipsoid_point_uncert_ellipse>
1439 <latitude><> <\>..<longitude></longitude>
1441 <uncert_ellipse><uncert_semi_major></uncert_semi_major><uncert_semi_minor></uncert_semi_minor>
1442 <orient_major></orient_major><confidence></confidence></uncert_ellipse>
1443 </ellipsoid_point_uncert_ellipse>
1446 <latitude><> <\>...</latitude><longitude></longitude>
1449 <ellipsoid_point_alt>
1451 <latitude><> <\>..</latitude><longitude></longitude>
1454 <height_above_surface></height_above_surface><height></height>
1456 </ellipsoid_point_alt>
1457 <ellipsoid_point_alt_uncertellipse>
1459 <latitude> <> <\>.. ..</latitude><longitude></longitude>
1462 <height_above_surface></height_above_surface><height></height>
1464 <uncert_semi_major></uncert_semi_major><uncert_semi_minor></uncert_semi_minor><orient_major></orient_major>
1465 <confidence></confidence><uncert_alt></uncert_alt>
1466 </ellipsoid_point_alt_uncertellipse>
1469 <latitude><> <\> .. </latitude><longitude></longitude>
1471 <inner_rad></inner_rad>
1472 <uncert_rad></uncert_rad><offset_angle></offset_angle><included_angle></included_angle>
1473 <confidence></confidence>
1476 </location_parameters>
1482 ================================================================================================================================
1485 doc = xmlNewDoc(BAD_CAST "1.0");
1488 memset(node_name, 0x00, sizeof(node_name));
1489 memset(node_value, 0x00, sizeof(node_value));
1491 sprintf(node_name, "%s", POSITION_NODE);
1492 // Creation of a new node element
1493 root_node = xmlNewNode(NULL, BAD_CAST node_name);
1494 // Set the root element of the document
1495 xmlDocSetRootElement(doc, root_node);
1496 sprintf(node_name, "%s", POSITION_NODE_ATTR_XSI);
1497 sprintf(node_value, "%s", POSITION_NODE_ATTR_VAL_XSI);
1498 // Create a new property carried by a node
1499 xmlNewProp(root_node, BAD_CAST node_name, BAD_CAST node_value);
1501 sprintf(node_name, "%s", POSITION_NODE_ATTR_XMLNS);
1502 sprintf(node_value, "%s", POSITION_NODE_ATTR_VAL_XMLNS);
1503 xmlNewProp(root_node, BAD_CAST node_name, BAD_CAST node_value);
1506 // Creation of a new child element, added at the end of @parent children list
1507 sprintf(node_name, "%s", "GPS_meas");
1508 gps_msr_node = xmlNewChild(root_node, NULL, BAD_CAST node_name, NULL);
1510 sprintf(node_name, "%s", "ref_time_only");
1511 node = xmlNewChild(gps_msr_node, NULL, BAD_CAST node_name, NULL);
1513 sprintf(node_name, "%s", "tow_msec");
1514 sprintf(node_value, "%d", (int) gps_measure_position_confirm->gps_measure.gpsTow);
1515 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1517 // creatation of <meas_params> elements.
1518 for (count = 0; count < gps_measure_position_confirm->gps_measure.nrOfSats; count++) {
1519 xmlNodePtr multipath_node = NULL;
1520 sprintf(node_name, "%s", "meas_params");
1521 node = xmlNewChild(gps_msr_node, NULL, BAD_CAST node_name, NULL);
1523 sprintf(node_name, "%s", "sat_id");
1524 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].satId);
1525 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1527 sprintf(node_name, "%s", "carr2_noise");
1528 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].cno);
1529 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1531 sprintf(node_name, "%s", "dopl");
1532 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].doppler);
1533 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1535 sprintf(node_name, "%s", "whole_chips");
1536 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].wholeChips);
1537 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1539 sprintf(node_name, "%s", "fract_chips");
1540 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].fracChips);
1541 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1543 sprintf(node_name, "%s", "multi_path");
1544 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].lcsMultiPath);
1545 multipath_node = xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1546 xmlNewProp(multipath_node, BAD_CAST "literal", BAD_CAST "not_measured");
1548 sprintf(node_name, "%s", "psr_rms_err");
1549 sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].pseuRangeRmsErr);
1550 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1554 sprintf(node_name, "%s", "location");
1555 node = xmlNewChild(root_node, NULL, BAD_CAST node_name, NULL);
1557 sprintf(node_name, "%s", "time_of_fix");
1558 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.fixType);
1559 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1561 // location_parameters
1562 sprintf(node_name, "%s", "location_parameters");
1563 node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
1566 sprintf(node_name, "%s", "shape_data");
1567 shape_data_node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
1570 sprintf(node_name, "%s", "ellipsoid_point");
1571 node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1573 _set_coordinate(node, &(gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_po), 0, 0);
1575 // ellipsoid_point_uncert_circle
1576 sprintf(node_name, "%s", "ellipsoid_point_uncert_circle");
1577 node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1578 sprintf(node_name, "%s", "uncert_circle");
1579 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_clrcle.uncertainRadius);
1580 xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1581 // set coordinate parameters.
1582 _set_coordinate(node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_clrcle.point), 0, 0);
1584 // ellipsoid_point_uncert_ellipse
1585 sprintf(node_name, "%s", "ellipsoid_point_uncert_ellipse");
1586 loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1587 // set coordinate parameters.
1588 _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_clrcle.point), 0, 0);
1590 sprintf(node_name, "%s", "uncert_ellipse");
1591 node = xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, NULL);
1592 // set location ellipse parametes.
1593 _set_loc_info_ellipse_elements(node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_ellipse), 1);
1595 sprintf(node_name, "%s", "polygon");
1596 loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1597 for (count = 0; count < gps_measure_position_confirm->loc_info.measured_loc_info.polygon.noOfPoints; count++) {
1598 // set coordinate parameters.
1599 _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.polygon.points[count]), 0, 0);
1602 // ellipsoid_point_alt
1603 sprintf(node_name, "%s", "ellipsoid_point_alt");
1604 loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1605 altitude = gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_alt.altitude;
1606 // set coordinate parameters.
1607 _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_alt.point), 1, altitude);
1609 // ellipsoid_point_alt_uncertellipse
1610 sprintf(node_name, "%s", "ellipsoid_point_alt_uncertellipse");
1611 loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1612 altitude = gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse.altitude;
1613 // set coordinate parameters.
1614 _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse.point), 1, altitude);
1615 // set location ellipse parametes.
1616 _set_loc_info_ellipse_elements(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse), 0);
1618 sprintf(node_name, "%s", "uncert_alt");
1619 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse.uncertainAltitude);
1620 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1622 // ellipsoid_point_alt_uncertellipse
1623 sprintf(node_name, "%s", "ellips_arc");
1624 loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
1625 _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.point), 0, 0);
1627 sprintf(node_name, "%s", "inner_rad");
1628 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.innerRadius);
1629 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1631 sprintf(node_name, "%s", "uncert_rad");
1632 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.uncertainRadius);
1633 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1635 sprintf(node_name, "%s", "offset_angle");
1636 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.offsetAngle);
1637 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1639 sprintf(node_name, "%s", "included_angle");
1640 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.includedAngle);
1641 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1643 sprintf(node_name, "%s", "confidence");
1644 sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.confidence);
1645 xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
1647 // 3. assist data /msr_assist_data
1648 sprintf(node_name, "%s", "assist_data");
1649 node = xmlNewChild(root_node, NULL, BAD_CAST node_name, NULL);
1650 sprintf(node_name, "%s", "msr_assist_data");
1651 xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
1653 // Dump an XML document in memory and return the #xmlChar * and it's size in bytes
1654 xmlDocDumpMemory(doc, &xml, &size);
1655 dbg("xmlcontetnt:\n");
1656 dbg("%s", (char *) xml);
1657 // Free up all the structures used by a document, tree included.
1663 static gboolean on_notification_gps_assist_data(CoreObject *o, const void *event_info, void *user_data)
1666 gps_assist_data_noti_t gps_data_assist;
1667 char *node = NULL, *node_value = NULL;
1668 char *attribute = NULL, *attr_value = NULL;
1669 enum gps_assist_element_type node_type = -1, set_element_type = -1;
1670 int nav_model_node_count = -1;
1671 int alm_node_count = -1;
1672 int gps_tow_assist_count = -1;
1673 char *line = NULL, *pos = NULL;
1674 char *xml_line = NULL;
1676 xmlTextReaderPtr reader;
1677 gboolean _gps_assist_data = FALSE, gps_tow_assist = FALSE;
1678 gboolean ephem_and_clock = FALSE, alm_elem = FALSE;
1679 const char *path = NULL;
1684 Example:GPS assist XML data will be in below format.
1685 ================================================================================================================================
1686 +CPOSR:<?xml version="1.0" encoding="UTF-8"?>
1687 <pos xsi:noNamespaceSchemaLocation="pos.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
1691 <GPS_time> <> <\>..<\GPS_time> <GPS_TOW_assist*> <> <\> ..<\GPS_TOW_assist>
1694 <location_parameters>
1695 <shape_data> <ellipsoid_point_alt_uncertellipse> </coordinate> <> <\>...</coordinate> <altitude> <\altitude>
1696 <uncert_semi_major> </uncert_semi_major> <uncert_semi_minor> </uncert_semi_minor> <orient_major> </orient_major> <confidence> </confidence>
1697 <uncert_alt> </uncert_alt> </ellipsoid_point_alt_uncertellipse> </shape_data>
1698 </location_parameters>
1701 <sat_id> </sat_id> <IODE> </IODE> <UDRE></UDRE> <PRC></PRC> <RRC></RRC>
1705 <sat_id> </sat_id> <sat_status literal="xx"></sat_status>
1706 <ephem_and_clock?> <l2_code></l2_code> <> <\> .. .. <\ephem_and_clock>
1709 <ionospheric_model> <alfa0> </alfa0> <alfa1> </alfa1> <alfa2> </alfa2> <alfa3></alfa3>
1710 <beta0></beta0> <beta1></beta1> <beta2></beta2> <beta3> </beta3>
1711 </ionospheric_model>
1714 <a1></a1><a0></a0><tot></tot><wnt></wnt> <dtls></dtls> <wnlsf></wnlsf> <dn></dn><dtlsf></dtlsf>
1717 <wna>0</wna> <alm_elem*> <> <\> ...<\alm_elem>
1721 <tow_msec></tow_msec> <sat_info> <> <\> ... <\sat_info>
1727 ================================================================================================================================
1730 memset((void *) &gps_data_assist, 0x00, sizeof(gps_data_assist));
1731 xml_line = (char *) ((GSList *) event_info)->data;
1733 if (g_str_has_prefix((char *) xml_line, "+CPOSR:")) {
1734 dbg("notification line with prefix");
1735 pos = (char *) xml_line + strlen("+CPOSR:");
1737 pos = (char *) xml_line;
1739 line = g_strdup((char *) pos);
1741 path = tzplatform_mkpath(TZ_SYS_ROOT, "sample.xml");
1743 if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, S_IRWXU)) == -1) {
1744 dbg("Cannot open file\n");
1748 // write gps xml data into file.
1749 if (write(fd, (const void *) line, strlen(line)) == -1) {
1750 dbg("Cannot write into file\n");
1755 // free the memory pointed to by line.
1758 dbg("read xml file");
1759 reader = xmlReaderForFile(path, NULL, 0);
1761 while (xmlTextReaderRead(reader) == 1) {
1762 // Get the node type of the current node
1763 switch (xmlTextReaderNodeType(reader)) {
1764 case XML_READER_TYPE_ELEMENT:
1766 // Read the qualified name of the node.
1767 node = (char *) xmlTextReaderConstName(reader);
1768 dbg("Element: %s\n ", node);
1770 // check type of sub element of <GPS_assist>
1771 set_element_type = _get_element_type(node);
1772 if ((int) set_element_type != -1) // ignore negative value as excepted element type not set.
1773 node_type = set_element_type;
1775 dbg("xml node type : %d", node_type);
1777 // Check for position measurement data.
1778 if (strcmp(node, "pos_meas") == 0) {
1779 // Deallocate all the resources associated to the reader
1780 xmlFreeTextReader(reader);
1782 dbg("gps postion measurement notification ");
1783 // GPS position measurement notification.
1784 ret = on_notification_gps_measure_position_from_modem(o, path, user_data);
1787 if (access(path, F_OK) == 0) {
1789 dbg("file removed");
1794 // Moves the position of the current instance to the next attribute associated with the current node.
1795 while (xmlTextReaderMoveToNextAttribute(reader)) {
1796 // Read the qualified name of the node
1797 attribute = (char *) xmlTextReaderConstName(reader);
1798 dbg("attribute value - %s\n", attribute);
1800 // Provides the text value of the node if present.
1801 attr_value = (char *) xmlTextReaderConstValue(reader);
1802 dbg("=\"%s\"\n", attr_value);
1804 // Read attribute value of <nav_model_elem>
1805 if (node_type == NAV_MODEL_ELEM) {
1806 if (strcmp(node, "sat_status") == 0 && strcmp(attribute, "literal") == 0) {
1807 gps_data_assist.navi_model.NavigationSatInfo[nav_model_node_count].NavigationSatStatus = _modem_sat_status_info_2_tel_sat_info(attr_value);
1808 dbg("navigation sat status of nav model element - %d\n", gps_data_assist.navi_model.NavigationSatInfo[nav_model_node_count].NavigationSatStatus);
1811 // Read attribute value of <acqu_assist>
1812 else if (node_type == ACQU_ASSIST) {
1813 if (strcmp(node, "dopl1_uncert") == 0 && strcmp(attribute, "literal") == 0) {
1814 gps_data_assist.acq_assist.lcsAcquisitionSatInfo[0].dopplerUncertainty = _modem_acqa_assit_doppler_2_tel_doppler(attr_value);
1815 dbg("doppler uncertainty of acqu assist data- %d", gps_data_assist.acq_assist.lcsAcquisitionSatInfo[0].dopplerUncertainty);
1818 } // end of attribute check.
1820 // check GPS data is having GPS_assist data.
1821 if (strcmp(node, "GPS_assist") == 0) {
1822 _gps_assist_data = TRUE;
1825 if (_gps_assist_data == TRUE) {
1826 // number of GPS_TOW_assist elements.
1827 if (strcmp(node, "GPS_TOW_assist") == 0) {
1828 gps_tow_assist_count++;
1829 gps_tow_assist = TRUE;
1830 } else if (strcmp(node, "nav_model_elem") == 0) {
1831 // number of nav_model_elem.
1832 nav_model_node_count++;
1833 } else if (strcmp(node, "alm_elem") == 0) {
1834 // number of alm_elem elements.
1836 dbg("alm_elem_count - %d", alm_node_count);
1837 if (node_type == ALMANAC)
1839 } else if (strcmp(node, "ephem_and_clock") == 0 && node_type == NAV_MODEL_ELEM) {
1840 ephem_and_clock = TRUE;
1844 xmlTextReaderMoveToElement(reader);
1845 } // end of reading node type.
1848 case XML_READER_TYPE_TEXT:
1850 // Provides the text value of the node if present
1851 node_value = (char *) xmlTextReaderConstValue(reader);
1852 dbg("node_value: %s\n", node_value);
1854 if (node_value != NULL) {
1855 switch (node_type) {
1857 _parse_ref_time_gps_elements(node, node_value, &gps_data_assist, gps_tow_assist, gps_tow_assist_count);
1861 _parse_location_parameters(node, node_value, &gps_data_assist);
1864 case DGPS_CORRECTION:
1865 _parse_dgps_correction_gps_elements(node, node_value, &gps_data_assist);
1868 case NAV_MODEL_ELEM:
1869 _parse_nav_model_gps_elements(node, node_value, &gps_data_assist, ephem_and_clock, nav_model_node_count);
1872 case IONOSPHERIC_MODEL:
1873 _parse_ionospheric_model_gps_elements(node, node_value, &gps_data_assist);
1877 _parse_utc_model_gps_elements(node, node_value, &gps_data_assist);
1881 _parse_almanc_model_gps_elements(node, node_value, &gps_data_assist, alm_elem, alm_node_count);
1885 _parse_acqu_assist_gps_elements(node, node_value, &gps_data_assist);
1889 dbg("invalid element");
1892 } // end of reading node value.
1895 } // end of parsing.
1897 // Deallocate all the resources associated to the reader
1898 xmlFreeTextReader(reader);
1903 if (access(path, F_OK) == 0) {
1905 dbg("file removed");
1908 tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)),
1909 o, TNOTI_GPS_ASSIST_DATA, sizeof(gps_data_assist), &gps_data_assist);
1913 static gboolean on_notification_gps_measure_position_from_modem(CoreObject *o, char *file_name, void *user_data)
1915 char *node = NULL, *node_value = NULL;
1916 char *attribute = NULL;
1917 char *attr_value = NULL;
1918 gps_measure_position_indi_t gps_measure_position_indi;
1919 gboolean rep_quant = FALSE;
1920 xmlTextReaderPtr reader;
1922 memset(&gps_measure_position_indi, 0x00, sizeof(gps_measure_position_indi));
1923 reader = xmlReaderForFile(file_name, NULL, 0);
1925 while (xmlTextReaderRead(reader) == 1) {
1926 switch (xmlTextReaderNodeType(reader)) {
1927 case XML_READER_TYPE_ELEMENT:
1929 node = (char *) xmlTextReaderConstName(reader);
1930 dbg("Element: %s", node);
1932 // Read attribute value.
1933 while (xmlTextReaderMoveToNextAttribute(reader)) {
1934 attribute = (char *) xmlTextReaderConstName(reader);
1935 dbg("Attribute value - %s\n", attribute);
1936 attr_value = (char *) xmlTextReaderConstValue(reader);
1937 dbg("=\"%s\"\n", attr_value);
1939 if (strcmp(node, "mult_sets") == 0) {
1940 if (strcmp(attribute, "literal") == 0) {
1941 if (strcmp(attr_value, "one") == 0)
1942 gps_measure_position_indi.use_multi_sets = GPS_MULTIPLESETS_ONESET;
1943 else if (strcmp(attr_value, "multiple") == 0)
1944 gps_measure_position_indi.use_multi_sets = GPS_MULTIPLESETS_MULTIPLESETS;
1946 dbg("gps_measure_position_indi.use_multi_sets - 0x%x\n", gps_measure_position_indi.use_multi_sets);
1947 } else if (strcmp(node, "rep_quant") == 0) {
1949 if (strcmp(attribute, "addl_assist_data_req") == 0) {
1950 if (strcmp(attr_value, "true") == 0)
1951 gps_measure_position_indi.add_assist_req = GPS_ADDITIONAL_ASSISREQ_REQ;
1953 gps_measure_position_indi.add_assist_req = GPS_ADDITIONAL_ASSISREQ_NOT_REQ;
1954 } else if (strcmp(attribute, "gps_timing_of_cell_wanted") == 0) {
1955 if (strcmp(attr_value, "true") == 0)
1956 gps_measure_position_indi.cell_timing_wnt = GPS_CELLTIMING_WANTED;
1958 gps_measure_position_indi.cell_timing_wnt = GPS_CELLTIMING_NOT_WANTED;
1961 } // end of attribute check
1963 if (strcmp(node, "ms_assisted") == 0) {
1964 gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_ASSISTED;
1965 } else if (strcmp(node, "ms_assisted_no_accuracy") == 0) {
1966 gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_ASSISTED;
1967 } else if (strcmp(node, "ms_based") == 0) {
1968 gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_BASED;
1969 } else if (strcmp(node, "ms_based_pref") == 0) {
1970 gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_BASED_PREF;
1971 } else if (strcmp(node, "ms_assisted_pref") == 0) {
1972 gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_ASSISTED_PREF;
1975 xmlTextReaderMoveToElement(reader);
1979 case XML_READER_TYPE_TEXT:
1981 node_value = (char *) xmlTextReaderConstValue(reader);
1982 dbg("element-value: %s", node_value);
1983 if (node_value != NULL) {
1984 if (strcmp(node, "resp_time_seconds") == 0) {
1985 gps_measure_position_indi.rsp_time = *node_value;
1986 dbg("gps_measure_position_indi.rsp_time - 0x%x", gps_measure_position_indi.rsp_time);
1988 if (rep_quant == TRUE) {
1989 if (strcmp(node, "hor_acc") == 0)
1990 gps_measure_position_indi.accuracy.horizontalAccuracy = *node_value;
1991 else if (strcmp(node, "vert_acc") == 0)
1992 gps_measure_position_indi.accuracy.vertcalAccuracy = *node_value;
1999 xmlFreeTextReader(reader);
2002 tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)),
2003 o, TNOTI_GPS_MEASURE_POSITION, sizeof(gps_measure_position_indi), &gps_measure_position_indi);
2009 static void on_confirmation_gps_message_send(TcorePending *p, gboolean result, void *user_data)
2013 if (result == FALSE) { // Fail
2023 static gboolean on_notification_reset_assist_data(CoreObject *o, const void *event_info, void *user_data)
2026 tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)),
2027 o, TNOTI_GPS_RESET_ASSIST_DATA, 0, NULL);
2031 static void on_confirmation_gps_measure_position(TcorePending *p, int data_len, const void *data, void *user_data)
2033 //GPS server does not except confirmation for GPS measure position request.
2039 static TReturn gps_confirm_measure_pos(CoreObject *o, UserRequest *ur)
2041 char *raw_str = NULL;
2042 char *cmd_str = NULL;
2043 TcorePending *pending = NULL;
2044 TcoreATRequest *req = NULL;
2045 TcoreHal *hal = NULL;
2046 gboolean ret = FALSE;
2047 xmlChar *xml = NULL;
2048 unsigned char *data = NULL;
2049 unsigned int data_len;
2050 gps_measure_position_confirm_t gps_measure_pos_confirm;
2054 return TCORE_RETURN_EINVAL;
2056 data = (unsigned char *) tcore_user_request_ref_data(ur, &data_len);
2057 memcpy(&gps_measure_pos_confirm, data, data_len);
2059 // make confirm measure postion request in xml format.
2060 xml = _generate_confirm_measure_pos_xml_text(&gps_measure_pos_confirm);
2062 err("xml text generation failed");
2063 return TCORE_RETURN_EINVAL;
2066 // AT+CPOS<cr>text is entered<ctrl-z/esc>
2067 raw_str = g_strdup_printf("AT+CPOS%s", "\r");
2068 cmd_str = g_strdup_printf("%s%s\x1A", raw_str, xml);
2070 dbg("command string : %s", cmd_str);
2071 pending = tcore_pending_new(o, 0);
2072 req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
2073 dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
2074 tcore_pending_set_request_data(pending, strlen(cmd_str), req);
2075 tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
2076 tcore_pending_set_send_callback(pending, on_confirmation_gps_message_send, NULL);
2077 tcore_pending_set_response_callback(pending, on_confirmation_gps_measure_position, NULL);
2078 tcore_pending_link_user_request(pending, ur);
2081 hal = tcore_object_get_hal(o);
2082 // Send request to HAL
2083 ret = tcore_hal_send_request(hal, pending);
2084 if (TCORE_RETURN_SUCCESS != ret) {
2085 err("Request send failed");
2096 static struct tcore_gps_operations gps_ops = {
2097 .confirm_measure_pos = gps_confirm_measure_pos,
2100 gboolean s_gps_init(TcorePlugin *cp, CoreObject *co_gps)
2104 tcore_gps_override_ops(co_gps, &gps_ops);
2106 tcore_object_override_callback(co_gps, "+CPOSR", on_notification_gps_assist_data, NULL);
2107 tcore_object_override_callback(co_gps, "+XCPOSR", on_notification_reset_assist_data, NULL);
2114 void s_gps_exit(TcorePlugin *cp, CoreObject *co_gps)