summaryrefslogtreecommitdiffstats
path: root/gnss/1.0/IGnssBatching.hal
blob: 6f2dde6641863722fe9f2859cea972ead74f348c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.gnss@1.0;

import IGnssBatchingCallback;

/*
 * Extended interface for GNSS Batching support.
 *
 * If this interface is supported, this batching request must be able to run in
 * parallel with, or without, non-batched location requested by the
 * IGnss start() & stop() - i.e. both requests must be handled independently,
 * and not interfere with each other.
 *
 * For example, if a 1Hz continuous output is underway on the IGnssCallback,
 * due to an IGnss start() operation,
 * and then a IGnssBatching start() is called for a location every 10
 * seconds, the newly added batching request must not disrupt the 1Hz
 * continuous location output on the IGnssCallback.
 *
 * As with GNSS Location outputs, source of location must be GNSS satellite
 * measurements, optionally using interial and baro sensors to improve
 * relative motion filtering. No additional absolute positioning information,
 * such as WiFi derived location, may be mixed with the GNSS information.
 */

interface IGnssBatching {
    /*
     * Enum which holds the bit masks for batching control.
     */
    @export(name="", value_prefix="FLP_BATCH_")
    enum Flag : uint8_t {
        /*
         * If this flag is set, the hardware implementation
         * must wake up the application processor when the FIFO is full, and
         * call IGnssBatchingCallback to return the locations.
         *
         * If the flag is not set, the hardware implementation must drop
         * the oldest data when the FIFO is full.
         */
        WAKEUP_ON_FIFO_FULL = 0x01
    };

    struct Options {
        /*
         * Time interval between samples in the location batch, in nano
         * seconds.
         */
        int64_t periodNanos;

        /*
         * Flags controlling how batching should behave.
         */
        bitfield<Flag> flags;
    };

    /*
     * Opens the interface and provides the callback routines
     * to the implementation of this interface.
     *
     * @param callback Callback interface for IGnssBatching.
     *
     * @return success Returns true on success.
     */
    init(IGnssBatchingCallback callback) generates (bool success);

    /*
     * Return the batch size (in number of GnssLocation objects)
     * available in this hardware implementation.
     *
     * If the available size is variable, for example, based on other operations
     * consuming memory, this is the minimum size guaranteed to be available
     * for batching operations.
     *
     * This may, for example, be used by the upper layer, to decide on the
     * batching interval and whether the AP should be woken up or not.
     *
     * @return batchSize number of location objects supported per batch
     */
    getBatchSize() generates (uint16_t batchSize);

    /*
     * Start batching locations. This API is primarily used when the AP is
     * asleep and the device can batch locations in the hardware.
     *
     * IGnssBatchingCallback is used to return the locations.
     *
     * When the buffer is full and WAKEUP_ON_FIFO_FULL is used,
     * IGnssBatchingCallback must be called to return the locations.
     *
     * When the buffer is full and WAKEUP_ON_FIFO_FULL is not set,
     * the oldest location object is dropped. In this case the AP must not be
     * woken up. The AP would then generally be responsible for using
     * flushBatchedLocation to explicitly ask for the location as needed,
     * to avoid it being dropped.
     *
     * @param options See struct Options definition.
     *
     * @return success Returns true on success.
     */
    start(Options options) generates (bool success);

    /**
     * Retrieve all batched locations currently stored.
     *
     * IGnssBatchingCallback is used to return the location.
     *
     * IGnssBatchingCallback must be called in response, even if there are
     * no locations to flush (in which case the Location vector must be empty).
     *
     * Subsequent calls to flushBatchedLocation
     * must not return any of the locations returned in this call.
     */
    flush();

    /**
     * Stop batching.
     *
     * @return success Returns true on success.
     */
    stop() generates (bool success);

    /**
     * Closes the interface. If any batch operations are in progress,
     * they must be stopped.  If any locations are in the hardware batch, they
     * must be deleted (and not sent via callback.)
     *
     * init() may be called again, after this, if the interface is to be restored
     */
    cleanup();

};