[Ovmsdev] WiFi client not switching to better AP

Stephen Casner casner at acm.org
Sun Dec 20 04:51:05 HKT 2020


OK, a proposed change is attached.

                                                        -- Steve

On Sat, 19 Dec 2020, Michael Balzer wrote:

> The reason to emit that event is to inform all potential listeners of the new
> state, so they can keep their internal state synchronized.
>
> Regards,
> Michael
>
>
> Am 19.12.20 um 19:09 schrieb Stephen Casner:
> > We don't need to emit the network.wifi.sta.bad event to cause
> > WifiDisconnect() to be called because that is already happening.  Is
> > there some other reason for emitting that event?
> >
> >                                                          -- Steve
> >
> > On Sat, 19 Dec 2020, Michael Balzer wrote:
> >
> > > It's also the event emission, keeping the handling close together is for
> > > code
> > > readability. The compiler will probably inline that call anyway.
> > >
> > > Regards,
> > > Michael
> > >
> > >
> > > Am 19.12.20 um 18:32 schrieb Stephen Casner:
> > > > On Sat, 19 Dec 2020, Michael Balzer wrote:
> > > >
> > > > > If we need to force good/bad state, I suggest adding a method for this
> > > > > right
> > > > > after WifiStaCheckSQ().
> > > > Rather than just adding m_wifi_good = false in some place like
> > > > WifiStaStop()?  Another method doesn't seem warranted.  That is a
> > > > member variable, not something local to WifiStaCheckSQ().
> > > >
> > > >                                                           -- Steve
> > > > _______________________________________________
> > > > OvmsDev mailing list
> > > > OvmsDev at lists.openvehicles.com
> > > > http://lists.openvehicles.com/mailman/listinfo/ovmsdev
> > > --
> > > Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
> > > Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
> > _______________________________________________
> > OvmsDev mailing list
> > OvmsDev at lists.openvehicles.com
> > http://lists.openvehicles.com/mailman/listinfo/ovmsdev
>
> --
> Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
> Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
-------------- next part --------------
diff --git a/vehicle/OVMS.V3/main/ovms_netmanager.cpp b/vehicle/OVMS.V3/main/ovms_netmanager.cpp
index ec4933a4..c5228233 100644
--- a/vehicle/OVMS.V3/main/ovms_netmanager.cpp
+++ b/vehicle/OVMS.V3/main/ovms_netmanager.cpp
@@ -350,7 +350,7 @@ void OvmsNetManager::WifiStaGotIP(std::string event, void* data)
     ScheduleCleanup();
   #endif
 
-  WifiStaCheckSQ(NULL);
+  WifiStaCheckSQ(StdMetrics.ms_m_net_wifi_sq);
   }
 
 void OvmsNetManager::WifiStaLostIP(std::string event, void* data)
@@ -377,6 +377,7 @@ void OvmsNetManager::WifiStaConnected(std::string event, void* data)
 
 void OvmsNetManager::WifiStaStop(std::string event, void* data)
   {
+  WifiStaSetSQ(false);
   if (m_wifi_sta)
     {
     m_wifi_sta = false;
@@ -435,6 +436,15 @@ void OvmsNetManager::WifiStaCheckSQ(OvmsMetric* metric)
     }
   }
 
+void OvmsNetManager::WifiStaSetSQ(bool good)
+  {
+  if (m_wifi_sta && m_wifi_good != good)
+    {
+    m_wifi_good = good;
+    MyEvents.SignalEvent(good ? "network.wifi.sta.good" : "network.wifi.sta.bad", NULL);
+    }
+  }
+
 void OvmsNetManager::WifiUpAP(std::string event, void* data)
   {
   m_wifi_ap = true;


More information about the OvmsDev mailing list