platform: Add update WIFI state func

This commit is contained in:
世界 2025-02-20 14:42:09 +08:00
parent 97ce666e43
commit 93b68312cf
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
4 changed files with 20 additions and 36 deletions

View file

@ -354,6 +354,18 @@ func (r *NetworkManager) WIFIState() adapter.WIFIState {
return r.wifiState
}
func (r *NetworkManager) UpdateWIFIState() {
if r.platformInterface != nil {
state := r.platformInterface.ReadWIFIState()
if state != r.wifiState {
r.wifiState = state
if state.SSID != "" {
r.logger.Info("updated WIFI state: SSID=", state.SSID, ", BSSID=", state.BSSID)
}
}
}
}
func (r *NetworkManager) ResetNetwork() {
conntrack.Close()
@ -414,15 +426,7 @@ func (r *NetworkManager) notifyInterfaceUpdate(defaultInterface *control.Interfa
}
}
r.logger.Info("updated default interface ", defaultInterface.Name, ", ", strings.Join(options, ", "))
if r.platformInterface != nil {
state := r.platformInterface.ReadWIFIState()
if state != r.wifiState {
r.wifiState = state
if state.SSID != "" {
r.logger.Info("updated WIFI state: SSID=", state.SSID, ", BSSID=", state.BSSID)
}
}
}
r.UpdateWIFIState()
if !r.started {
return