1f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *
3f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * Redistribution and use in source and binary forms, with or without
4f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * modification, are permitted provided that the following conditions are
5f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * met:
6f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *     * Redistributions of source code must retain the above copyright
7f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       notice, this list of conditions and the following disclaimer.
8f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *     * Redistributions in binary form must reproduce the above
9f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       copyright notice, this list of conditions and the following
10f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       disclaimer in the documentation and/or other materials provided
11f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       with the distribution.
12f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *     * Neither the name of Code Aurora Forum, Inc. nor the names of its
13f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       contributors may be used to endorse or promote products derived
14f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *       from this software without specific prior written permission.
15f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *
16f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani *
28f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani */
29f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#ifndef LOC_API_RPC_ADAPTER_H
30f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#define LOC_API_RPC_ADAPTER_H
31f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
32f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <rpc/rpc.h>
33f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <loc_api_rpc_glue.h>
34f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#include <LocApiAdapter.h>
35f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
36f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
37f77c85bb51137f5ba854184e5e9194197027438aAjay Dudaniclass LocApiRpcAdapter : public LocApiAdapter {
38f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // RPC communication establishment
39f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    rpc_loc_client_handle_type client_handle;
40f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    rpc_loc_event_mask_type eMask;
41f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
42f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    static const rpc_loc_event_mask_type locBits[];
43f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    static rpc_loc_event_mask_type convertMask(LOC_API_ADAPTER_EVENT_MASK_T mask);
44f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    static enum loc_api_adapter_err convertErr(int rpcErr);
45f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
46f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    void reportPosition(const rpc_loc_parsed_position_s_type *location_report_ptr);
47f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    void reportSv(const rpc_loc_gnss_info_s_type *gnss_report_ptr);
48f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    void reportStatus(const rpc_loc_status_event_s_type *status_report_ptr);
49f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    void reportNmea(const rpc_loc_nmea_report_s_type *nmea_report_ptr);
50f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    void ATLEvent(const rpc_loc_server_request_s_type *server_request_ptr);
51f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    void NIEvent(const rpc_loc_ni_event_s_type *ni_req_ptr);
52f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    int NIEventFillVerfiyType(GpsNiNotification &notif,
53f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                              rpc_loc_ni_notify_verify_e_type notif_priv);
54f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    GpsNiEncodingType convertNiEncodingType(int loc_encoding);
55f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
56f77c85bb51137f5ba854184e5e9194197027438aAjay Dudanipublic:
57f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    LocApiRpcAdapter(LocEng &locEng);
58f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    ~LocApiRpcAdapter();
59f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
60f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    int locEventCB(rpc_loc_client_handle_type client_handle,
61f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                   rpc_loc_event_mask_type loc_event,
62f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani                   const rpc_loc_event_payload_u_type* loc_event_payload);
63f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
64f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    void locRpcGlobalCB(CLIENT* clnt, enum rpc_reset_event event);
65f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
66f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    // RPC adapter interface implementations
67f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
68f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        reinit();
69f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
70f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        startFix();
71f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
72f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        stopFix();
73f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
74f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        setPositionMode(LocPositionMode mode, GpsPositionRecurrence recurrence,
75f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani            uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time);
76f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
77f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        enableData(int enable);
78f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
79f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        setTime(GpsUtcTime time, int64_t timeReference, int uncertainty);
80f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
81f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        injectPosition(double latitude, double longitude, float accuracy);
82f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
83f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        deleteAidingData(GpsAidingData f);
84f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
85f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        informNiResponse(GpsUserResponseType userResponse, const void* passThroughData);
86f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
87f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        setAPN(char* apn, int len);
88f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
89f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        setServer(const char* url, int len);
90f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
91f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        setServer(unsigned int ip, int port, LocServerType type);
92f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
93f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        setXtraData(char* data, int length);
94f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
95f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        atlOpenStatus(int handle, int is_succ, char* apn, AGpsBearerType bear, AGpsType agpsType);
96f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
97f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        atlCloseStatus(int handle, int is_succ);
98f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani    virtual enum loc_api_adapter_err
99f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani        setSUPLVersion(uint32_t version);
100f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani};
101f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani
102f77c85bb51137f5ba854184e5e9194197027438aAjay Dudani#endif //LOC_API_RPC_ADAPTER_H
103