I recently got some P2's and trying to get my P1 code ported to P2. When I setup the Static IP Config and perform WiFi.Connect(), my P2 is not connecting on the desired static IP. It is connecting to WiFi at any IP address - I think like DHCP. My code is posted below:
Is there a reason you commented out the .source()? I think it's required. It's required, if a source is not specified all of the configuration options are ignored.
Also you should use WiFi.setConfig() not Network.setConfig().
There's a full example in the pull request that added static IP address support that may be helpful.
Also make sure your device has Device OS 5.3.0 on it already, including all system dependencies, because if you're missing something like a bootloader, the device won't run your code until the dependencies are resolved, and will attempt to go online using the current network configuration, which is presumably DHCP, to get the dependencies OTA.
and its working now. Will test the code on a fresh P2 and verify that the above changes in my code are the reason its working and not because I ran the example code (as the network configurations are stored in flash they are getting retrieved regardless of what changes I did in my code).
Will update here in few hours. Nonetheless. Thanks for this!
I got a chance to verify my hypothesis that since the example code had run successfully the code with above changes gave the result of static IP as the config was stored in the flash.
I was able to make it work by adding the .profile() to the config parameter as mentioned in the example code. So the config is stored against the profile I believe.