mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-11-27 01:01:03 +00:00
!3346 Notify csa channel switch in staStateMashine
Merge pull request !3346 from 吴俊/master
This commit is contained in:
commit
6a687f8db2
@ -72,6 +72,7 @@ namespace Wifi {
|
||||
#define WIFI_SVR_CMD_STA_REPORT_DISCONNECT_REASON_EVENT 0x301F
|
||||
#define WIFI_SVR_CMD_STA_PORTAL_BROWSE_NOTIFY_EVENT 0x3020
|
||||
#define WIFI_SVR_CMD_STA_LINK_SWITCH_EVENT 0x3021
|
||||
#define WIFI_SVR_CMD_STA_CSA_CHANNEL_SWITCH_EVENT 0x3022
|
||||
|
||||
#define WPA_BLOCK_LIST_CLEAR_EVENT 0x4001
|
||||
#define WIFI_SVR_CMD_UPDATE_COUNTRY_CODE 0x4002
|
||||
|
@ -28,6 +28,7 @@ DEFINE_WIFILOG_LABEL("StaMonitor");
|
||||
|
||||
namespace OHOS {
|
||||
namespace Wifi {
|
||||
constexpr const char* WPA_CSA_CHANNEL_SWITCH_FREQ_PREFIX = "freq=";
|
||||
StaMonitor::StaMonitor(int instId) : pStaStateMachine(nullptr), m_instId(instId)
|
||||
{
|
||||
WIFI_LOGI("StaMonitor constuctor insId %{public}d", instId);
|
||||
@ -166,6 +167,9 @@ void StaMonitor::OnWpaStaNotifyCallBack(const std::string ¬ifyParam)
|
||||
case static_cast<int>(WpaEventCallback::EAP_SIM_NUM):
|
||||
OnWpaEapSimAuthCallBack(data);
|
||||
break;
|
||||
case static_cast<int>(WpaEventCallback::CSA_CHSWITCH_NUM):
|
||||
OnWpaCsaChannelSwitchNotifyCallBack(data);
|
||||
break;
|
||||
default:
|
||||
WIFI_LOGI("OnWpaStaNotifyCallBack() undefine event:%{public}d", num);
|
||||
break;
|
||||
@ -319,5 +323,21 @@ void StaMonitor::OnWpaEapSimAuthCallBack(const std::string ¬ifyParam)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void StaMonitor::OnWpaCsaChannelSwitchNotifyCallBack(const std::string ¬ifyParam)
|
||||
{
|
||||
WIFI_LOGD("%{public}s notifyParam:%{private}s", __FUNCTION__, notifyParam.c_str());
|
||||
if (pStaStateMachine == nullptr) {
|
||||
WIFI_LOGE("%{public}s The statemachine pointer is null.", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
std::string::size_type freqPos = 0;
|
||||
if ((freqPos = notifyParam.find(WPA_CSA_CHANNEL_SWITCH_FREQ_PREFIX)) == std::string::npos) {
|
||||
WIFI_LOGE("%{public}s csa channel switch notifyParam not find frequency!", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
std::string data = notifyParam.substr(freqPos + strlen(WPA_CSA_CHANNEL_SWITCH_FREQ_PREFIX));
|
||||
pStaStateMachine->SendMessage(WIFI_SVR_CMD_STA_CSA_CHANNEL_SWITCH_EVENT, CheckDataLegal(data));
|
||||
}
|
||||
} // namespace Wifi
|
||||
} // namespace OHOS
|
@ -144,6 +144,13 @@ public:
|
||||
*/
|
||||
void OnWpaStaNotifyCallBack(const std::string ¬ifyParam);
|
||||
|
||||
/**
|
||||
* @Description : Callback of the Csa channel switch
|
||||
*
|
||||
* @param notifyParam - authentication information [in]
|
||||
*/
|
||||
void OnWpaCsaChannelSwitchNotifyCallBack(const std::string ¬ifyParam);
|
||||
|
||||
private:
|
||||
StaStateMachine *pStaStateMachine;
|
||||
int m_instId;
|
||||
|
@ -989,6 +989,9 @@ int StaStateMachine::InitStaSMHandleMap()
|
||||
staSmHandleFuncMap[WIFI_SVR_COM_STA_ENABLE_HILINK] = [this](InternalMessagePtr msg) {
|
||||
return this->DealHiLinkDataToWpa(msg);
|
||||
};
|
||||
staSmHandleFuncMap[WIFI_SVR_CMD_STA_CSA_CHANNEL_SWITCH_EVENT] = [this](InternalMessagePtr msg) {
|
||||
return this->DealCsaChannelChanged(msg);
|
||||
};
|
||||
staSmHandleFuncMap[WIFI_SVR_COM_STA_HILINK_DELIVER_MAC] = [this](InternalMessagePtr msg) {
|
||||
return this->DealHiLinkDataToWpa(msg);
|
||||
};
|
||||
@ -3886,6 +3889,19 @@ void StaStateMachine::DealNetworkRemoved(InternalMessagePtr msg)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void StaStateMachine::DealCsaChannelChanged(InternalMessagePtr msg)
|
||||
{
|
||||
if (msg == nullptr) {
|
||||
LOGE("%{public}s InternalMessage msg is null", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
int newFreq = msg->GetParam1();
|
||||
WIFI_LOGI("%{public}s update freq from %{public}d to %{public}d", __FUNCTION__, linkedInfo.frequency, newFreq);
|
||||
linkedInfo.frequency = newFreq;
|
||||
// trigger wifi connection broadcast to notify sta channel has changed for p2penhance
|
||||
InvokeOnStaConnChanged(OperateResState::CONNECT_AP_CONNECTED, linkedInfo);
|
||||
}
|
||||
/* --------------------------- state machine Roaming State ------------------------------ */
|
||||
StaStateMachine::ApRoamingState::ApRoamingState(StaStateMachine *staStateMachine)
|
||||
: State("ApRoamingState"), pStaStateMachine(staStateMachine)
|
||||
|
@ -549,6 +549,7 @@ public:
|
||||
void HilinkSetMacAddress(std::string &cmd);
|
||||
void DealWpaStateChange(InternalMessagePtr msg);
|
||||
void DealNetworkRemoved(InternalMessagePtr msg);
|
||||
void DealCsaChannelChanged(InternalMessagePtr msg);
|
||||
#ifndef OHOS_ARCH_LITE
|
||||
void SetEnhanceService(IEnhanceService* enhanceService);
|
||||
void SetSelfCureService(ISelfCureService *selfCureService);
|
||||
|
Loading…
Reference in New Issue
Block a user