Unable to use the WiFi class (WiFi doesn't have a type)

Hello,

I am using the first spark core that was released. However I downloaded the latest libraries but I am not able to build the code with the following basic code snippet…

//-----------------------------------------------------------------------------------------

 #include "application.h"
SYSTEM_MODE(MANUAL);

WiFi.on();
WiFi.clearCredentials();
WiFi.setCredentials("Santhanand", "8977117950", WPA2);
WiFi.connect();

void setup()
{
  Serial.begin(9600);
  if (WiFi.ready())
     Serial.println("Wifi ready");
}

void loop()
{

}

//------------------------------------------------------------------------------------------

So is my sequence OK? And am I missing any headers here ?

Thanks
Gaurav…

1 Like

you will want to put this in setup( )

WiFi.on();
WiFi.clearCredentials();
WiFi.setCredentials("Santhanand", "8977117950", WPA2);
WiFi.connect();
3 Likes

Hey @BulldogLowell,

Sorry for getting back late. But when I put this inside setup(), I get the same error. I downloaded the fresh libraries as is and just modified the tinker application on the following part and compiled it:

SYSTEM_MODE(MANUAL);

/* This function is called once at start up ----------------------------------*/
void setup()
{

WiFi.on();
WiFi.clearCredentials();
WiFi.setCredentials(“Santhanand”, “8977117950”, WPA2);
WiFi.connect();
//Setup the Tinker application here

//Register all the Tinker functions
Spark.function("digitalread", tinkerDigitalRead);
Spark.function("digitalwrite", tinkerDigitalWrite);

Spark.function("analogread", tinkerAnalogRead);
Spark.function("analogwrite", tinkerAnalogWrite);

}

Still the same error sir.

I think I am missing some headers here. Where are these defined??

Thanks,
Gaurav

In your first post you had `#include “application.h” but I can’t see it in your second post. Where is iit gone?

Just to confirm
Are you using Spark Dev or local Toolchain rather than Web IDE?
Is your main file applicaiton.CPP?

Are you also including the functions for each of your spark functions…

SYSTEM_MODE(MANUAL);

void setup()
{

WiFi.on();
WiFi.clearCredentials();
WiFi.setCredentials("Santhanand", "8977117950", WPA2);
WiFi.connect();
//Setup the Tinker application here

//Register all the Tinker functions
Spark.function("digitalread", tinkerDigitalRead);
Spark.function("digitalwrite", tinkerDigitalWrite);
Spark.function("analogread", tinkerAnalogRead);
Spark.function("analogwrite", tinkerAnalogWrite);
}

void loop()
{
  //nothing happening here
}

int tinkerDigitalRead(String command)
{
  return -1;
}

int tinkerDigitalWrite(String command1)
{
  return -1;
}

int tinkerAnalogRead(String command2)
{
  return -1;
}

int tinkerAnalogWrite(String command3)
{
  return -1;
}

compiles on the web IDE

I am compiling it using the command line in Linux.

Actually it’s there, I didn’t even try out my own application. Just downloaded the libraries from github and modified the tinker app’s mode to MANUAL and added the Wifi credentials. Then I just compiled it using the make utility and it threw the error.

My file is the application.cpp application file found inside …/firmware/src/

Then I am definitely missing out on some headers and their respective definition files which I guess didn’t come bundled in the libraries that I downloaded.

I am using it it office on a POC but my IT infrastructure doesn’t allow me to connect to the spark cloud. Hence I am using Linux to compile and update the core using dfu-utils instead of the Web IDE.

If anyone has compiled the same using the make utility, please let me know.

Thanks for the input @BulldogLowell.

in the first code above there is a space before the #include… this causes errors from memory

In this case the quoted statement should have been checked :wink:

It’s always good to double check - I’ve (re)learnt that just a while ago :blush: :wink: