blob: 9ac3e06fccf83ac5137fa67ff4495d887b8e9ca5 [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>
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070022#include <android/hardware/wifi/1.4/IWifiRttController.h>
23#include <android/hardware/wifi/1.4/IWifiRttControllerEventCallback.h>
Roshan Pius59268282016-10-06 20:23:47 -070024
25#include "wifi_legacy_hal.h"
26
27namespace android {
28namespace hardware {
29namespace wifi {
Jimmy Chend460df32019-11-29 17:31:22 +020030namespace V1_5 {
Roshan Pius59268282016-10-06 20:23:47 -070031namespace implementation {
32
33/**
34 * HIDL interface object used to control all RTT operations.
35 */
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070036class WifiRttController : public V1_4::IWifiRttController {
Roshan Piusabcf78f2017-10-06 16:30:38 -070037 public:
38 WifiRttController(
39 const std::string& iface_name, const sp<IWifiIface>& bound_iface,
40 const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal);
41 // Refer to |WifiChip::invalidate()|.
42 void invalidate();
43 bool isValid();
Jimmy Chend460df32019-11-29 17:31:22 +020044 std::vector<sp<V1_4::IWifiRttControllerEventCallback>> getEventCallbacks();
Roshan Pius82368502019-05-16 12:53:02 -070045 std::string getIfaceName();
Roshan Pius59268282016-10-06 20:23:47 -070046
Roshan Piusabcf78f2017-10-06 16:30:38 -070047 // HIDL methods exposed.
48 Return<void> getBoundIface(getBoundIface_cb hidl_status_cb) override;
49 Return<void> registerEventCallback(
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070050 const sp<V1_0::IWifiRttControllerEventCallback>& callback,
Roshan Piusabcf78f2017-10-06 16:30:38 -070051 registerEventCallback_cb hidl_status_cb) override;
52 Return<void> rangeRequest(uint32_t cmd_id,
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070053 const hidl_vec<V1_0::RttConfig>& rtt_configs,
Roshan Piusabcf78f2017-10-06 16:30:38 -070054 rangeRequest_cb hidl_status_cb) override;
55 Return<void> rangeCancel(uint32_t cmd_id,
56 const hidl_vec<hidl_array<uint8_t, 6>>& addrs,
57 rangeCancel_cb hidl_status_cb) override;
58 Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override;
59 Return<void> setLci(uint32_t cmd_id, const RttLciInformation& lci,
60 setLci_cb hidl_status_cb) override;
61 Return<void> setLcr(uint32_t cmd_id, const RttLcrInformation& lcr,
62 setLcr_cb hidl_status_cb) override;
63 Return<void> getResponderInfo(getResponderInfo_cb hidl_status_cb) override;
64 Return<void> enableResponder(uint32_t cmd_id,
65 const WifiChannelInfo& channel_hint,
66 uint32_t max_duration_seconds,
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070067 const V1_0::RttResponder& info,
Roshan Piusabcf78f2017-10-06 16:30:38 -070068 enableResponder_cb hidl_status_cb) override;
69 Return<void> disableResponder(uint32_t cmd_id,
70 disableResponder_cb hidl_status_cb) override;
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070071 Return<void> registerEventCallback_1_4(
Jimmy Chend460df32019-11-29 17:31:22 +020072 const sp<V1_4::IWifiRttControllerEventCallback>& callback,
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070073 registerEventCallback_1_4_cb hidl_status_cb) override;
74 Return<void> rangeRequest_1_4(uint32_t cmd_id,
Jimmy Chend460df32019-11-29 17:31:22 +020075 const hidl_vec<V1_4::RttConfig>& rtt_configs,
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070076 rangeRequest_1_4_cb hidl_status_cb) override;
77 Return<void> getCapabilities_1_4(
78 getCapabilities_1_4_cb hidl_status_cb) override;
79 Return<void> getResponderInfo_1_4(
80 getResponderInfo_1_4_cb hidl_status_cb) override;
81 Return<void> enableResponder_1_4(
82 uint32_t cmd_id, const WifiChannelInfo& channel_hint,
Jimmy Chend460df32019-11-29 17:31:22 +020083 uint32_t max_duration_seconds, const V1_4::RttResponder& info,
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070084 enableResponder_1_4_cb hidl_status_cb) override;
Roshan Pius59268282016-10-06 20:23:47 -070085
Roshan Piusabcf78f2017-10-06 16:30:38 -070086 private:
87 // Corresponding worker functions for the HIDL methods.
88 std::pair<WifiStatus, sp<IWifiIface>> getBoundIfaceInternal();
89 WifiStatus registerEventCallbackInternal(
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070090 const sp<V1_0::IWifiRttControllerEventCallback>& callback);
91 WifiStatus rangeRequestInternal(
92 uint32_t cmd_id, const std::vector<V1_0::RttConfig>& rtt_configs);
Roshan Piusabcf78f2017-10-06 16:30:38 -070093 WifiStatus rangeCancelInternal(
94 uint32_t cmd_id, const std::vector<hidl_array<uint8_t, 6>>& addrs);
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070095 std::pair<WifiStatus, V1_0::RttCapabilities> getCapabilitiesInternal();
Roshan Piusabcf78f2017-10-06 16:30:38 -070096 WifiStatus setLciInternal(uint32_t cmd_id, const RttLciInformation& lci);
97 WifiStatus setLcrInternal(uint32_t cmd_id, const RttLcrInformation& lcr);
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -070098 std::pair<WifiStatus, V1_0::RttResponder> getResponderInfoInternal();
Roshan Piusabcf78f2017-10-06 16:30:38 -070099 WifiStatus enableResponderInternal(uint32_t cmd_id,
100 const WifiChannelInfo& channel_hint,
101 uint32_t max_duration_seconds,
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -0700102 const V1_0::RttResponder& info);
Roshan Piusabcf78f2017-10-06 16:30:38 -0700103 WifiStatus disableResponderInternal(uint32_t cmd_id);
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -0700104 WifiStatus registerEventCallbackInternal_1_4(
Jimmy Chend460df32019-11-29 17:31:22 +0200105 const sp<V1_4::IWifiRttControllerEventCallback>& callback);
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -0700106 WifiStatus rangeRequestInternal_1_4(
Jimmy Chend460df32019-11-29 17:31:22 +0200107 uint32_t cmd_id, const std::vector<V1_4::RttConfig>& rtt_configs);
108 std::pair<WifiStatus, V1_4::RttCapabilities> getCapabilitiesInternal_1_4();
109 std::pair<WifiStatus, V1_4::RttResponder> getResponderInfoInternal_1_4();
Ahmed ElArabawyeeb53382019-10-10 20:18:31 -0700110 WifiStatus enableResponderInternal_1_4(uint32_t cmd_id,
111 const WifiChannelInfo& channel_hint,
112 uint32_t max_duration_seconds,
Jimmy Chend460df32019-11-29 17:31:22 +0200113 const V1_4::RttResponder& info);
Roshan Pius907d4a22016-10-27 12:48:12 -0700114
Roshan Piusabcf78f2017-10-06 16:30:38 -0700115 std::string ifname_;
116 sp<IWifiIface> bound_iface_;
117 std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
Jimmy Chend460df32019-11-29 17:31:22 +0200118 std::vector<sp<V1_4::IWifiRttControllerEventCallback>> event_callbacks_;
Roshan Piusabcf78f2017-10-06 16:30:38 -0700119 bool is_valid_;
Roshan Pius59268282016-10-06 20:23:47 -0700120
Roshan Piusabcf78f2017-10-06 16:30:38 -0700121 DISALLOW_COPY_AND_ASSIGN(WifiRttController);
Roshan Pius59268282016-10-06 20:23:47 -0700122};
123
124} // namespace implementation
Jimmy Chend460df32019-11-29 17:31:22 +0200125} // namespace V1_5
Roshan Pius59268282016-10-06 20:23:47 -0700126} // namespace wifi
127} // namespace hardware
128} // namespace android
129
130#endif // WIFI_RTT_CONTROLLER_H_