Using Particle Dev and WiFi

If I’m using Particle Dev, how can I manipulate the Wi-Fi radio, like WiFi.on()? I presume I need to include a library, but I can’t figure out which one. :frowning:

Thanks!

No you don’t need to add a library manually since the WiFi object gets instanciated and included via application.h which gets automatically #included to .INO projects by the preprocessor or you’ll have to include it yourself in .H/.CPP files.

Thanks. However, I’m using Particle Dev (the stand-along-ish Atom-based editor), and it appears that local compilations do not automagically include application.h. What’s the right way to address this? Do I do something similar to other libraries, namely clone the repository, copy the necessary bits into the same level directory as my application, and then compile locally?

There might be a misconception.
While Particle Dev is a local editor, it does not compile locally but sends the project files to the Particle build farm and downloads the resulting bin.

What’s your main project files name and path?
Do you get any error messages?

Ahhhhh, sorry, my bad. Is there a way to do a completely local toolchain?

The directory is /Users/i831533/src/Arduino/SAP/OCM_demo, and the name of the file is OCMdemo_photon.ino.

Following up to my own post, for some inexplicable reason, it now works. I didn’t change anything. :smile:

1 Like

Yes, you can set up a local toolchain.
A nice and easy installer was put together by @mumblepins and can be found here
Toolchain for Windows Installer


Just saw you got it working now - congrats :+1:
One thing you need to watch out is that you have to save the file, since only the stored files will be compiled and not what you see in the IDE.
This comes from the fact that only stored edits can actually be sent to the build farm :wink:


But to test the accessability of functions like WiFi.on() and such you could try this short sketch (saved in a .INO file)

SYSTEM_MODE(SEMI_AUTOMATIC)

void setup()
{
  pinMode(D7, OUTPUT);
  digitalWrite(D7, HIGH);
  WiFi.off();
  Serial.begin(115200);
  while(!Serial.available);  // wait till you enter some byte via USB serial
  WiFi.connect();
  while(!WiFi.ready());
  {
    Particle.process();
    delay(100);
  }
  digitalWrite(D7, LOW);
  Serial.println("Now we are connected to WiFi");
  Particle.connect();
}

void loop()
{
}

I don’t suppose there’s a Mac installer for the local toolchain, is there?

Thanks!

There are some threads about that too
e.g.
https://github.com/spark/firmware/blob/develop/docs/dependencies.md
[Debugging] Netbeans IDE on Mac OSX [17 June 2015]
Help setting up Eclipse development environment on Mac - SOLVED
(Almost) no-brainer linux virtual machine for firmware building
https://docs.google.com/document/d/1izv83fnSMMKyw-7tIbnH4RleJCthTPgSBkJR6swwFzo/edit?usp=sharing