Expected unqualified-id before '.' token

sketch_oct30a.ino:7:10: error: expected unqualified-id before '.' token
WiFiUDP.begin(); //WiFiNINA - WiFiUDP.begin() - Arduino Reference

//create a WiFi connection

#include <WiFiNINA.h>

void connect_WiFi() {
  WiFiUDP.begin();  //https://www.arduino.cc/reference/en/libraries/wifinina/wifiudp.begin/
                    //[WiFiNINA]Initializes the WiFi UDP library and network settings. Starts WiFiUDP socket,
                    //listening at local port PORT.
                    //  WL_CONNECTED when connected to a network
                    //  WL_IDLE_STATUS when not connected to a network, but powered on
                    //    attempt to connect to Wifi network:

} //void connect_WiFi()


I cut the offending section out of the larger sketch while still getting the same error. I've tried copy-and-pasting the command in question from the reference library, to get the same result. This probably has something to do with the use of a library function, but I have no idea what the problem is.

Perhaps add:

#include <WiFiUdp.h>

Edit: case oops.

Example .INO also shows capitalization...

#include <SPI.h>
#include <WiFiNINA.h>
#include <WiFiUdp.h>

Did you forget to enter the port number?

I added WiFiClient client(80);
Same problem.

I tried both #include <WiFiUDP.h> and <WiFiUdp.h>.
Same problem.

I added WiFiClient client(80);
Same problem.

Then use
client.begin();

Always post the revised code.

Did you think to look at the example code that @xfpd linked to?

It clearly shows that you have to create an instance of the WifiUDP class and use that.

#include <WiFiUdp.h>
.
.
.
WifiUDP wifiudp;
.
.
.
wifiudp.begin(<insert port number>);
1 Like
#include <WiFiUdp.h>

WiFiUDP wifiudp;

wifiudp.begin(80); 

yields.... 9:1: error: 'wifiudp' does not name a type wifiudp.begin(80);

However, the '.' error is gone, and I thank you for that.
Just so you know... <WiFiNINA.h> gives the same result.

None of the capitalization matches anything, and I don't understand why WiFiUDP needs to be redefined. I don't understand the point of this structure. Where is the documentation describing what 'WiFiUDP wifiudp;' is doing, and why?

Thank you for your assistance!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.