PAGE UNDER CONSTRUCTION
This page is being put together due to this discussion: https://digistump.com/board/index.php/topic,2132.0.html
In a nutshell, you can use an Oak offline if you serial program it. No wifi or internet is needed for that mode of programming. However, you may not be using an Oak if that was the case. So perhaps your internet or wifi is intermittent, or you want to be able to turn the wifi off the save power. Can you do it? YES!
Basically, run the Oak in manual safe mode only mode so it doesn't auto-reboot when there is no wifi, and run the oak in SYSTEM_MODE(SEMI_AUTOMATIC) or SYSTEM_MODE(MANUAL)? to manage the wifi connection / internet connection yourself in code. You can then have the Oak connect to wifi when it's available, or in response to a button, etc.
Here you basically have to options - run the Oak in SEMI_AUTOMATIC or MANUAL mode. In SEMI_AUTOMATIC mode, the Oak will try to connect to it's configured WiFi network automatically, but won't establish a Particle connection. In MANUAL mode, it won't connect to the WiFi or Particle automatically, it's entirely up to you to tell it how and when to connect.
Why would you do this? Maybe you want to reduce power consumption, or want to run some time sensitive code, so don't want the WiFi or Particle connection routines causing timing or stability issues. Depending on whether you want an internet connection when your code starts will determine whether which mode you want to start the Oak in.
Examples to come
If you want to manage your wifi manually, rather than via the SoftAP / OakConfig page, you can do that too. You have to option of using DHCP IP addresses, or static IP addresses also. If you don't know what a Static or DHCP IP address is, stuck with DHCP. The following two examples don't have a Particle connection until you enable them, nor do they connect to your WiFi until you tell them to.
SYSTEM_MODE(MANUAL); #include <ESP8266WiFi.h> //Static IP stuff char SSID[] = "yournetwork"; // your network SSID char passwd[] = "yourpassword"; // your network password void setup() { pinMode(LED_BUILTIN, OUTPUT); //don't save these details WiFi.persistent(false); //start the WiFi connection process WiFi.begin_internal(SSID, passwd, 0, NULL); //wait for WiFi to connect while (WiFi.status() != WL_CONNECTED) { digitalWrite(LED_BUILTIN, HIGH); delay(100); digitalWrite(LED_BUILTIN, LOW); delay(100); } } void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
SYSTEM_MODE(MANUAL); #include <ESP8266WiFi.h> //Static IP stuff char SSID[] = "yournetwork"; // your network SSID char passwd[] = "yourpassword"; // your network password //WiFi config stuff IPAddress ip(192, 168, 0, 70); //your static IP IPAddress gateway(192, 168, 0, 1); //your gateway IP IPAddress subnet(255, 255, 255, 0); //your subnet mask void setup() { pinMode(LED_BUILTIN, OUTPUT); //don't save these details WiFi.persistent(false); //configure the WiFi to use the custom settings WiFi.config(ip, gateway, subnet); //start the WiFi connection process WiFi.begin_internal(SSID, passwd, 0, NULL); //wait for WiFi to connect while (WiFi.status() != WL_CONNECTED) { digitalWrite(LED_BUILTIN, HIGH); delay(100); digitalWrite(LED_BUILTIN, LOW); delay(100); } } void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
MMTC