!3346 Notify csa channel switch in staStateMashine

Merge pull request !3346 from 吴俊/master
This commit is contained in:
openharmony_ci 2024-11-21 08:09:22 +00:00 committed by Gitee
commit 6a687f8db2
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 45 additions and 0 deletions

View File

@ -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

View File

@ -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 &notifyParam)
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 &notifyParam)
return;
}
}
void StaMonitor::OnWpaCsaChannelSwitchNotifyCallBack(const std::string &notifyParam)
{
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

View File

@ -144,6 +144,13 @@ public:
*/
void OnWpaStaNotifyCallBack(const std::string &notifyParam);
/**
* @Description : Callback of the Csa channel switch
*
* @param notifyParam - authentication information [in]
*/
void OnWpaCsaChannelSwitchNotifyCallBack(const std::string &notifyParam);
private:
StaStateMachine *pStaStateMachine;
int m_instId;

View File

@ -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)

View File

@ -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);