Azure / azure-sphere-samples

Samples for Azure Sphere
Other
222 stars 200 forks source link

Wifi disabled automatically in azure sphere #269

Closed nishithvpoojary closed 10 months ago

nishithvpoojary commented 10 months ago

Hi. In the Sample https://github.com/Azure/azure-sphere-samples/tree/main/Samples/WiFi/WiFi_HighLevelApp after adding the wifi and enabling it, if i disconnect the device without doing the remaining functions( i.e., the disable , duplicate and delete ) and connect the device back again.., why does the wifi state shows disabled. The wifi state stays enabled if i add it through command prompt, but if it is done through code, it becomes disabled automatically. How is it? Thank you.

jamesadevine commented 10 months ago

Are you calling WifiConfig_PersistConfig in your code?

nishithvpoojary commented 10 months ago

Yes. Is that the function causing this ? Thanks for your reply @jamesadevine

jamesadevine commented 10 months ago

Well, I think minimally you need to:

1) Call WifiConfig_AddNetwork 2) Call the WifiConfig_Set* calls for the network ID returned in 1). 3) Call WifiConfig_SetNetworkEnabled 4) Call WifiConfig_PersistConfig

Are making all the calls listed above?

nishithvpoojary commented 10 months ago

i checked it now.... WifiConfig_PersistConfig was missing inside the WifiNetworkEnableState(void).. Now it is working perfectly. Thanks a lot.

jamesadevine commented 10 months ago

Perfect! no problem