I am using WiFiNina and would like to move some of the setup and configuration code into a separate file, so I can modularise and reuse it. Is it possible to pass the WiFi object in the .ino to a function in a library with something like the below?
void WiFiSetup(WiFi myWiFi) {
}
Since there's no declaration of a WiFi object in the sketch, I'm not sure how to pass it, or if that can even be done.
And if you want to know for the general case, you want to pass the parameter by reference (add the & before the parameter name) so that you don’t ask the compiler to build a copy and work on the copy. That’s usually a bad idea esp. when the instance deals with hardware resources,