blob: b4f2721dca8cd7a19d192034afc20dfac3842c40 [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 Piusa04ba3f2016-10-27 14:36:26 -070080 Return<void> startDebugPacketFateMonitoring(
81 startDebugPacketFateMonitoring_cb hidl_status_cb) override;
82 Return<void> stopDebugPacketFateMonitoring(
83 stopDebugPacketFateMonitoring_cb hidl_status_cb) override;
84 Return<void> getDebugTxPacketFates(
85 getDebugTxPacketFates_cb hidl_status_cb) override;
86 Return<void> getDebugRxPacketFates(
87 getDebugRxPacketFates_cb hidl_status_cb) override;
Roshan Pius3e2d6712016-10-06 13:16:23 -070088
89 private:
Roshan Pius907d4a22016-10-27 12:48:12 -070090 // Corresponding worker functions for the HIDL methods.
91 std::pair<WifiStatus, std::string> getNameInternal();
92 std::pair<WifiStatus, IfaceType> getTypeInternal();
Roshan Piusa04ba3f2016-10-27 14:36:26 -070093 WifiStatus registerEventCallbackInternal(
94 const sp<IWifiStaIfaceEventCallback>& callback);
95 std::pair<WifiStatus, uint32_t> getCapabilitiesInternal();
96 std::pair<WifiStatus, StaApfPacketFilterCapabilities>
97 getApfPacketFilterCapabilitiesInternal();
98 WifiStatus installApfPacketFilterInternal(
99 uint32_t cmd_id, const std::vector<uint8_t>& program);
100 std::pair<WifiStatus, StaBackgroundScanCapabilities>
101 getBackgroundScanCapabilitiesInternal();
102 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
103 getValidFrequenciesForBackgroundScanInternal(StaBackgroundScanBand band);
104 WifiStatus startBackgroundScanInternal(
105 uint32_t cmd_id, const StaBackgroundScanParameters& params);
106 WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);
107 WifiStatus enableLinkLayerStatsCollectionInternal(bool debug);
108 WifiStatus disableLinkLayerStatsCollectionInternal();
109 std::pair<WifiStatus, StaLinkLayerStats> getLinkLayerStatsInternal();
Roshan Piusd4767542016-12-06 10:04:05 -0800110 WifiStatus startRssiMonitoringInternal(uint32_t cmd_id,
111 int32_t max_rssi,
112 int32_t min_rssi);
113 WifiStatus stopRssiMonitoringInternal(uint32_t cmd_id);
Roshan Piusa04ba3f2016-10-27 14:36:26 -0700114 WifiStatus startDebugPacketFateMonitoringInternal();
115 WifiStatus stopDebugPacketFateMonitoringInternal();
116 std::pair<WifiStatus, std::vector<WifiDebugTxPacketFateReport>>
117 getDebugTxPacketFatesInternal();
118 std::pair<WifiStatus, std::vector<WifiDebugRxPacketFateReport>>
119 getDebugRxPacketFatesInternal();
Roshan Pius907d4a22016-10-27 12:48:12 -0700120
Roshan Pius3e2d6712016-10-06 13:16:23 -0700121 std::string ifname_;
Roshan Pius6cedc972016-10-28 10:11:17 -0700122 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
Roshan Piusa04ba3f2016-10-27 14:36:26 -0700123 std::vector<sp<IWifiStaIfaceEventCallback>> event_callbacks_;
Roshan Pius3e2d6712016-10-06 13:16:23 -0700124 bool is_valid_;
125
126 DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
127};
128
129} // namespace implementation
130} // namespace V1_0
131} // namespace wifi
132} // namespace hardware
133} // namespace android
134
135#endif // WIFI_STA_IFACE_H_