Init basesystem source codes.
[staging/basesystem.git] / vehicleservice / positioning / client / src / POS_common_API / Common_API.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file
19  *    Common_API.cpp
20  * @brief
21  *   Module : POSITIONING
22  *   Common I/F service functionality
23  */
24 #include <vehicle_service/positioning_base_library.h>
25 #include <vehicle_service/POS_define.h>
26 #include <vehicle_service/POS_common_API.h>
27 #include "POS_common_private.h"
28 #include "Vehicle_API_private.h"
29 #include "POS_private.h"
30
31 /**
32  * @brief
33  *  Latitude and longitude informationDelivery registration
34  *
35  *  Registering Latitude and Longitude Information Delivery
36  *
37  * @param[in] hApp              HANDLE  - Application handle
38  * @param[in] notifyName        PCSTR   - Destination thread name
39  * @param[in] ucCtrlFlg         uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery)
40  * @param[in] ucDeliveryTiming  uint8_t - Delivery timing(Changing/Updating)
41  * @param[in] ucGetMethod       uint8_t - Acquisition method(GPS/Navigation/Not specified)
42  *
43  * @return POS_RET_NORMAL               Normal completion(Include illegal)<br>
44  *         POS_RET_ERROR_BUFFULL        Buffer-full<br>
45  *         POS_RET_ERROR_INNER          Internal error<br>
46  *         POS_RET_ERROR_PARAM          Parameter error<br>
47  *         POS_RET_ERROR_NOSUPPORT      Unsupported environment
48  *
49  */
50 POS_RET_API POS_RegisterListenerLonLat(HANDLE hApp,  // NOLINT(readability/nolint)
51                                        PCSTR notifyName,  // NOLINT(readability/nolint)
52                                        uint8_t ucCtrlFlg,  // NOLINT(readability/nolint)
53                                        uint8_t ucDeliveryTiming,  // NOLINT(readability/nolint)
54                                        uint8_t ucGetMethod) {  // NOLINT(readability/nolint)
55     POS_RET_API       ret = POS_RET_NORMAL;                 /* Return value of this function */
56     SENSOR_RET_API    ret_sens = SENSOR_RET_NORMAL;         /* API return value */
57     UNIT_TYPE         type = UNIT_TYPE_NONE;                /* Supported HW Configuration Type */
58     DID               did = VEHICLE_DID_LOCATION_LONLAT;    /* Data ID */
59
60     /* Internal debug log output */
61     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
62
63     /* Arguments & Support Configuration Check */
64     if ((ucDeliveryTiming != SENSOR_DELIVERY_TIMING_CHANGE) &&
65         (ucDeliveryTiming != SENSOR_DELIVERY_TIMING_UPDATE)) {
66         /* Change delivery timing,Terminate as a parameter error except update */
67         ret = POS_RET_ERROR_PARAM;
68     } else if (ucCtrlFlg != SENSOR_DELIVERY_REGIST) {
69         /* Parameters other than delivery registration are terminated abnormally when delivery control is terminated. */
70         ret = POS_RET_ERROR_PARAM;
71     } else if (hApp == NULL) {
72         /* If the handler is NULL, the process terminates with an error. */
73         ret = POS_RET_ERROR_PARAM;
74     } else if (notifyName == NULL) {
75         /* If the thread name is NULL, it terminates with an abnormal parameter. */
76         ret = POS_RET_ERROR_PARAM;
77     } else {
78         /* Positioning Base API initialization */
79         _pb_Setup_CWORD64_API(hApp);
80
81         /* Supported HW Configuration Check */
82         type = GetEnvSupportInfo();
83
84         if (UNIT_TYPE_GRADE1 == type) {
85             /* GRADE1 */
86             ret = POS_RET_NORMAL;
87             if (ucGetMethod == SENSOR_GET_METHOD_GPS) {
88                 did = VEHICLE_DID_LOCATION_LONLAT;
89             } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
90                        (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
91                 did = VEHICLE_DID_LOCATION_LONLAT_NAVI;
92             } else {
93                 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
94                 ret = POS_RET_ERROR_PARAM;
95             }
96         } else if (UNIT_TYPE_GRADE2 == type) {
97           /*
98            *  Note.
99            *  This feature branches processing depending on the unit type.
100            */
101             ret = POS_RET_ERROR_NOSUPPORT;
102         } else {
103             /* Environment error */
104             ret = POS_RET_ERROR_NOSUPPORT;
105         }
106     }
107
108     /* Delivery registration */
109     if (ret == POS_RET_NORMAL) {
110         /* Delivery registry SensorAPI calls */
111         ret_sens = PosRegisterListenerProc(notifyName,           /* Destination thread name */
112                                            did,                  /* Data ID */
113                                            ucCtrlFlg,            /* Delivery control */
114                                            ucDeliveryTiming);    /* Delivery timing */
115
116         /* Decision of delivery registration result */
117         if (ret_sens == SENSOR_RET_NORMAL) {
118             ret = POS_RET_NORMAL;
119         } else if (ret_sens == SENSOR_RET_ERROR_PARAM) {
120             ret = POS_RET_ERROR_PARAM;
121         } else if (ret_sens == SENSOR_RET_ERROR_BUFFULL) {
122             ret = POS_RET_ERROR_BUFFULL;
123         } else if (ret_sens == SENSOR_RET_ERROR_RESOURCE) {
124             ret = POS_RET_ERROR_RESOURCE;
125         } else {
126             ret = POS_RET_ERROR_INNER;
127         }
128     }
129
130     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "- [ret = %d]", ret);
131     return ret;
132 }
133
134 /**
135  * @brief
136  *  Altitude information delivery registration
137  *
138  *  Register for the delivery of altitude information
139  *
140  * @param[in] hApp              HANDLE  - Application handle
141  * @param[in] notifyName        PCSTR   - Destination thread name
142  * @param[in] ucCtrlFlg         uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery)
143  * @param[in] ucDeliveryTiming  uint8_t - Delivery timing(Changing/Updating)
144  * @param[in] ucGetMethod       uint8_t - Acquisition method(GPS/Navigation/Not specified)
145  *
146  * @return POS_RET_NORMAL               Normal completion(Include illegal)<br>
147  *         POS_RET_ERROR_PARAM          Parameter error<br>
148  *         POS_RET_ERROR_NOSUPPORT      Unsupported environment
149  *
150  */
151 POS_RET_API POS_RegisterListenerAltitude(HANDLE hApp,  // NOLINT(readability/nolint)
152                                          PCSTR notifyName,  // NOLINT(readability/nolint)
153                                          uint8_t ucCtrlFlg,  // NOLINT(readability/nolint)
154                                          uint8_t ucDeliveryTiming,  // NOLINT(readability/nolint)
155                                          uint8_t ucGetMethod) {  // NOLINT(readability/nolint)
156     POS_RET_API       ret = POS_RET_NORMAL;                   /* Return value */
157     SENSOR_RET_API    ret_sens = SENSOR_RET_NORMAL;           /* API return value */
158     UNIT_TYPE         type = UNIT_TYPE_NONE;                  /* Supported HW Configuration Type */
159     DID               did = VEHICLE_DID_LOCATION_ALTITUDE;    /* Data ID */
160
161     /* Internal debug log output */
162     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
163
164     /* Arguments & Support Configuration Check */
165     if ((ucDeliveryTiming != SENSOR_DELIVERY_TIMING_CHANGE) &&
166         (ucDeliveryTiming != SENSOR_DELIVERY_TIMING_UPDATE)) {
167         /* Change delivery timing,Terminate as a parameter error except update */
168         ret = POS_RET_ERROR_PARAM;
169     } else if (ucCtrlFlg != SENSOR_DELIVERY_REGIST) {
170         /* Parameters other than delivery registration are terminated abnormally when delivery control is terminated. */
171         ret = POS_RET_ERROR_PARAM;
172     } else if (hApp == NULL) {
173         /* If the handler is NULL, the process terminates with an error. */
174         ret = POS_RET_ERROR_PARAM;
175     } else if (notifyName == NULL) {
176         /* If the thread name is NULL, it terminates with an abnormal parameter. */
177         ret = POS_RET_ERROR_PARAM;
178     } else {
179         /* Positioning Base API initialization */
180         _pb_Setup_CWORD64_API(hApp);
181
182         /* Supported HW Configuration Check */
183         type = GetEnvSupportInfo();
184         if (UNIT_TYPE_GRADE1 == type) {
185             /* GRADE1 */
186             ret = POS_RET_NORMAL;
187             if ((ucGetMethod == SENSOR_GET_METHOD_GPS) ||
188                 (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
189                 did = VEHICLE_DID_LOCATION_ALTITUDE;
190             } else {
191                 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
192                 ret = POS_RET_ERROR_PARAM;
193             }
194         } else if (UNIT_TYPE_GRADE2 == type) {
195           /*
196            *  Note.
197            *  This feature branches processing depending on the unit type.
198            */
199             ret = SENSOR_RET_ERROR_NOSUPPORT;
200         } else {
201             /* Environment error */
202             ret = SENSOR_RET_ERROR_NOSUPPORT;
203         }
204     }
205
206     /* Delivery registration */
207     if (ret == POS_RET_NORMAL) {
208         /* Delivery registry SensorAPI calls */
209         ret_sens = PosRegisterListenerProc(notifyName,           /* Destination thread name */
210                                            did,                  /* Data ID */
211                                            ucCtrlFlg,            /* Delivery control */
212                                            ucDeliveryTiming);    /* Delivery timing */
213
214         /* Decision of delivery registration result */
215         if (ret_sens == SENSOR_RET_NORMAL) {
216             ret = POS_RET_NORMAL;
217         } else if (ret_sens == SENSOR_RET_ERROR_PARAM) {
218             ret = POS_RET_ERROR_PARAM;
219         } else if (ret_sens == SENSOR_RET_ERROR_BUFFULL) {
220             ret = POS_RET_ERROR_BUFFULL;
221         } else if (ret_sens == SENSOR_RET_ERROR_RESOURCE) {
222             ret = POS_RET_ERROR_RESOURCE;
223         } else {
224             ret = POS_RET_ERROR_INNER;
225         }
226     }
227     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "- [ret = %d]", ret);
228     return ret;
229 }
230
231 /**
232  * @brief
233  *  Vehicle Speed Information Transmission Registration
234  *
235  *  Register delivery of vehicle speed information
236  *
237  * @param[in] hApp              HANDLE  - Application handle
238  * @param[in] notifyName        PCSTR   - Destination thread name
239  * @param[in] ucCtrlFlg         uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery)
240  * @param[in] ucDeliveryTiming  uint8_t - Delivery timing(Changing/Updating)
241  * @param[in] ucGetMethod       uint8_t - Acquisition method(POS/Navigation/Not specified)
242  *
243  * @return POS_RET_NORMAL               Normal completion(Include illegal)<br>
244  *         POS_RET_ERROR_BUFFULL        Buffer-full<br>
245  *         POS_RET_ERROR_INNER          Internal error<br>
246  *         POS_RET_ERROR_PARAM          Parameter error<br>
247  *         POS_RET_ERROR_NOSUPPORT      Unsupported environment
248  *
249  */
250 POS_RET_API POS_RegisterListenerSpeed(HANDLE hApp,  // NOLINT(readability/nolint)
251                                       PCSTR notifyName,  // NOLINT(readability/nolint)
252                                       uint8_t ucCtrlFlg,   // NOLINT(readability/nolint)
253                                       uint8_t ucDeliveryTiming,  // NOLINT(readability/nolint)
254                                       uint8_t ucGetMethod) {  // NOLINT(readability/nolint)
255     POS_RET_API       ret = POS_RET_NORMAL;            /* Return value of this function            */
256     SENSOR_RET_API    ret_sens = SENSOR_RET_NORMAL;    /* API return value             */
257     UNIT_TYPE         type = UNIT_TYPE_NONE;           /* Supported HW Configuration Type    */
258     DID               did;                             /* Data ID             */
259
260     /* Internal debug log output */
261     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
262
263     /* Arguments & Support Configuration Check */
264     if ((ucDeliveryTiming != SENSOR_DELIVERY_TIMING_CHANGE) &&
265         (ucDeliveryTiming != SENSOR_DELIVERY_TIMING_UPDATE)) {
266         /* Change delivery timing,Terminate as a parameter error except update */
267         ret = POS_RET_ERROR_PARAM;
268     } else if (ucCtrlFlg != SENSOR_DELIVERY_REGIST) {
269         /* Parameters other than delivery registration are terminated abnormally when delivery control is terminated. */
270         ret = POS_RET_ERROR_PARAM;
271     } else if (hApp == NULL) {
272         /* If the handler is NULL, the process terminates with an error. */
273         ret = POS_RET_ERROR_PARAM;
274     } else if (notifyName == NULL) {
275         /* If the thread name is NULL, it terminates with an abnormal parameter. */
276         ret = POS_RET_ERROR_PARAM;
277     } else {
278         /* Positioning Base API initialization */
279         _pb_Setup_CWORD64_API(hApp);
280
281         /* Supported HW Configuration Check */
282         type = GetEnvSupportInfo();
283         if (UNIT_TYPE_GRADE1 == type) {
284             /* GRADE1 */
285             ret = POS_RET_NORMAL;
286             if (ucGetMethod == SENSOR_GET_METHOD_POS) {
287                 did = VEHICLE_DID_MOTION_SPEED_INTERNAL;
288             } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
289                        (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
290                 did = VEHICLE_DID_MOTION_SPEED_NAVI;
291             } else {
292                 ret = POS_RET_ERROR_PARAM;
293             }
294         } else if (UNIT_TYPE_GRADE2 == type) {
295           /*
296            *  Note.
297            *  This feature branches processing depending on the unit type.
298            */
299             ret = POS_RET_ERROR_NOSUPPORT;
300         } else {
301             /* Environment error */
302             ret = POS_RET_ERROR_NOSUPPORT;
303         }
304     }
305
306     /* Delivery registration */
307     if (ret == POS_RET_NORMAL) {
308         /* Delivery registry SensorAPI calls */
309         ret_sens = PosRegisterListenerProc(notifyName,           /* Destination thread name */
310                                            did,                  /* Data ID */
311                                            ucCtrlFlg,            /* Delivery control */
312                                            ucDeliveryTiming);    /* Delivery timing */
313
314         /* Decision of delivery registration result */
315         if (ret_sens == SENSOR_RET_NORMAL) {
316             ret = POS_RET_NORMAL;
317         } else if (ret_sens == SENSOR_RET_ERROR_PARAM) {
318             ret = POS_RET_ERROR_PARAM;
319         } else if (ret_sens == SENSOR_RET_ERROR_BUFFULL) {
320             ret = POS_RET_ERROR_BUFFULL;
321         } else if (ret_sens == SENSOR_RET_ERROR_RESOURCE) {
322             ret = POS_RET_ERROR_RESOURCE;
323         } else {
324             ret = POS_RET_ERROR_INNER;
325         }
326     }
327
328     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "- [ret = %d]", ret);
329     return ret;
330 }
331
332 /**
333  * @brief
334  *  Compass Information Transmission Register
335  *
336  *  Register the delivery of the vehicle orientation information
337  *
338  * @param[in] hApp              HANDLE  - Application handle
339  * @param[in] notifyName        PCSTR   - Destination thread name
340  * @param[in] ucCtrlFlg         uint8_t - Delivery control(Delivery registration/Delivery stop/Resume delivery)
341  * @param[in] ucDeliveryTiming  uint8_t - Delivery timing(Changing/Updating)
342  * @param[in] ucGetMethod       uint8_t - Acquisition method(GPS/Navigation/Not specified)
343  *
344  * @return POS_RET_NORMAL               Normal completion(Include illegal)<br>
345  *         POS_RET_ERROR_PARAM          Parameter error<br>
346  *         POS_RET_ERROR_NOSUPPORT      Unsupported environment
347  *
348  */
349 POS_RET_API POS_RegisterListenerHeading(HANDLE hApp,  // NOLINT(readability/nolint)
350                                         PCSTR notifyName,  // NOLINT(readability/nolint)
351                                         uint8_t ucCtrlFlg,  // NOLINT(readability/nolint)
352                                         uint8_t ucDeliveryTiming,  // NOLINT(readability/nolint)
353                                         uint8_t ucGetMethod) {  // NOLINT(readability/nolint)
354     POS_RET_API       ret = POS_RET_NORMAL;                /* Return value */
355     SENSOR_RET_API    ret_sens = SENSOR_RET_NORMAL;        /* API return value */
356     UNIT_TYPE         type = UNIT_TYPE_NONE;               /* Supported HW Configuration Type */
357     DID               did = VEHICLE_DID_MOTION_HEADING;    /* TODO VEHICLE_DID_LOCATION_HEADING Missing */
358     /* Data ID */
359
360     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "+");
361
362     /* Arguments & Support Configuration Check */
363     if ((ucDeliveryTiming != SENSOR_DELIVERY_TIMING_CHANGE) &&
364         (ucDeliveryTiming != SENSOR_DELIVERY_TIMING_UPDATE)) {
365         /* Change delivery timing,Terminate as a parameter error except update */
366         ret = POS_RET_ERROR_PARAM;
367     } else if (ucCtrlFlg != SENSOR_DELIVERY_REGIST) {
368         /* Parameters other than delivery registration are terminated abnormally when delivery control is terminated. */
369         ret = POS_RET_ERROR_PARAM;
370     } else if (hApp == NULL) {
371         /* If the handler is NULL, the process terminates with an error. */
372         ret = POS_RET_ERROR_PARAM;
373     } else if (notifyName == NULL) {
374         /* If the thread name is NULL, it terminates with an abnormal parameter. */
375         ret = POS_RET_ERROR_PARAM;
376     } else {
377         /* Positioning Base API initialization */
378         _pb_Setup_CWORD64_API(hApp);
379
380         /* Supported HW Configuration Check */
381         type = GetEnvSupportInfo();
382         if (UNIT_TYPE_GRADE1 == type) {
383             /* GRADE1 */
384             ret = POS_RET_NORMAL;
385             if (ucGetMethod == SENSOR_GET_METHOD_GPS) {
386                 did = VEHICLE_DID_MOTION_HEADING;
387             } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
388                        (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
389                 did = VEHICLE_DID_MOTION_HEADING_NAVI;
390             } else {
391                 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
392                 ret = POS_RET_ERROR_PARAM;
393             }
394         } else if (UNIT_TYPE_GRADE2 == type) {
395           /*
396            *  Note.
397            *  This feature branches processing depending on the unit type.
398            */
399             ret = SENSOR_RET_ERROR_NOSUPPORT;
400         } else {
401             /* Environment error */
402             ret = SENSOR_RET_ERROR_NOSUPPORT;
403         }
404     }
405
406     /* Delivery registration */
407     if (ret == POS_RET_NORMAL) {
408         /* Delivery registry SensorAPI calls */
409         ret_sens = PosRegisterListenerProc(notifyName,           /* Destination thread name */
410                                            did,                  /* Data ID */
411                                            ucCtrlFlg,            /* Delivery control */
412                                            ucDeliveryTiming);    /* Delivery timing */
413
414         /* Decision of delivery registration result */
415         if (ret_sens == SENSOR_RET_NORMAL) {
416             ret = POS_RET_NORMAL;
417         } else if (ret_sens == SENSOR_RET_ERROR_PARAM) {
418             ret = POS_RET_ERROR_PARAM;
419         } else if (ret_sens == SENSOR_RET_ERROR_BUFFULL) {
420             ret = POS_RET_ERROR_BUFFULL;
421         } else if (ret_sens == SENSOR_RET_ERROR_RESOURCE) {
422             ret = POS_RET_ERROR_RESOURCE;
423         } else {
424             ret = POS_RET_ERROR_INNER;
425         }
426     }
427
428     FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, "- [ret = %d]", ret);
429     return ret;
430 }
431
432 /**
433  * @brief
434  *  Get Lltitude and longitude information
435  *
436  *  Get Lltitude and longitude information
437  *
438  * @param[in] hApp          HANDLE                          - Application handle
439  * @param[in] dat           SENSORLOCATION_LONLATINFO_DAT*  - Pointer to the acquired latitude/longitude information storage destination
440  * @param[in] ucGetMethod   uint8_t                         - Acquisition method(GPS/Navigation/Not specified)
441  *
442  * @return POS_RET_NORMAL               Normal completion(Include illegal)<br>
443  *         POS_RET_ERROR_PARAM          Parameter error<br>
444  *         POS_RET_ERROR_NOSUPPORT      Unsupported environment<br>
445  *         POS_RET_ERROR_INNER          Internal error
446  *
447  */
448 POS_RET_API POS_GetLonLat(HANDLE hApp,   // NOLINT(readability/nolint)
449                          SENSORLOCATION_LONLATINFO_DAT *dat,  // NOLINT(readability/nolint)
450                          uint8_t ucGetMethod) {  // NOLINT(readability/nolint)
451     POS_RET_API ret = POS_RET_NORMAL;                 /* Return value */
452     UNIT_TYPE   type = UNIT_TYPE_NONE;                /* Supported HW Configuration Type */
453     DID         did = VEHICLE_DID_LOCATION_LONLAT;    /* DID */
454     int32_t       ret_get_proc;                                /* POS_GetProc Return Values */
455
456     /* Internal debug log output */
457     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
458
459     /* Arguments & Support Configuration Check */
460     if (hApp == NULL) {
461         /* If the handler is NULL, the process terminates with an error. */
462         ret = POS_RET_ERROR_PARAM;
463     } else if (dat == NULL) {
464         /* If the longitude/latitude data is NULL, it ends with an abnormal parameter. */
465         ret = POS_RET_ERROR_PARAM;
466     } else {
467         /* Positioning Base API initialization */
468         _pb_Setup_CWORD64_API(hApp);
469
470         /* Supported HW Configuration Check */
471         type = GetEnvSupportInfo();
472         if (UNIT_TYPE_GRADE1 == type) {
473             /* GRADE1 */
474             if (ucGetMethod == SENSOR_GET_METHOD_GPS) {
475                 did = VEHICLE_DID_LOCATION_LONLAT;
476             } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
477                        (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
478                 did = VEHICLE_DID_LOCATION_LONLAT_NAVI;
479             } else {
480                 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
481                 ret = POS_RET_ERROR_PARAM;
482             }
483         } else if (UNIT_TYPE_GRADE2 == type) {
484           /*
485            *  Note.
486            *  This feature branches processing depending on the unit type.
487            */
488             ret = POS_RET_ERROR_NOSUPPORT;
489         } else {
490             /* Environment error */
491             ret = POS_RET_ERROR_NOSUPPORT;
492         }
493     }
494
495     /* Sensor information acquisition */
496     if (ret == POS_RET_NORMAL) {
497         /* Data acquisition process */
498         ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORLOCATION_LONLATINFO_DAT));
499         if (static_cast<int32_t>(sizeof(SENSORLOCATION_LONLATINFO_DAT)) > ret_get_proc) {
500             /* Failed to acquire */
501             if (ret_get_proc == POS_RET_ERROR_RESOURCE) {
502                 /* Insufficient resource */
503                 ret = POS_RET_ERROR_RESOURCE;
504             } else {
505                 ret = POS_RET_ERROR_INNER;
506             }
507             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosGetProc ERROR [ret = %d]", ret);
508         }
509     }
510     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
511     return ret;
512 }
513
514 /**
515  * @brief
516  *  Altitude information acquisition
517  *
518  *  Obtain altitude information
519  *
520  * @param[in] hApp          HANDLE                           - Application handle
521  * @param[in] dat           SENSORLOCATION_ALTITUDEINFO_DAT* - Pointer to the acquired altitude information storage destination
522  * @param[in] ucGetMethod   uint8_t                          - Acquisition method(GPS/Not specified)
523  *
524  * @return POS_RET_NORMAL               Normal completion(Include illegal)<br>
525  *         POS_RET_ERROR_PARAM          Parameter error<br>
526  *         POS_RET_ERROR_NOSUPPORT      Unsupported environment<br>
527  *         POS_RET_ERROR_INNER          Internal error
528  *
529  */
530 POS_RET_API POS_GetAltitude(HANDLE hApp,  // NOLINT(readability/nolint)
531                             SENSORLOCATION_ALTITUDEINFO_DAT *dat,  // NOLINT(readability/nolint)
532                             uint8_t ucGetMethod) {  // NOLINT(readability/nolint)
533     POS_RET_API ret = POS_RET_NORMAL;                   /* Return value */
534     UNIT_TYPE   type = UNIT_TYPE_NONE;                  /* Supported HW Configuration Type */
535     DID         did = VEHICLE_DID_LOCATION_ALTITUDE;    /* DID */
536     int32_t       ret_get_proc;                         /* POS_GetProc Return Values */
537
538     /* Internal debug log output */
539     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
540
541     /* Arguments & Support Configuration Check */
542     if (hApp == NULL) {
543         /* If the handler is NULL, the process terminates with an error. */
544         ret = POS_RET_ERROR_PARAM;
545     } else if (dat == NULL) {
546         /* If the altitude data is NULL, it terminates with an abnormal parameter. */
547         ret = POS_RET_ERROR_PARAM;
548     } else {
549         /* Positioning Base API initialization */
550         _pb_Setup_CWORD64_API(hApp);
551
552         /* Supported HW Configuration Check */
553         type = GetEnvSupportInfo();
554         if (UNIT_TYPE_GRADE1 == type) {
555             /* GRADE1 */
556             if ((ucGetMethod == SENSOR_GET_METHOD_GPS) ||
557                 (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
558                 did = VEHICLE_DID_LOCATION_ALTITUDE;
559             } else {
560                 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
561                 ret = POS_RET_ERROR_PARAM;
562             }
563         } else if (UNIT_TYPE_GRADE2 == type) {
564           /*
565            *  Note.
566            *  This feature branches processing depending on the unit type.
567            */
568             ret = POS_RET_ERROR_NOSUPPORT;
569         } else {
570             /* Environment error */
571             ret = POS_RET_ERROR_NOSUPPORT;
572         }
573     }
574     /* Sensor information acquisition */
575     if (ret == POS_RET_NORMAL) {
576         /* Data acquisition process */
577         ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORLOCATION_ALTITUDEINFO_DAT));
578         if (static_cast<int32_t>(sizeof(SENSORLOCATION_ALTITUDEINFO_DAT)) > ret_get_proc) {
579             /* Failed to acquire */
580             if (ret_get_proc == POS_RET_ERROR_RESOURCE) {
581                 /* Insufficient resource */
582                 ret = POS_RET_ERROR_RESOURCE;
583             } else {
584                 ret = POS_RET_ERROR_INNER;
585             }
586             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosGetProc ERROR [ret = %d]", ret);
587         }
588     }
589     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
590     return ret;
591 }
592
593 /**
594  * @brief
595  *  Vehicle Speed Information Acquisition
596  *
597  *  Obtain vehicle speed information
598  *
599  * @param[in] hApp          HANDLE                      - Application handle
600  * @param[in] dat           SENSORMOTION_SPEEDINFO_DAT* - Pointer to the acquired car speed information storage destination
601  * @param[in] ucGetMethod   uint8_t                     - Acquisition method(GPS/Navigation/Not specified)
602  *
603  * @return POS_RET_NORMAL               Normal completion(Include illegal)<br>
604  *         POS_RET_ERROR_PARAM          Parameter error<br>
605  *         POS_RET_ERROR_NOSUPPORT      Unsupported environment<br>
606  *         POS_RET_ERROR_INNER          Internal error
607  *
608  */
609 POS_RET_API POS_GetSpeed(HANDLE hApp,  // NOLINT(readability/nolint)
610                          SENSORMOTION_SPEEDINFO_DAT *dat,  // NOLINT(readability/nolint)
611                          uint8_t ucGetMethod) {  // NOLINT(readability/nolint)
612     POS_RET_API    ret = POS_RET_NORMAL;     /* Return value                 */
613     UNIT_TYPE      type = UNIT_TYPE_NONE;    /* Supported HW Configuration Type     */
614     DID            did;                      /* Data ID             */
615     int32_t          ret_get_proc;             /* POS_GetProc Return Values */
616
617     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
618     if (hApp == NULL) {
619         /* If the handler is NULL, the process terminates with an error. */
620         ret = POS_RET_ERROR_PARAM;
621         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [hApp = %p]", hApp);
622     } else if (dat == NULL) {
623         /* When the pointer to the vehicle speed data storage destination is NULL, the pointer terminates with an error in the parameter. */
624         ret = POS_RET_ERROR_PARAM;
625         FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "Argument ERROR [dat = %p]", dat);
626     } else {
627         /* Positioning Base API initialization */
628         _pb_Setup_CWORD64_API(hApp);
629
630         /* Supported HW Configuration Check */
631         type = GetEnvSupportInfo();
632         if (UNIT_TYPE_GRADE1 == type) {
633             /* GRADE1 */
634             ret = POS_RET_NORMAL;
635             if (ucGetMethod == SENSOR_GET_METHOD_POS) {
636                 did = VEHICLE_DID_MOTION_SPEED_INTERNAL;
637             } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
638                        (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
639                 did = VEHICLE_DID_MOTION_SPEED_NAVI;
640             } else {
641                 /* End as a parameter error abnormality except for POS/unspecified acquisition method */
642                 ret = POS_RET_ERROR_PARAM;
643                 FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, 
644                               "Argument ERROR [type = %d, ucGetMethod = %d]",
645                               type, ucGetMethod);
646             }
647         } else if (UNIT_TYPE_GRADE2 == type) {
648           /*
649            *  Note.
650            *  This feature branches processing depending on the unit type.
651            */
652             ret = POS_RET_ERROR_NOSUPPORT;
653         } else {
654             /* Environment error */
655             ret = POS_RET_ERROR_NOSUPPORT;
656             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "GetEnvSupportInfo ERROR [type = %d]", type);
657         }
658     }
659
660     if (ret == POS_RET_NORMAL) {
661         /* Data acquisition process */
662         ret_get_proc = PosGetProc(did, dat, sizeof(SENSORMOTION_SPEEDINFO_DAT));
663         if (static_cast<int32_t>(sizeof(SENSORMOTION_SPEEDINFO_DAT)) > ret_get_proc) {
664             /* Failed to acquire */
665             if (ret_get_proc == POS_RET_ERROR_RESOURCE) {
666                 /* Insufficient resource */
667                 ret = POS_RET_ERROR_RESOURCE;
668             } else {
669                 ret = POS_RET_ERROR_INNER;
670             }
671             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosGetProc ERROR [ret = %d]", ret);
672         }
673     }
674     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
675
676     return ret;
677 }
678
679 /**
680  * @brief
681  *  Compass information acquisition
682  *
683  *  Get Bill Direction Information
684  *
685  * @param[in] hApp          HANDLE                        - Application handle
686  * @param[in] dat           SENSORMOTION_HEADINGINFO_DAT* - Pointer to the acquired altitude information storage destination
687  * @param[in] ucGetMethod   uint8_t                       - Acquisition method(GPS/Navigation/Not specified)
688  *
689  * @return POS_RET_NORMAL               Normal completion(Include illegal)<br>
690  *         POS_RET_ERROR_PARAM          Parameter error<br>
691  *         POS_RET_ERROR_NOSUPPORT      Unsupported environment<br>
692  *         POS_RET_ERROR_INNER          Internal error
693  *
694  */
695 POS_RET_API POS_GetHeading(HANDLE hApp,  // NOLINT(readability/nolint)
696                            SENSORMOTION_HEADINGINFO_DAT *dat,  // NOLINT(readability/nolint)
697                            uint8_t ucGetMethod) {  // NOLINT(readability/nolint)
698     POS_RET_API ret = POS_RET_NORMAL;                /* Return value */
699     UNIT_TYPE   type = UNIT_TYPE_NONE;               /* Supported HW Configuration Type */
700     DID         did = VEHICLE_DID_MOTION_HEADING;    /* Data ID */
701     int32_t       ret_get_proc;                        /* POS_GetProc Return Values */
702
703     /* Internal debug log output */
704     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
705
706     /* Arguments & Support Configuration Check */
707     if (hApp == NULL) {
708         /* If the handler is NULL, the process terminates with an error. */
709         ret = POS_RET_ERROR_PARAM;
710     } else if (dat == NULL) {
711         /* If the longitude/latitude data is NULL, it ends with an abnormal parameter. */
712         ret = POS_RET_ERROR_PARAM;
713     } else {
714         /* Positioning Base API initialization */
715         _pb_Setup_CWORD64_API(hApp);
716
717         /* Supported HW Configuration Check */
718         type = GetEnvSupportInfo();
719         if (UNIT_TYPE_GRADE1 == type) {
720             /* GRADE1 */
721             if (ucGetMethod == SENSOR_GET_METHOD_GPS) {
722                 did = VEHICLE_DID_MOTION_HEADING;
723             } else if ((ucGetMethod == SENSOR_GET_METHOD_NAVI) ||
724                        (ucGetMethod == SENSOR_GET_METHOD_AUTO)) {
725                 did = VEHICLE_DID_MOTION_HEADING_NAVI;
726             } else {
727                 /* End as a parameter error abnormality except for GPS/unspecified acquisition method */
728                 ret = POS_RET_ERROR_PARAM;
729             }
730         } else if (UNIT_TYPE_GRADE2 == type) {
731           /*
732            *  Note.
733            *  This feature branches processing depending on the unit type.
734            */
735             ret = SENSOR_RET_ERROR_NOSUPPORT;
736         } else {
737             /* Environment error */
738             ret = SENSOR_RET_ERROR_NOSUPPORT;
739         }
740     }
741     /* Sensor information acquisition */
742     if (ret == POS_RET_NORMAL) {
743         /* Data acquisition process */
744         ret_get_proc = PosGetProc(did, reinterpret_cast<void *>(dat), sizeof(SENSORMOTION_HEADINGINFO_DAT));
745         if (static_cast<int32_t>(sizeof(SENSORMOTION_HEADINGINFO_DAT)) > ret_get_proc) {
746             /** Failed to acquire */
747             if (ret_get_proc == POS_RET_ERROR_RESOURCE) {
748                 /** Insufficient resource */
749                 ret = POS_RET_ERROR_RESOURCE;
750             } else {
751                 ret = POS_RET_ERROR_INNER;
752             }
753             FRAMEWORKUNIFIEDLOG(ZONE_ERR, __FUNCTION__, "PosGetProc ERROR [ret = %d]", ret);
754         }
755     }
756     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
757     return ret;
758 }
759
760 /**
761  * @brief
762  *  Vehicle speed information setting
763  *
764  *  Setting Vehicle Speed Information
765  *
766  * @param[in] hApp      HANDLE   - Application handle
767  * @param[in] navispped uint16_t - Vehicle speed information[Unit:1.0km/h]
768  *
769  * @return POS_RET_NORMAL               Normal completion(Include illegal)<br>
770  *         POS_RET_ERROR_PARAM          Parameter error<br>
771  *         POS_RET_ERROR_NOSUPPORT      Unsupported environment
772  *
773  */
774 POS_RET_API POS_SetSpeedInfo(HANDLE hApp, uint16_t navispeed) {  // NOLINT(readability/nolint)
775     POS_RET_API  ret = POS_RET_NORMAL;     /* Return value */
776     UNIT_TYPE    type = UNIT_TYPE_NONE;    /* Supported HW Configuration Type */
777     uint16_t     speed;                    /* Vehicle speed */
778
779     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
780
781     /* Arguments & Support Configuration Check */
782     if (hApp == NULL) {
783         ret = POS_RET_ERROR_PARAM;
784     } else {
785         /* Positioning Base API initialization */
786         _pb_Setup_CWORD64_API(hApp);
787
788         /* Supported HW Configuration Check */
789         type = GetEnvSupportInfo();
790         if (UNIT_TYPE_GRADE1 == type) {
791             /* GRADE1 */
792             ret = POS_RET_NORMAL;
793         } else if (UNIT_TYPE_GRADE2 == type) {
794           /*
795            *  Note.
796            *  This feature branches processing depending on the unit type.
797            */
798             ret = SENSOR_RET_ERROR_NOSUPPORT;
799         } else {
800             /* Environment error */
801             ret = SENSOR_RET_ERROR_NOSUPPORT;
802         }
803     }
804
805     if (ret == POS_RET_NORMAL) {
806         /* Adjustment by unit [1.0km/h]->[0.01m/sec] */
807         speed = static_cast<uint16_t>(navispeed * 10000 / 360);
808         /* Data setting(After setting,Immediate termination) */
809         ret = PosSetProc(VEHICLE_DID_MOTION_SPEED_NAVI,
810                          reinterpret_cast<void *>(&speed), sizeof(uint16_t), FALSE);
811     }
812
813     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
814     return ret;
815 }
816
817 /**
818  * @brief
819  *  Location information setting
820  *
821  *  Set location information
822  *
823  * @param[in] hApp          HANDLE       - Application handle
824  * @param[in] posData       POS_POSDATA  - Pointer to location information
825  *
826  * @return  POS_RET_NORMAL           Normal completion(Include illegal)<br>
827  *          POS_RET_ERROR_PARAM      Parameter error<br>
828  *          POS_RET_ERROR_INNER      Internal error<br>
829  *          POS_RET_ERROR_NOSUPPORT  Unsupported environment
830  *
831  */
832 POS_RET_API POS_SetLocationInfo(HANDLE hApp, POS_POSDATA* pstPosData) {  // NOLINT(readability/nolint)
833     POS_RET_API    ret = POS_RET_NORMAL;     /* Return value of this function */
834     UNIT_TYPE      type = UNIT_TYPE_NONE;    /* Supported HW Configuration Type */
835
836     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "+");
837
838     /* Arguments & Support Configuration Check */
839     if ((pstPosData == NULL) || (hApp == NULL)) {
840         ret = POS_RET_ERROR_PARAM;
841     } else {
842         /* Positioning Base API initialization */
843         _pb_Setup_CWORD64_API(hApp);
844
845         /* Supported HW Configuration Check */
846         type = GetEnvSupportInfo();
847         if (UNIT_TYPE_GRADE1 == type) {
848             /* GRADE1 */
849             ret = POS_RET_NORMAL;
850         } else if (UNIT_TYPE_GRADE2 == type) {
851           /*
852            *  Note.
853            *  This feature branches processing depending on the unit type.
854            */
855             ret = SENSOR_RET_ERROR_NOSUPPORT;
856         } else {
857             /* Environment error */
858             ret = SENSOR_RET_ERROR_NOSUPPORT;
859         }
860     }
861
862     if (ret == POS_RET_NORMAL) {
863         /* Data status check */
864         if ((0x01 > pstPosData->status) || (0x0F < pstPosData->status)) {
865             ret = POS_RET_ERROR_PARAM;
866         } else {
867             /* Parameter range check */
868             /* Latitude */
869             if ((pstPosData->status & POS_LOC_INFO_LAT) == POS_LOC_INFO_LAT) {
870                 (void)POS_CHKPARAM32(pstPosData->latitude, -41472000, 41472000);
871             }
872             /* Longitude */
873             if ((pstPosData->status & POS_LOC_INFO_LON) == POS_LOC_INFO_LON) {
874                 (void)POS_CHKPARAM32(pstPosData->longitude, -82944000, 82944000);
875             }
876             /* Orientation */
877             if ((pstPosData->status & POS_LOC_INFO_HEAD) == POS_LOC_INFO_HEAD) {
878                 (void)POS_CHKPARAM16(pstPosData->heading, -179, 180);
879             }
880
881             /* Data setting(After setting,Immediate termination) */
882             ret = PosSetProc(VEHICLE_DID_GPS_CUSTOMDATA_NAVI,  // == POSHAL_DID_GPS_CUSTOMDATA_NAVI
883                              reinterpret_cast<void *>(pstPosData), sizeof(POS_POSDATA), FALSE);
884         }
885     }
886
887     FRAMEWORKUNIFIEDLOG(ZONE_26, __FUNCTION__, "- [ret = %d]", ret);
888     return ret;
889 }