blob: 90126cd48f7930dcb001c611d2ad0795259d0ab7 [file] [log] [blame]
Roshan Pius3e2d6712016-10-06 13:16:23 -07001/*
2 * Copyright (C) 2016 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 WIFI_STA_IFACE_H_
18#define WIFI_STA_IFACE_H_
19
20#include <android-base/macros.h>
21#include <android/hardware/wifi/1.0/IWifiStaIface.h>
Roshan Piusa04ba3f2016-10-27 14:36:26 -070022#include <android/hardware/wifi/1.0/IWifiStaIfaceEventCallback.h>
Roshan Pius3e2d6712016-10-06 13:16:23 -070023
24#include "wifi_legacy_hal.h"
25
26namespace android {
27namespace hardware {
28namespace wifi {
29namespace V1_0 {
30namespace implementation {
31
32/**
33 * HIDL interface object used to control a STA Iface instance.
34 */
35class WifiStaIface : public IWifiStaIface {
36 public:
37 WifiStaIface(const std::string& ifname,
Roshan Pius6cedc972016-10-28 10:11:17 -070038 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
Roshan Pius3e2d6712016-10-06 13:16:23 -070039 // Refer to |WifiChip::invalidate()|.
40 void invalidate();
Roshan Pius907d4a22016-10-27 12:48:12 -070041 bool isValid();
Roshan Pius970f0312016-12-05 15:25:51 -080042 std::vector<sp<IWifiStaIfaceEventCallback>> getEventCallbacks();
Roshan Pius3e2d6712016-10-06 13:16:23 -070043
44 // HIDL methods exposed.
Roshan Pius734fea02016-10-11 08:30:28 -070045 Return<void> getName(getName_cb hidl_status_cb) override;
46 Return<void> getType(getType_cb hidl_status_cb) override;
Roshan Piusa04ba3f2016-10-27 14:36:26 -070047 Return<void> registerEventCallback(
48 const sp<IWifiStaIfaceEventCallback>& callback,
49 registerEventCallback_cb hidl_status_cb) override;
50 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
51 Return<void> getApfPacketFilterCapabilities(
52 getApfPacketFilterCapabilities_cb hidl_status_cb) override;
53 Return<void> installApfPacketFilter(
54 uint32_t cmd_id,
55 const hidl_vec<uint8_t>& program,
56 installApfPacketFilter_cb hidl_status_cb) override;
57 Return<void> getBackgroundScanCapabilities(
58 getBackgroundScanCapabilities_cb hidl_status_cb) override;
59 Return<void> getValidFrequenciesForBackgroundScan(
60 StaBackgroundScanBand band,
61 getValidFrequenciesForBackgroundScan_cb hidl_status_cb) override;
62 Return<void> startBackgroundScan(
63 uint32_t cmd_id,
64 const StaBackgroundScanParameters& params,
65 startBackgroundScan_cb hidl_status_cb) override;
66 Return<void> stopBackgroundScan(
67 uint32_t cmd_id, stopBackgroundScan_cb hidl_status_cb) override;
68 Return<void> enableLinkLayerStatsCollection(
69 bool debug, enableLinkLayerStatsCollection_cb hidl_status_cb) override;
70 Return<void> disableLinkLayerStatsCollection(
71 disableLinkLayerStatsCollection_cb hidl_status_cb) override;
72 Return<void> getLinkLayerStats(getLinkLayerStats_cb hidl_status_cb) override;
Roshan Piusd4767542016-12-06 10:04:05 -080073 Return<void> startRssiMonitoring(
74 uint32_t cmd_id,
75 int32_t max_rssi,
76 int32_t min_rssi,
77 startRssiMonitoring_cb hidl_status_cb) override;
78 Return<void> stopRssiMonitoring(
79 uint32_t cmd_id, stopRssiMonitoring_cb hidl_status_cb) override;
Roshan Pius26801cb2016-12-13 14:25:45 -080080 Return<void> getRoamingCapabilities(
81 getRoamingCapabilities_cb hidl_status_cb) override;
82 Return<void> configureRoaming(const StaRoamingConfig& config,
83 configureRoaming_cb hidl_status_cb) override;
84 Return<void> setRoamingState(StaRoamingState state,
85 setRoamingState_cb hidl_status_cb) override;
Roshan Piusa04ba3f2016-10-27 14:36:26 -070086 Return<void> startDebugPacketFateMonitoring(
87 startDebugPacketFateMonitoring_cb hidl_status_cb) override;
88 Return<void> stopDebugPacketFateMonitoring(
89 stopDebugPacketFateMonitoring_cb hidl_status_cb) override;
90 Return<void> getDebugTxPacketFates(
91 getDebugTxPacketFates_cb hidl_status_cb) override;
92 Return<void> getDebugRxPacketFates(
93 getDebugRxPacketFates_cb hidl_status_cb) override;
Roshan Pius3e2d6712016-10-06 13:16:23 -070094
95 private:
Roshan Pius907d4a22016-10-27 12:48:12 -070096 // Corresponding worker functions for the HIDL methods.
97 std::pair<WifiStatus, std::string> getNameInternal();
98 std::pair<WifiStatus, IfaceType> getTypeInternal();
Roshan Piusa04ba3f2016-10-27 14:36:26 -070099 WifiStatus registerEventCallbackInternal(
100 const sp<IWifiStaIfaceEventCallback>& callback);
101 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
102 std::pair<WifiStatus, StaApfPacketFilterCapabilities>
103 getApfPacketFilterCapabilitiesInternal();
104 WifiStatus installApfPacketFilterInternal(
105 uint32_t cmd_id, const std::vector<uint8_t>& program);
106 std::pair<WifiStatus, StaBackgroundScanCapabilities>
107 getBackgroundScanCapabilitiesInternal();
108 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
109 getValidFrequenciesForBackgroundScanInternal(StaBackgroundScanBand band);
110 WifiStatus startBackgroundScanInternal(
111 uint32_t cmd_id, const StaBackgroundScanParameters& params);
112 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
113 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
114 WifiStatus disableLinkLayerStatsCollectionInternal();
115 std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal();
Roshan Piusd4767542016-12-06 10:04:05 -0800116 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id,
117 int32_t max_rssi,
118 int32_t min_rssi);
119 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
Roshan Pius26801cb2016-12-13 14:25:45 -0800120 std::pair<WifiStatus, StaRoamingCapabilities>
121 getRoamingCapabilitiesInternal();
122 WifiStatus configureRoamingInternal(const StaRoamingConfig& config);
123 WifiStatus setRoamingStateInternal(StaRoamingState state);
Roshan Piusa04ba3f2016-10-27 14:36:26 -0700124 WifiStatus startDebugPacketFateMonitoringInternal();
125 WifiStatus stopDebugPacketFateMonitoringInternal();
126 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
127 getDebugTxPacketFatesInternal();
128 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
129 getDebugRxPacketFatesInternal();
Roshan Pius907d4a22016-10-27 12:48:12 -0700130
Roshan Pius3e2d6712016-10-06 13:16:23 -0700131 std::string ifname_;
Roshan Pius6cedc972016-10-28 10:11:17 -0700132 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
Roshan Piusa04ba3f2016-10-27 14:36:26 -0700133 std::vector<sp<IWifiStaIfaceEventCallback>> event_callbacks_;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700134 bool is_valid_;
135
136 DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
137};
138
139} // namespace implementation
140} // namespace V1_0
141} // namespace wifi
142} // namespace hardware
143} // namespace android
144
145#endif // WIFI_STA_IFACE_H_