1 /*
2  * Copyright (c) 2023 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 
16 #ifndef OHOS_WIFI_STA_MANAGER_H
17 #define OHOS_WIFI_STA_MANAGER_H
18 
19 #include <mutex>
20 #include <functional>
21 #include "wifi_errcode.h"
22 #include "sta_service_callback.h"
23 #include "wifi_internal_msg.h"
24 
25 namespace OHOS {
26 namespace Wifi {
27 class WifiStaManager {
28 public:
29     WifiStaManager();
30     ~WifiStaManager() = default;
31 
32     StaServiceCallback& GetStaCallback(void);
33     void StopUnloadStaSaTimer(void);
34     void StartUnloadStaSaTimer(void);
35     void CloseStaService(int instId = 0);
36     void StartSatelliteTimer(void);
37     void StopSatelliteTimer(void);
38     void DealStaOpened(int instId);
39     void DealStaStopped(int instId);
40 
41 private:
42     void InitStaCallback(void);
43     bool IgnoreConnStateChange(int instId = 0);
44     void DealStaConnChanged(OperateResState state, const WifiLinkedInfo &info, int instId = 0);
45     void DealWpsChanged(WpsStartState state, const int pinCode, int instId = 0);
46     void DealStreamChanged(StreamDirection direction, int instId = 0);
47     void DealRssiChanged(int rssi, int instId = 0);
48     void DealAutoSelectNetworkChanged(int networkId, int instId);
49     void PublishWifiOperateStateHiSysEvent(OperateResState state);
50 private:
51     StaServiceCallback mStaCallback;
52     uint32_t unloadStaSaTimerId{0};
53     std::mutex unloadStaSaTimerMutex;
54     uint32_t satelliteTimerId{0};
55     std::mutex satelliteTimerMutex;
56 };
57 
58 }  // namespace Wifi
59 }  // namespace OHOS
60 #endif // OHOS_WIFI_STA_MANAGER_H