Re: https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/issues/127

I've pushed my solution in commit d1f466d9a7fac6afbb4b768425164c9b367aca1a.

Please check how this works for your setups.

It normally doesn't need any manual control, the shell commands were a by-product, but may be useful. Example:
OVMS# net list
ID        Flags     Handler   Local                  Remote
3f81ddf0  00000000  3f821380  192.168.2.101:80       192.168.2.107:48840
3f81ce3c  00000100  3f81b708  192.168.4.1:80         192.168.4.2:45516
3f81d1e8  00000100  3f81def8  192.168.2.101:80       192.168.2.107:48814
3f81b538  00000000  00000000  192.168.2.101:54799    188.138.75.229:6867
3f81b098  00000000  3f81bfb8  192.168.2.101:22       192.168.2.107:55362

OVMS# net close 3f81b098
Close signal sent to 1 connection(s)

OVMS# net list
ID        Flags     Handler   Local                  Remote
3f81bb84  00000000  3f81e3ac  192.168.2.101:80       192.168.2.107:48844
3f81ce3c  00000100  3f81b708  192.168.4.1:80         192.168.4.2:45516
3f81d1e8  00000100  3f81def8  192.168.2.101:80       192.168.2.107:48814
3f81b538  00000000  00000000  192.168.2.101:54799    188.138.75.229:6867
Issuing "net close 0" closes all connections.

An automatic cleanup log looks like this for an AP station disconnect:
I (143741) wifi: station: 30:75:12:f5:71:c7 leave, AID = 1
I (143791) wifi: n:11 0, o:11 0, ap:11 2, sta:11 0, prof:11
I (143791) events: Signal(system.event)
I (143881) events: Signal(system.wifi.ap.sta.disconnected)
I (143931) netmanager: WIFI access point station disconnected
D (143981) netmanager: send cmd 3 from 0x0
D (144041) netmanager: done cmd 3 from 0x0
I (144091) esp32wifi: AP station disconnected: id: 1, MAC: 30:75:12:f5:71:c7
D (144351) netmanager: MongooseTask: got cmd 3 from 0x0
D (144391) netmanager: CleanupConnections: conn 3f81e010 -> iface ap2
I (144441) netmanager: CleanupConnections: closing conn 3f81e010: AP peer disconnected
D (144491) netmanager: CleanupConnections: conn 3f81bb2c -> iface ap2
I (144531) netmanager: CleanupConnections: closing conn 3f81bb2c: AP peer disconnected
D (144591) netmanager: CleanupConnections: conn 3f81bd08 -> iface ap2
I (144641) netmanager: CleanupConnections: closing conn 3f81bd08: AP peer disconnected
D (144681) netmanager: CleanupConnections: conn 3f81d1e8 -> iface st1
D (144731) netmanager: CleanupConnections: conn 3f81baa0 -> iface st1
D (144771) netmanager: CleanupConnections: conn 3f81b538 -> iface st1
D (144821) netmanager: CleanupConnections: conn 3f81b098 -> iface st1
D (144871) netmanager: MongooseTask: done cmd 3 from 0x0
D (145191) websocket: WebSocket connection 0x3f81ce3c closed; 1 clients active

…and like this for a client network disconnect:
I (535888) wifi: bcn_timout,ap_probe_send_start
I (538398) wifi: ap_probe_send over, resett wifi status to disassoc
I (538398) wifi: state: run -> init (1)
I (538398) wifi: pm stop, total sleep time: 196172381 us / 249569092 us
I (538398) wifi: n:11 0, o:11 2, ap:11 2, sta:11 2, prof:11
I (538408) netmanager: Interface priority is pp3 (10.170.195.13/255.255.255.255 gateway 10.64.64.64)
I (538408) netmanager: Set DNS#0 212.9.0.135
I (538408) netmanager: Set DNS#1 212.9.0.136
I (538408) netmanager: Set DNS#2 0.0.0.0
I (538408) netmanager: WIFI client down (with MODEM up): reconfigured for MODEM priority
D (538408) netmanager: send cmd 3 from 0x0
D (538408) netmanager: done cmd 3 from 0x0
I (538408) esp32wifi: STA disconnected with reason 200
I (538408) time: Network was reconfigured: restarting SNTP client
I (538418) ovms-server-v2: Network was reconfigured: disconnect, and reconnect in 10 seconds
I (538418) ovms-server-v2: Status: Network was reconfigured: disconnect, and reconnect in 10 seconds
I (538558) ovms-server-v2: Status: Disconnected
D (538558) netmanager: MongooseTask: got cmd 3 from 0x0
D (538558) netmanager: CleanupConnections: conn 3fff2854 -> no iface
I (538568) netmanager: CleanupConnections: closing conn 3fff2854: interface/link down
D (538578) netmanager: CleanupConnections: conn 3fff514c -> no iface
I (538578) netmanager: CleanupConnections: closing conn 3fff514c: interface/link down
D (538588) netmanager: CleanupConnections: conn 3fff5054 -> no iface
I (538588) netmanager: CleanupConnections: closing conn 3fff5054: interface/link down
D (538588) netmanager: MongooseTask: done cmd 3 from 0x0
D (538598) websocket: WebSocket[0x3fff2854] handler 0x3ffdff20 closed; 0 clients active

Regards,
Michael

-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26