[Ovmsdev] WiFi client not switching to better AP

Michael Balzer dexter at expeedo.de
Fri Dec 18 03:26:54 HKT 2020


Steve,

the RSSI is read for the connection in use, -127.0 is the value for the 
unconnected state. The value needs to be smoothed as it's quite jumpy, 
so may need 2-3 seconds after connect to get to the actual value.

IP association normally takes long enough from connect to get the RSSI 
into a usable state, and thus the WifiStaCheckSQ() call in 
WifiStaGotIP() is meant to switch to the network as soon as possible.

For the case of fast DHCP association, you could try speeding the RSSI 
adoption up by checking for m_sta_rssi == -1270 and skipping or 
weakening the smoothing in that case, so the first RSSI read after a 
connect will be used immediately / stronger. But I remember that first 
value being far too optimistic in my test cases, which were having a 
single AP barely reachable from the car. I suggest testing that case 
specifically, as it seems your current test setup is close to a best 
case scenario.

OTOH, removing the WifiStaCheckSQ() call in WifiStaGotIP() would 
introduce at most 1 second delay for the netmanager to switch to the 
Wifi network, as the next ticker.1 run would trigger the switch. So 
that's not critical I think.

Another option: WifiStaCheckSQ(NULL) triggers the events unconditionally 
of the previous state, just by the current signal quality. That was 
meant to process a changed threshold configuration, but I don't remember 
why I did that in WifiStaGotIP(). Maybe that's why the "bad" event got 
triggered twice? You could try passing ms_m_net_wifi_sq there instead of 
NULL.

Regards,
Michael



Am 17.12.20 um 03:58 schrieb Stephen Casner:
> Following up #2:  Perhaps we can just remove the call to
> WifiStaCheckSQ() in WifiStaGotIP()?  If the IP address has just been
> assigned then the radio must be working well enough to exchange DHCP
> packets.  That would avoid the problem I observed that the signal
> quality measurement was not yet accurate at that point.
>
> With that call removed and with a script "wifi reconnect" attached to
> the network.wifi.sta.bad event I can walk to the corners of my house
> carrying the OVMS module and see it switch cleanly among my three APs.
> See the attached log.
>
>                                                          -- Steve
>
> On Wed, 16 Dec 2020, Stephen Casner wrote:
>
>> Following up: I see that OvmsNetManager::WifiStaGotIP() calls
>> WifiStaCheckSQ() at the start of the connection, but it looks like the
>> radio hasn't fully adapted yet or something.  The signal quality can
>> be -95.5 -99.2 dBm and sometimes even -127.0 dBm, which looks like an
>> uninitialized value, even though wifi scan says the RSSI is -60.  (Is
>> RSSI calibrated to dBm for this system?)
>>
>> If I stop the looping by "wifi mode off" and "wifi mode client" then I
>> see a good signal quality -79.3 reported after getting IP, and then if
>> I do "wifi status" the reported signal quality is -56.0 dBm.  This is
>> all with my test OVMS v3.0 sitting on my desk.
>>
>> So would it make sense to introduce some delay here if the signal
>> quality is not good enough yet?
>>
>>                                                          -- Steve
>>
>> On Mon, 14 Dec 2020, Stephen Casner wrote:
>>
>>> On Mon, 7 Dec 2020, Michael Balzer wrote:
>>>
>>>> If you don't mind frequent disconnects in poor Wifi situations, a simple
>>>> solution now is to attach a "wifi reconnect" command call to the
>>>> "network.wifi.sta.bad" event. I added that command on the Wifi rework some
>>>> months ago.
>>> I tested this today with the three APs in my home but ran into
>>> trouble.  It looks like the event was emitted again at the end of the
>>> reconnection process so another reconnect was performed and it kept
>>> looping.  See the attached log.  I have not investigated this
>>> carefully.
>>>
>>>> For a better, general solution, we could e.g. count the "network.wifi.sta.bad"
>>>> events on the same network (or better: check the event frequency) and
>>>> disconnect when reaching some (tunable) threshold. The next automatic scan
>>>> then connects to the best network available. Getting stuck in the "bad signal"
>>>> state for too long would also need to trigger a disconnect.
>>> I'll look at this further to see whether a smooth transition from one
>>> AP to another on the same network is possible.
>>>
>>>                                                          -- Steve
>> _______________________________________________
>> OvmsDev mailing list
>> OvmsDev at lists.openvehicles.com
>> http://lists.openvehicles.com/mailman/listinfo/ovmsdev
>>
> >
>
> _______________________________________________
> 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20201217/775b25b1/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20201217/775b25b1/attachment.sig>


More information about the OvmsDev mailing list