blob: 3dd5340fcfa04e3cb5ac74ab9a27c950bdaef278 [file] [log] [blame]
Roshan Pius59268282016-10-06 20:23:47 -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_RTT_CONTROLLER_H_
18#define WIFI_RTT_CONTROLLER_H_
19
20#include <android-base/macros.h>
21#include <android/hardware/wifi/1.0/IWifiIface.h>
22#include <android/hardware/wifi/1.0/IWifiRttController.h>
Roshan Pius7913f5e2016-10-27 17:09:30 -070023#include <android/hardware/wifi/1.0/IWifiRttControllerEventCallback.h>
Roshan Pius59268282016-10-06 20:23:47 -070024
25#include "wifi_legacy_hal.h"
26
27namespace android {
28namespace hardware {
29namespace wifi {
30namespace V1_0 {
31namespace implementation {
32
33/**
34 * HIDL interface object used to control all RTT operations.
35 */
36class WifiRttController : public IWifiRttController {
37 public:
38 WifiRttController(const sp<IWifiIface>& bound_iface,
Roshan Pius6cedc972016-10-28 10:11:17 -070039 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
Roshan Pius59268282016-10-06 20:23:47 -070040 // Refer to |WifiChip::invalidate()|.
41 void invalidate();
Roshan Pius907d4a22016-10-27 12:48:12 -070042 bool isValid();
Roshan Pius59268282016-10-06 20:23:47 -070043
44 // HIDL methods exposed.
Roshan Pius734fea02016-10-11 08:30:28 -070045 Return<void> getBoundIface(getBoundIface_cb hidl_status_cb) override;
Roshan Pius7913f5e2016-10-27 17:09:30 -070046 Return<void> registerEventCallback(
47 const sp<IWifiRttControllerEventCallback>& callback,
48 registerEventCallback_cb hidl_status_cb) override;
49 Return<void> rangeRequest(uint32_t cmd_id,
50 const hidl_vec<RttConfig>& rtt_configs,
51 rangeRequest_cb hidl_status_cb) override;
52 Return<void> rangeCancel(uint32_t cmd_id,
53 const hidl_vec<hidl_array<uint8_t, 6>>& addrs,
54 rangeCancel_cb hidl_status_cb) override;
55 Return<void> setChannelMap(uint32_t cmd_id,
56 const RttChannelMap& params,
57 uint32_t num_dw,
58 setChannelMap_cb hidl_status_cb) override;
59 Return<void> clearChannelMap(uint32_t cmd_id,
60 clearChannelMap_cb hidl_status_cb) override;
61 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
62 Return<void> setDebugCfg(RttDebugType type,
63 setDebugCfg_cb hidl_status_cb) override;
64 Return<void> getDebugInfo(getDebugInfo_cb hidl_status_cb) override;
65 Return<void> setLci(uint32_t cmd_id,
66 const RttLciInformation& lci,
67 setLci_cb hidl_status_cb) override;
68 Return<void> setLcr(uint32_t cmd_id,
69 const RttLcrInformation& lcr,
70 setLcr_cb hidl_status_cb) override;
71 Return<void> getResponderInfo(getResponderInfo_cb hidl_status_cb) override;
72 Return<void> enableResponder(uint32_t cmd_id,
73 const WifiChannelInfo& channel_hint,
74 uint32_t maxDurationSeconds,
75 const RttResponder& info,
76 enableResponder_cb hidl_status_cb) override;
77 Return<void> disableResponder(uint32_t cmd_id,
78 disableResponder_cb hidl_status_cb) override;
Roshan Pius59268282016-10-06 20:23:47 -070079
80 private:
Roshan Pius907d4a22016-10-27 12:48:12 -070081 // Corresponding worker functions for the HIDL methods.
82 std::pair<WifiStatus, sp<IWifiIface>> getBoundIfaceInternal();
Roshan Pius7913f5e2016-10-27 17:09:30 -070083 WifiStatus registerEventCallbackInternal(
84 const sp<IWifiRttControllerEventCallback>& callback);
85 WifiStatus rangeRequestInternal(uint32_t cmd_id,
86 const std::vector<RttConfig>& rtt_configs);
87 WifiStatus rangeCancelInternal(
88 uint32_t cmd_id, const std::vector<hidl_array<uint8_t, 6>>& addrs);
89 WifiStatus setChannelMapInternal(uint32_t cmd_id,
90 const RttChannelMap& params,
91 uint32_t num_dw);
92 WifiStatus clearChannelMapInternal(uint32_t cmd_id);
93 std::pair<WifiStatus, RttCapabilities> getCapabilitiesInternal();
94 WifiStatus setDebugCfgInternal(RttDebugType type);
95 std::pair<WifiStatus, RttDebugInfo> getDebugInfoInternal();
96 WifiStatus setLciInternal(uint32_t cmd_id, const RttLciInformation& lci);
97 WifiStatus setLcrInternal(uint32_t cmd_id, const RttLcrInformation& lcr);
98 std::pair<WifiStatus, RttResponder> getResponderInfoInternal();
99 WifiStatus enableResponderInternal(uint32_t cmd_id,
100 const WifiChannelInfo& channel_hint,
101 uint32_t maxDurationSeconds,
102 const RttResponder& info);
103 WifiStatus disableResponderInternal(uint32_t cmd_id);
Roshan Pius907d4a22016-10-27 12:48:12 -0700104
Roshan Pius59268282016-10-06 20:23:47 -0700105 sp<IWifiIface> bound_iface_;
Roshan Pius6cedc972016-10-28 10:11:17 -0700106 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
Roshan Pius7913f5e2016-10-27 17:09:30 -0700107 std::vector<sp<IWifiRttControllerEventCallback>> event_callbacks_;
Roshan Pius59268282016-10-06 20:23:47 -0700108 bool is_valid_;
109
110 DISALLOW_COPY_AND_ASSIGN(WifiRttController);
111};
112
113} // namespace implementation
114} // namespace V1_0
115} // namespace wifi
116} // namespace hardware
117} // namespace android
118
119#endif // WIFI_RTT_CONTROLLER_H_