1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OHOS_AP_INTERFACE_H 16 #define OHOS_AP_INTERFACE_H 17 #include "ap_config_use.h" 18 #include "ap_monitor.h" 19 #include "ap_stations_manager.h" 20 #include "ap_service.h" 21 #include "ap_state_machine.h" 22 23 namespace OHOS { 24 namespace Wifi { 25 class ApInterface : public IApService { 26 public: 27 /** 28 * @Description construction method. 29 * @param None 30 * @return None 31 */ 32 explicit ApInterface(int id = 0); 33 /** 34 * @Description destructor method. 35 * @param None 36 * @return None 37 */ 38 ~ApInterface(); 39 40 public: 41 /** 42 * @Description Enable hotspot. 43 * @param None 44 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 45 */ 46 virtual ErrCode EnableHotspot() override; 47 48 /** 49 * @Description Disable hotspot. 50 * @param None 51 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 52 */ 53 virtual ErrCode DisableHotspot() override; 54 55 /** 56 * @Description Add block list from station information. 57 * @param stationInfo - station information. 58 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 59 */ 60 virtual ErrCode AddBlockList(const StationInfo &stationInfo) override; 61 62 /** 63 * @Description Del block list from station information. 64 * @param stationInfo - station information. 65 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 66 */ 67 virtual ErrCode DelBlockList(const StationInfo &stationInfo) override; 68 69 /** 70 * @Description Set hotspot configure. 71 * @param hotspotConfig - hotspot configure. 72 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 73 */ 74 virtual ErrCode SetHotspotConfig(const HotspotConfig &hotspotConfig) override; 75 76 /** 77 * @Description Set the idel timeout of Hotspot 78 * 79 * @param time -input time, 80 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 81 */ 82 virtual ErrCode SetHotspotIdleTimeout(int time) override; 83 84 /** 85 * @Description Disconnect Station connect from station information. 86 * @param stationInfo - station information. 87 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 88 */ 89 virtual ErrCode DisconnetStation(const StationInfo &stationInfo) override; 90 91 /** 92 * @Description Get the Station List object. 93 * 94 * @param result - current connected station info 95 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 96 */ 97 virtual ErrCode GetStationList(std::vector<StationInfo> &result) override; 98 99 /** 100 * @Description Sets the callback function for the state machine. 101 * @param callbacks - callbacks list. 102 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 103 */ 104 virtual ErrCode RegisterApServiceCallbacks(const IApServiceCallbacks &callbacks) override; 105 106 /** 107 * @Description Get valid bands. 108 * 109 * @param bands - return valid bands 110 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 111 */ 112 virtual ErrCode GetValidBands(std::vector<BandType> &bands) override; 113 114 /** 115 * @Description Get valid channels. 116 * 117 * @param band - input band 118 * @param validchannel - band's valid channel 119 * @return ErrCode - success: WIFI_OPT_SUCCESS failed: ERROR_CODE 120 */ 121 virtual ErrCode GetValidChannels(BandType band, std::vector<int32_t> &validChannel) override; 122 123 /** 124 * @Description Get supported power model list 125 * 126 * @param setPowerModelList - supported power model list 127 * @return ErrCode - operation result 128 */ 129 virtual ErrCode GetSupportedPowerModel(std::set<PowerModel>& setPowerModelList) override; 130 131 /** 132 * @Description Get power model 133 * 134 * @param model - current power model 135 * @return ErrCode - operation result 136 */ 137 virtual ErrCode GetPowerModel(PowerModel& model) override; 138 139 /** 140 * @Description Get supported power model list 141 * 142 * @param model - the model to be set 143 * @return ErrCode - operation result 144 */ 145 virtual ErrCode SetPowerModel(const PowerModel& model) override; 146 147 private: 148 ApRootState m_ApRootState; 149 ApStartedState m_ApStartedState; 150 ApIdleState m_ApIdleState; 151 152 ApMonitor m_ApMonitor; 153 ApStateMachine m_ApStateMachine; 154 ApService m_ApService; 155 156 ApStationsManager m_ApStationsManager; 157 ApConfigUse m_ApConfigUse; 158 }; 159 } // namespace Wifi 160 } // namespace OHOS 161 162 #endif 163