1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_HDI_LOCATION_LOCATION_VENDOR_LIB_H 17 #define OHOS_HDI_LOCATION_LOCATION_VENDOR_LIB_H 18 19 #include <cstdint> 20 #include <sys/socket.h> 21 22 namespace OHOS { 23 namespace HDI { 24 namespace Location { 25 26 #define SATELLITE_NUM_MAXIMUM 128 27 #define GNSS_NI_SUPPLICANT_INFO_LENGTH_MAXIMUM 256 28 #define GNSS_NI_NOTIFICATION_TEXT_LENGTH_MAXIMUM 2048 29 30 enum class AgnssSetIdClass { 31 AGNSS_SETID_CLASS_NONE = 0, 32 AGNSS_SETID_CLASS_IMSI = 1, 33 AGNSS_SETID_CLASS_MSISDM = 2, 34 }; 35 36 enum class AgnssRefLocClass { 37 AGNSS_REF_LOC_CLASS_CELLID = 1, 38 AGNSS_REF_LOC_CLASS_MAC = 2, 39 }; 40 41 enum class GnssStartClass { 42 GNSS_START_CLASS_NORMAL = 1, 43 GNSS_START_CLASS_GNSS_CACHE = 2, 44 }; 45 46 enum class CellIdClass { 47 GSM_CELLID = 1, 48 UMTS_CELLID = 2, 49 LTE_CELLID = 3, 50 NR_CELLID = 4, 51 }; 52 53 enum class ApnIpClass { 54 APN_CLASS_INVALID = 0, 55 APN_CLASS_IPV4 = 1, 56 APN_CLASS_IPV6 = 2, 57 APN_CLASS_IPV4V6 = 3 58 }; 59 60 enum class AgnssDataConnStatus { 61 /* AGNSS data connecting. */ 62 AGNSS_DATA_CONN_CONNECTING = 1, 63 /* AGNSS data connection initiated. */ 64 AGNSS_DATA_CONN_CONNECTED = 2, 65 /* AGNSS data disconnecting. */ 66 AGNSS_DATA_CONN_DISCONNECTING = 3, 67 /* AGNSS data disconnected. */ 68 AGNSS_DATA_CONN_DISCONNECTED = 4 69 }; 70 71 enum class AgnssClass { 72 AGNSS_CLASS_SUPL = 1, 73 AGNSS_CLASS_C2K = 2 74 }; 75 76 /* 77 * Constellation class 78 */ 79 enum class ConstellationClass { 80 GNSS_CONSTELLATION_UNKNOWN = 0, 81 /* Global Positioning System. */ 82 GNSS_CONSTELLATION_GPS = 1, 83 /* Satellite-Based Augmentation System. */ 84 GNSS_CONSTELLATION_SBAS = 2, 85 /* Global Navigation Satellite System. */ 86 GNSS_CONSTELLATION_GLONASS = 3, 87 /* Quasi-Zenith Satellite System. */ 88 GNSS_CONSTELLATION_QZSS = 4, 89 /* BeiDou Navigation Satellite System. */ 90 GNSS_CONSTELLATION_BEIDOU = 5, 91 /* Galileo Navigation Satellite System. */ 92 GNSS_CONSTELLATION_GALILEO = 6, 93 /* Indian Regional Navigation Satellite System. */ 94 GNSS_CONSTELLATION_IRNSS = 7, 95 }; 96 97 /* GNSS working status values. */ 98 enum class GnssWorkingStatus { 99 /* GNSS status unknown. */ 100 GNSS_STATUS_NONE = 0, 101 /* GNSS has begun navigating. */ 102 GNSS_STATUS_SESSION_BEGIN = 1, 103 /* GNSS has stopped navigating. */ 104 GNSS_STATUS_SESSION_END = 2, 105 /* GNSS has powered on but is not navigating. */ 106 GNSS_STATUS_ENGINE_ON = 3, 107 /* GNSS is powered off. */ 108 GNSS_STATUS_ENGINE_OFF = 4 109 }; 110 111 enum class GnssCapabilities { 112 /* GNSS supports MS-Based AGNSS mode */ 113 GNSS_CAP_SUPPORT_MSB = (1 << 0), 114 /* GNSS supports MS-Assisted AGNSS mode */ 115 GNSS_CAP_SUPPORT_MSA = (1 << 1), 116 /* GNSS supports Geofencing */ 117 GNSS_CAP_SUPPORT_GEOFENCING = (1 << 2), 118 /* GNSS supports Measurements for at least GPS. */ 119 GNSS_CAP_SUPPORT_MEASUREMENTS = (1 << 3), 120 /* GNSS supports Navigation Messages */ 121 GNSS_CAP_SUPPORT_NAV_MESSAGES = (1 << 4), 122 /* GNSS supports location caching */ 123 GNSS_CAP_SUPPORT_GNSS_CACHE = (1 << 5), 124 }; 125 126 enum class SatelliteAdditionalInfo { 127 SATELLITES_ADDITIONAL_INFO_NULL = 0, 128 SATELLITES_ADDITIONAL_INFO_EPHEMERIS_DATA_EXIST = 1 << 0, 129 SATELLITES_ADDITIONAL_INFO_ALMANAC_DATA_EXIST = 1 << 1, 130 SATELLITES_ADDITIONAL_INFO_USED_IN_FIX = 1 << 2, 131 SATELLITES_ADDITIONAL_INFO_CARRIER_FREQUENCY_EXIST = 1 << 3 132 }; 133 134 enum class GnssWorkingMode { 135 GNSS_WORKING_MODE_STANDALONE = 1, /* GNSS standalone (no assistance) */ 136 GNSS_WORKING_MODE_MS_BASED = 2, /* AGNSS MS-Based mode */ 137 GNSS_WORKING_MODE_MS_ASSISTED = 3 /* AGPS MS-Assisted mode */ 138 }; 139 140 enum class GnssRefInfoClass { 141 GNSS_REF_INFO_TIME = 1, 142 GNSS_REF_INFO_LOCATION = 2, 143 GNSS_REF_INFO_BEST_LOCATION = 3, 144 }; 145 146 enum class GnssAuxiliaryDataClass { 147 GNSS_AUXILIARY_DATA_CLASS_EPHEMERIS = 0x0001, 148 GNSS_AUXILIARY_DATA_CLASS_ALMANAC = 0x0002, 149 GNSS_AUXILIARY_DATA_CLASS_POSITION = 0x0004, 150 GNSS_AUXILIARY_DATA_CLASS_TIME = 0x0008, 151 GNSS_AUXILIARY_DATA_CLASS_IONO = 0x0010, 152 GNSS_AUXILIARY_DATA_CLASS_UTC = 0x0020, 153 GNSS_AUXILIARY_DATA_CLASS_HEALTH = 0x0040, 154 GNSS_AUXILIARY_DATA_CLASS_SVDIR = 0x0080, 155 GNSS_AUXILIARY_DATA_CLASS_SVSTEER = 0x0100, 156 GNSS_AUXILIARY_DATA_CLASS_SADATA = 0x0200, 157 GNSS_AUXILIARY_DATA_CLASS_RTI = 0x0400, 158 GNSS_AUXILIARY_DATA_CLASS_CELLDB_INFO = 0x8000, 159 GNSS_AUXILIARY_DATA_CLASS_ALL = 0xFFFF 160 }; 161 162 enum class GnssModuleIfaceCategory { 163 AGNSS_MODULE_INTERFACE = 1, 164 GNSS_GEOFENCING_MODULE_INTERFACE = 2, 165 GNSS_NET_INITIATED_MODULE_INTERFACE = 3, 166 GNSS_MEASUREMENT_MODULE_INTERFACE = 4, 167 }; 168 169 enum class GeofenceEvent { 170 GEOFENCE_EVENT_UNCERTAIN = (1 << 0), 171 GEOFENCE_EVENT_ENTERED = (1 << 1), 172 GEOFENCE_EVENT_EXITED = (1 << 2), 173 }; 174 175 enum class GeofenceOperateClass { 176 GEOFENCE_ADD = 1, 177 GEOFENCE_DELETE = 2, 178 }; 179 180 enum class GeofenceOperateResult { 181 GEOFENCE_OPERATION_SUCCESS = 0, 182 GEOFENCE_OPERATION_ERROR_UNKNOWN = -100, 183 GEOFENCE_OPERATION_ERROR_TOO_MANY_GEOFENCES = -101, 184 GEOFENCE_OPERATION_ERROR_GEOFENCE_ID_EXISTS = -102, 185 GEOFENCE_OPERATION_ERROR_PARAMS_INVALID = -103, 186 }; 187 188 enum class GnssNiRequestCategory { 189 GNSS_NI_REQUEST_CATEGORY_EMERGENCY_SUPL = 1, 190 GNSS_NI_REQUEST_CATEGORY_VOICE = 2, 191 GNSS_NI_REQUEST_CATEGORY_UMTS_CONTROL_PLANE = 3, 192 GNSS_NI_REQUEST_CATEGORY_UMTS_SUPL = 4, 193 }; 194 195 enum class GnssNiResponseCmd { 196 GNSS_NI_RESPONSE_CMD_ACCEPT = 1, 197 GNSS_NI_RESPONSE_CMD_NO_RESPONSE = 2, 198 GNSS_NI_RESPONSE_CMD_REJECT = 3, 199 }; 200 201 enum class GnssNiNotificationCategory { 202 GNSS_NI_NOTIFICATION_REQUIRE_NOTIFY = (1 << 0), 203 GNSS_NI_NOTIFICATION_REQUIRE_VERIFY = (1 << 1), 204 GNSS_NI_NOTIFICATION_REQUIRE_PRIVACY_OVERRIDE = (1 << 2), 205 }; 206 207 enum class GnssNiRequestEncodingFormat { 208 GNSS_NI_ENCODING_FORMAT_NULL = 1, 209 GNSS_NI_ENCODING_FORMAT_SUPL_GSM_DEFAULT = 2, 210 GNSS_NI_ENCODING_FORMAT_SUPL_UCS2 = 3, 211 GNSS_NI_ENCODING_FORMAT_SUPL_UTF8 = 4, 212 }; 213 /* CellID info struct. */ 214 typedef struct { 215 size_t size; 216 /* See CellIdClass for the definition of type. */ 217 uint16_t type; 218 /* Mobile Country Code. */ 219 uint16_t mcc; 220 /* Mobile Network Code. */ 221 uint16_t mnc; 222 /* Location Area Code in 2G, 3G and LTE. */ 223 uint16_t lac; 224 /* 2G:Cell id. 3G:Utran Cell id. LTE:Cell Global Id EUTRA. */ 225 uint32_t cid; 226 /* Tracking Area Code in LTE. */ 227 uint16_t tac; 228 /* Physical Cell id in LTE. */ 229 uint16_t pcid; 230 } AGnssRefInfoCellId; 231 232 typedef struct { 233 size_t size; 234 uint8_t mac[6]; 235 } AGnssRefInfoMac; 236 237 /* Agnss reference location information structure */ 238 typedef struct { 239 size_t size; 240 /* See AgnssRefLocClass for the definition of type. */ 241 uint32_t type; 242 union { 243 AGnssRefInfoCellId cellId; 244 AGnssRefInfoMac mac; 245 } u; 246 } AGnssRefLocInfo; 247 248 /* GNSS position structure. */ 249 typedef struct { 250 size_t size; 251 uint32_t flags; 252 double latitude; 253 double longitude; 254 /* Altitude in meters. */ 255 double altitude; 256 /* Speed in meters per second. */ 257 float speed; 258 /* Heading in degrees. */ 259 float bearing; 260 /* 261 * Represents expected horizontal position accuracy, radial, in meters 262 * (68% confidence). 263 */ 264 float horizontalAccuracy; 265 /* 266 * Represents expected vertical position accuracy in meters 267 * (68% confidence). 268 */ 269 float verticalAccuracy; 270 /* 271 * Represents expected speed accuracy in meter per seconds 272 * (68% confidence). 273 */ 274 float speedAccuracy; 275 /* 276 * Represents expected bearing accuracy in degrees 277 * (68% confidence). 278 */ 279 float bearingAccuracy; 280 /* Timestamp for the location fix.Milliseconds since January 1, 1970. */ 281 int64_t timestamp; 282 /* Timestamp since boot.Milliseconds since January 1, 1970. */ 283 int64_t timestampSinceBoot; 284 } GnssLocation; 285 286 typedef struct { 287 size_t size; 288 /* min interval between locations in ms. */ 289 uint32_t interval; 290 /* If the value is true, the cached locations 291 * are reported and the AP is woken up after the FIFO is full. 292 */ 293 bool fifoFullNotify; 294 } GnssCachingConfig; 295 296 /* 297 * Status information of a single satellite. 298 */ 299 typedef struct { 300 size_t size; 301 302 /* Satellite ID number for the satellite. */ 303 int16_t satelliteId; 304 305 /* 306 * Defines the constellation category. 307 * See ConstellationCategory for the definition of constellationCategory. 308 */ 309 uint8_t constellationCategory; 310 311 /* Carrier-to-noise density in dB-Hz. */ 312 float cn0; 313 314 /* Elevation of satellite in degrees. */ 315 float elevation; 316 317 /* Azimuth of satellite in degrees. */ 318 float azimuth; 319 320 /* Carrier frequency of the signal tracked. The unit is Hz. */ 321 float carrierFrequency; 322 323 /* See SatelliteAdditionalInfo for the definition of satelliteAdditionalInfo. */ 324 uint32_t satelliteAdditionalInfo; 325 } SatelliteStatusInfo; 326 327 /* 328 * Status informations of all satellites. 329 */ 330 typedef struct { 331 /* set to sizeof(GnssSatelliteStatus) */ 332 size_t size; 333 334 /* Number of all satellites that can be viewed. */ 335 uint32_t satellitesNum; 336 337 /* Array of all satellites information. */ 338 SatelliteStatusInfo satellitesList[SATELLITE_NUM_MAXIMUM]; 339 } GnssSatelliteStatus; 340 341 /* Callback with location information. */ 342 typedef void (* on_location_change)(GnssLocation* location); 343 344 /* 345 * Callback with gnss working status information. 346 * Parameters: 347 * status - Working status of GNSS chip. 348 * See GnssWorkingStatus for the definition of status. 349 */ 350 typedef void (* on_gnss_status_change)(uint16_t* status); 351 352 /* Callback with satellite status information. */ 353 typedef void (* on_sv_status_change)(GnssSatelliteStatus* status); 354 355 /* 356 * Callback for reporting NMEA info. 357 * Parameters: 358 * timestamp - Timestamp when the nmea was reported. Milliseconds since January 1, 1970. 359 * nmea - NMEA string. 360 * length - length of NMEA string. 361 */ 362 typedef void (* on_gnss_nmea_change)(int64_t timestamp, const char* nmea, int length); 363 364 /* 365 * Callback to reporting the GNSS capabilities. 366 * Parameters: 367 * capabilities - GNSS capabilities,See GnssCapabilities for the definition of capabilities. 368 */ 369 typedef void (* on_capabilities_change)(uint32_t capabilities); 370 371 /* 372 * Request Delivery Reference Information. 373 * Parameters: 374 * type - Type of GNSS reference information,See GnssRefInfoClass for the definition of type. 375 */ 376 typedef void (* request_reference_information)(int type); 377 378 /* Gnss basic config structure. */ 379 typedef struct { 380 size_t size; 381 uint32_t minInterval; /* min interval between locations in ms */ 382 int gnssMode; /* See GnssWorkingMode for the definition of gnssMode */ 383 } GnssBasicConfigPara; 384 385 /* GNSS config structure. */ 386 typedef struct { 387 size_t size; 388 /* 389 * Indicates the method of location reporting, 390 * whether to report immediately or after caching for a 391 * period of time. See GnssStartClass for the definition of type. 392 */ 393 uint32_t type; 394 union { 395 GnssBasicConfigPara gnssBasicConfig; 396 GnssCachingConfig gnssCacheConfig; 397 } u; 398 } GnssConfigPara; 399 400 /* Gnss reference time. */ 401 typedef struct { 402 size_t size; 403 int64_t time; /* Milliseconds since January 1, 1970. */ 404 int64_t timeReference; /* Milliseconds since January 1, 1970. */ 405 int uncertainty; 406 } GnssRefTime; 407 408 /* Gnss reference position. */ 409 typedef struct { 410 size_t size; 411 double latitude; 412 double longitude; 413 float accuracy; 414 } GnssRefLocation; 415 416 /* Gnss reference information structure. */ 417 typedef struct { 418 size_t size; 419 /* 420 * Type of GNSS reference information, 421 * See GnssRefInfoClass for the definition of type. 422 */ 423 int type; 424 union { 425 GnssRefTime time; 426 GnssRefLocation location; 427 GnssLocation bestLocation; 428 } u; 429 } GnssRefInfo; 430 431 /* Callback to request the client to download XTRA data. */ 432 typedef void (* extended_ephemeris_download_request)(void); 433 434 /* GNSS cache location information reporting. */ 435 typedef void (* on_cached_locations_change)(const GnssLocation** locationArray, size_t len); 436 437 /* GNSS basic callback functions. */ 438 typedef struct { 439 size_t size; 440 on_location_change locationUpdate; 441 on_gnss_status_change statusUpdate; 442 on_sv_status_change svStatusUpdate; 443 on_gnss_nmea_change nmeaUpdate; 444 on_capabilities_change capabilitiesUpdate; 445 request_reference_information refInfoRequest; 446 extended_ephemeris_download_request downloadRequestCb; 447 } GnssBasicCallbackIfaces; 448 449 /* GNSS cache callback functions. */ 450 typedef struct { 451 size_t size; 452 on_cached_locations_change cachedLocationCb; 453 } GnssCacheCallbackIfaces; 454 455 /* 456 * Definition of the GNSS NI notification request structure. 457 */ 458 typedef struct { 459 size_t size; 460 461 /* 462 * An ID of GNSS NI notifications. 463 */ 464 int16_t gnssNiNotificationId; 465 466 /* 467 * Category of GNSS NI Request. See GnssNiRequestCategory for the definition of gnssNiRequestCategory. 468 */ 469 int16_t gnssNiRequestCategory; 470 471 /* 472 * Category of notification. See GnssNiNotificationCategory for the definition of gnssNiCategory. 473 */ 474 int32_t notificationCategory; 475 476 /* 477 * Timeout to wait for user response. The unit is seconds. 478 */ 479 int32_t requestTimeout; 480 481 /* 482 * Default response command when timeout. 483 */ 484 int32_t defaultResponseCmd; 485 486 /* 487 * Supplicant information. 488 */ 489 char supplicantInfo[GNSS_NI_SUPPLICANT_INFO_LENGTH_MAXIMUM]; 490 491 /* 492 * Notification message text. 493 */ 494 char notificationText[GNSS_NI_NOTIFICATION_TEXT_LENGTH_MAXIMUM]; 495 496 /* 497 * See GnssNiRequestEncodingFormat for the definition of supplicantInfoEncoding. 498 */ 499 int16_t supplicantInfoEncoding; 500 501 /* 502 * See GnssNiRequestEncodingFormat for the definition of notificationTextEncoding. 503 */ 504 int16_t notificationTextEncoding; 505 } GnssNiNotificationRequest; 506 507 /* 508 * Callback for GNSS NI notification reporting. 509 */ 510 typedef void (*OnGnssNiNotificationChange)(GnssNiNotificationRequest *notification); 511 512 /* 513 * Definition of GNSS NI callback structure. 514 */ 515 typedef struct { 516 OnGnssNiNotificationChange reportNiNotification; 517 } GnssNetInitiatedCallbacks; 518 519 /* 520 * GNSS callback structure. 521 */ 522 typedef struct { 523 size_t size; 524 GnssBasicCallbackIfaces gnssCb; 525 GnssCacheCallbackIfaces gnssCacheCb; 526 } GnssCallbackStruct; 527 528 /* GNSS vendor interface definition. */ 529 typedef struct { 530 size_t size; 531 532 /* Enable the GNSS function.Initializing the GNSS Chip. */ 533 int (* enable_gnss)(GnssCallbackStruct* callbacks); 534 535 /* Disables the GNSS function. */ 536 int (* disable_gnss)(void); 537 538 /* start navigating.See GnssStartClass for the definition of type. */ 539 int (* start_gnss)(uint32_t type); 540 541 /* Stops navigating.See GnssStartClass for the definition of type. */ 542 int (* stop_gnss)(uint32_t type); 543 544 /* Inject reference information into the GNSS chip. 545 * See GnssRefInfoClass for the definition of type. */ 546 int (* injects_reference_information)(int type, GnssRefInfo* info); 547 548 /* Set gnss configuration parameters. */ 549 int (* set_gnss_config_para)(GnssConfigPara* para); 550 551 /* 552 * Specifies that the next call to start will not use the 553 * information defined in the flags. 554 * See GnssAuxiliaryDataClass for the definition of flags. 555 */ 556 void (* remove_auxiliary_data)(uint16_t flags); 557 558 /* Injects XTRA data into the GNSS. */ 559 int (* inject_extended_ephemeris)(char* data, int length); 560 561 /* Return the cached locations size. */ 562 int (* get_cached_locations_size)(); 563 564 /* Retrieve all cached locations currently stored and clear the buffer. */ 565 void (* flush_cached_gnss_locations)(); 566 567 /* Get a pointer to gnss module interface.See GnssModuleIfaceClass for the definition of iface. */ 568 const void* (* get_gnss_module_iface)(int iface); 569 } GnssVendorInterface; 570 571 struct GnssVendorDevice { 572 size_t size; 573 const GnssVendorInterface* (*get_gnss_interface)(); 574 }; 575 576 /* Status of AGNSS. */ 577 typedef struct { 578 size_t size; 579 /* See AgnssClass for the definition of agnssType */ 580 uint16_t agnssType; 581 /* See AgnssDataConnStatus for the definition of connStatus. */ 582 uint16_t connStatus; 583 /* IPv4 address. */ 584 uint32_t ipaddr; 585 /* Contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report. */ 586 struct sockaddr_storage sockAddr; 587 } AGnssStatusInfo; 588 589 typedef void (* on_agnss_status_change)(const AGnssStatusInfo* status); 590 591 /* 592 * Callback function for requesting setid. 593 * Parameters: 594 * type - Type of setid,See enum class agnssetidclass for the definition of type. 595 */ 596 typedef void (* get_setid_cb)(uint16_t type); 597 598 /* 599 * Callback function for requesting setid. 600 * Parameters: 601 * type - Type of Type of reference location,See enum class AgnssRefLocClass for the definition of type. 602 */ 603 typedef void (* get_ref_location_cb)(uint32_t type); 604 605 typedef struct { 606 size_t size; 607 on_agnss_status_change agnssStatusChange; 608 get_setid_cb getSetid; 609 get_ref_location_cb getRefLoc; 610 } AGnssCallbackIfaces; 611 612 /* interface for AGNSS support */ 613 typedef struct { 614 size_t size; 615 616 /* 617 * Opens the AGNSS interface and provides the callback interfaces 618 */ 619 bool (* set_agnss_callback)(AGnssCallbackIfaces* callbacks); 620 621 /* 622 * Sets the reference cell id. 623 */ 624 bool (* set_ref_location)(const AGnssRefLocInfo* refLoc); 625 626 /* 627 * Sets the set ID. 628 * Parameters: 629 * type - Type of setid,See enum class agnssetidclass for the definition of type. 630 * setid - String to hold setid. 631 * len - length of setid. 632 */ 633 bool (* set_setid)(uint16_t type, const char* setid, size_t len); 634 635 /* 636 * Setting the Agnss Server Information. 637 * Parameters: 638 * type - type of agnss.See AgnssClass for the definition of type. 639 * server - agnss server. 640 * len - length of server string. 641 * port - port of agnss server. 642 */ 643 bool (* set_agnss_server)(uint16_t type, const char* server, size_t len, int32_t port); 644 } AGnssModuleInterface; 645 646 /* 647 * The callback associated with the geofence. 648 * Parameters: 649 * geofenceId - The id associated with the add_gnss_geofence. 650 * location - The current GNSS location. 651 * event - Can be one of GEOFENCE_EVENT_UNCERTAIN, GEOFENCE_EVENT_ENTERED, 652 * GEOFENCE_EVENT_EXITED. 653 * timestamp - Timestamp when the transition was detected. Milliseconds since January 1, 1970. 654 */ 655 typedef void (* geofence_event_callback)(int32_t geofenceId, GnssLocation* location, 656 int32_t event, int64_t timestamp); 657 658 /* 659 * Callback function that indicates whether the geofence service is available. 660 * 661 * Parameters: 662 * isAvailable is true when gnss geofence service is available. 663 */ 664 typedef void (* geofence_availability_callback)(bool isAvailable); 665 666 /* 667 * Callback function indicating the result of the geofence operation 668 * 669 * geofenceId - Id of the geofence. 670 * operateType - geofence operate type. 671 * result - GEOFENCE_OPERATION_SUCCESS 672 * GEOFENCE_OPERATION_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. 673 * GEOFENCE_OPERATION_ERROR_GEOFENCE_ID_EXISTS - geofence with id already exists 674 * GEOFENCE_OPERATION_ERROR_PARAMS_INVALID - input params are invalid. 675 */ 676 typedef void (* geofence_operate_result_callback)(int32_t geofenceId, int32_t operateType, 677 int32_t result); 678 679 typedef struct { 680 size_t size; 681 geofence_availability_callback on_geofence_availability_change; 682 geofence_event_callback geofence_event_notify; 683 geofence_operate_result_callback geofence_operate_result_cb; 684 } GeofenceCallbackIfaces; 685 686 /* Interface for GNSS Geofence */ 687 typedef struct { 688 size_t size; 689 690 /* 691 * Opens the geofence interface and provides the callback interfaces. 692 */ 693 bool (* set_callback)(GeofenceCallbackIfaces* callbacks); 694 695 /* 696 * Add a geofence area. This api currently supports circular geofences. 697 * Parameters: 698 * geofenceId - The id for the geofence. 699 * latitude, longtitude, radius - The lat, long and radius 700 * (in meters) for the geofence 701 * monitorEvent - Which transitions to monitor. Bitwise OR of 702 * GEOFENCE_EVENT_UNCERTAIN, GEOFENCE_EVENT_ENTERED and 703 * GEOFENCE_EVENT_EXITED. 704 */ 705 bool (* add_gnss_geofence)(int32_t geofenceId, double latitude, double longitude, 706 double radius, int32_t monitorEvent); 707 708 /* 709 * Remove a gnss geofence. 710 * geofenceId - The id for the geofence. 711 * Return true if delete successful. 712 */ 713 bool (* delete_gnss_geofence)(int32_t geofenceId); 714 } GeofenceModuleInterface; 715 716 /* 717 * Definition of GNSS NI interface. 718 */ 719 typedef struct { 720 size_t size; 721 722 /* Set callbacks. */ 723 void (*setCallback)(GnssNetInitiatedCallbacks *callbacks); 724 725 /* 726 * Sends user response command. 727 * Parameters: 728 * gnssNiNotificationId - The id of GNSS NI notifications. 729 * userResponse - User reponse command. 730 * See GnssNiResponseCmd for the definition of userResponse. 731 */ 732 void (*sendUserResponse)(int32_t gnssNiNotificationId, int32_t userResponse); 733 734 /* 735 * Send network initiated message. 736 */ 737 void (*sendNetworkInitiatedMsg)(uint8_t *msg, size_t length); 738 } GnssNetInitiatedInterface; 739 } // namespace Location 740 } // namespace HDI 741 } // namespace OHOS 742 743 #endif /* OHOS_HDI_LOCATION_LOCATION_VENDOR_LIB_H */ 744