WiFi.off DeviceOS 5 keeps turning WiFi back on

We have an application that only uses the LAN connection so calls WiFi.off() at the start of the code before connection to Particle. This is working fine on DeviceOS 1.5.2 on an Argon.

Looking to run this code on a P2 and initially after you load the code on it seems to turn the WiFi off but the code seems to hang.

0000001376 [hal] INFO: WiFi on
0000001613 [net.lwip_rltk] INFO: promisc_deinit TODO
0000001617 [hal] INFO: WiFi off
0000001621 [system.nm] INFO: State changed: NONE -> DISABLED
0000001648 [comm] INFO: channel inited

A reboot allows the code to startup but the WiFi is getting turned back on.

0000001610 [hal] INFO: WiFi on
0000001846 [net.lwip_rltk] INFO: promisc_deinit TODO
0000001851 [hal] INFO: WiFi off
0000001855 [system.nm] INFO: State changed: NONE -> DISABLED
0000001882 [comm] INFO: channel inited
Freq switch time 5
0000002112 [hal] INFO: rltk_wlan_set_netif_info: 0, 94:94:4a:03:66:90
0000002321 [hal] INFO: WiFi on
0000002486 [app] INFO: Ethernet is on
0000002490 [system.nm] INFO: State changed: DISABLED -> IFACE_DOWN
0000002502 [system.nm] INFO: State changed: IFACE_DOWN -> IFACE_REQUEST_UP
0000002513 [net.ifapi] INFO: Netif wl3 state UP
0000002517 [system.nm] INFO: State changed: IFACE_REQUEST_UP -> IFACE_UP
0000002528 [hal] INFO: WiFi is already on
0000002529 [ncp.rltk.client] INFO: rltkOff
0000002530 [ncp.rltk.client] INFO: rltkOff done
0000002531 [hal] INFO: WiFi is already on
0000002534 [ncp.rltk.client] INFO: Try to connect to ssid: Sensoteq-Test
0000002536 [net.lwip_rltk] INFO: is_promisc_enabled
0000002537 [net.lwip_rltk] INFO: get_eap_phase
0000002581 [net.ifapi] INFO: Netif en2 state UP
0000002879 [net.en] INFO: Link up
0000002880 [net.ifapi] INFO: Netif en2 link UP, profile=NONE
0000002884 [system.nm] INFO: State changed: IFACE_UP -> IFACE_LINK_UP

Tried it on an Argon running DeviceOS 5.5.0 and it is also turning the WiFi back on, so looks to be a DeviceOS issue rather than a P2 issue.

System Mode is SEMI_AUTOMATIC
Tried calling Particle.disconnect(); before WiFi.off()

Could you provide sample code that illustrates the problem? There are too many possibilities for what it could be without knowing what the user firmware is doing.

It looks like the Particle.connect(); call is turning the WiFi back on.

I have cut code down for testing.
Can I send sample code direct to you rather than post it on here?

Unfortunately that is the expected behavior. Calling Particle.connect() calls the system network manager, which brings up all network interfaces.

Clearing the Wi-Fi credentials may prevent the Wi-Fi interface from being brought up, but not positive about that.