1 /*
2  * Copyright (C) 2017 The Android Open Source Project
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 #ifndef CHRE_PLATFORM_PLATFORM_WIFI_H_
18 #define CHRE_PLATFORM_PLATFORM_WIFI_H_
19 
20 #include "chre/target_platform/platform_wifi_base.h"
21 
22 namespace chre {
23 
24 class PlatformWifi : public PlatformWifiBase {
25  public:
26   /**
27    * Performs platform-specific deinitialization of the PlatformWifi instance.
28    */
29   ~PlatformWifi();
30 
31   /**
32    * Initializes the platform-specific WiFi implementation. This is potentially
33    * called at a later stage of initialization than the constructor, so platform
34    * implementations are encouraged to put any blocking initialization here.
35    */
36   void init();
37 
38   /**
39    * Returns the set of WiFi capabilities that the platform has exposed. This
40    * may return CHRE_WIFI_CAPABILITIES_NONE if wifi is not supported.
41    *
42    * @return the WiFi capabilities exposed by this platform.
43    */
44   uint32_t getCapabilities();
45 
46   /**
47    * Configures the scan monitoring function of the platform Wifi. For more info
48    * see the WiFi PAL documentation. The result of this operation is
49    * asynchronous and must be delivered to CHRE by invoking the
50    * WifiRequestManager::handleScanMonitorStateChange method.
51    *
52    * @param enable true to enable listening for scan results.
53    *
54    * @return true to indicate that the request was accepted.
55    */
56   bool configureScanMonitor(bool enable);
57 
58   /**
59    * Requests that the WiFi chipset perform RTT ranging. Refer to the
60    * {@link chrePalWifiApi} struct of the PAL API which includes further
61    * documentation. Note that the implementation of this method may be supplied
62    * by the CHRE PAL but is not required to be. The semantics of this
63    * implementation, however, must be the same those of the requestRanging PAL
64    * API.
65    *
66    * @param params Parameters for the ranging request.
67    *
68    * @return true to indicate that the request was accepted.
69    */
70   bool requestRanging(const struct chreWifiRangingParams *params);
71 
72   bool requestNanRanging(const struct chreWifiNanRangingParams *params);
73 
74   /**
75    * Requests that the WiFi chipset perform an active wifi scan. Refer to
76    * the
77    * {@link chrePalWifiApi} struct which includes further documentation.
78    * Note that the implementation of this method may be supplied by the CHRE
79    * PAL but is not required to be. The semantics of this implementation,
80    * however, must be the same those of the requestScan PAL API.
81    *
82    * @param params The configuration of the wifi scan.
83    *
84    * @return true to indicate that the request was accepted.
85    */
86   bool requestScan(const struct chreWifiScanParams *params);
87 
88   /**
89    * Releases a previously published WiFi RTT ranging result event. Refer to the
90    * {@link chrePalWifiApi} struct of the PAL API for further documentation.
91    *
92    * @param event A pointer to an event to be released.
93    */
94   void releaseRangingEvent(struct chreWifiRangingEvent *event);
95 
96   /**
97    * Releases a previously published wifi scan event. Refer to the
98    * {@link chrePalWifiApi} struct of the PAL API for further documentation.
99    *
100    * @param event A pointer to an event to be released.
101    */
102   void releaseScanEvent(struct chreWifiScanEvent *event);
103 
104   /**
105    * Requests the initiation of a NAN service subscription.
106    *
107    * @param config Service specific NAN subscription configuration.
108    * @return true if the request was successful, false otherwise.
109    */
110   bool nanSubscribe(const struct chreWifiNanSubscribeConfig *config);
111 
112   /**
113    * Requests a subscription cancelation.
114    *
115    * @param subscriptionID The ID of the subscriber that's requesting a
116    *        cancelation.
117    * @return true if the cancelation request was successful.
118    */
119   bool nanSubscribeCancel(uint32_t subscriptionId);
120 
121   /**
122    * Releases the memory associated with a NAN service discovery information
123    * structure, and passes memory ownership back to the PAL module.
124    *
125    * @param event The discovery event data to be released.
126    */
127   void releaseNanDiscoveryEvent(struct chreWifiNanDiscoveryEvent *event);
128 };
129 
130 }  // namespace chre
131 
132 #endif  // CHRE_PLATFORM_PLATFORM_WIFI_H_
133