Out of the box the Core wouldn’t connect (kept blinking blue) but I believe this is due to the unreliable internet at my current location, so it shouldn’t be a real issue.
I would like to know though, after flashing my own firmware onto the spark can I still use the iPhone Spark App to just connect the core to a WiFi location without using SparkCloud?
Do I need to add any code to achieve this, or does the phone app take care of everything somehow?
Lastly, if the connection somehow drops, is there a way to automatically try and reconnect?
I can certainly try and clear things up. The iPhone Spark App, the one that the http://docs.spark.io/start/ says to download in order to create an account and then connect your core to WiFi, by using the WiFi that your phone is currently connected to.
What I’m wondering is after I flash my own code/firmware onto the Core which would replace the tinker app that was originally installed, can I:
Still use the iPhone Spark App’s functionality of connecting to WiFi?
Can I do this without the aid of SparkCloud?
Would I need to add some additional code to my own code to achieve 1. and/or 2.
If 1-3 can be achieved; if for some reason my Core disconnects from WiFi or if WiFi goes down, will the Core be able to recognize that it’s disconnected and attempt to reconnect?
Any insight to the above questions would be greatly appreciate
Sorry if I still didn’t explain properly! I can attempt to explain again.
I am not sure I understand well, but I will try a generic answer, maybe it sheds some light on it. Some of it is pretty advanced stuff though. Flashing through the Spark Cloud (using Web IDE or Spark Dev) and being ready to do Factory reset and new setup using iPhone App is easiest for start.
iPhone APP is used for initial setup, telling the core WiFI and password. After that, iPhone app is no longer needed. Core must flash blue (being in Smart Config mode). When you upload sketch, you can put Core into Smart Config holding MODE button for 3 seconds. When you upload a code which somehow breaks Spark Cloud handling, you can do factory reset, which clears sketch and puts Core back into Smart Config mode, allowing it to be set up by iPhone app once more. See the documentation: http://docs.spark.io/connect/
You need Spark Cloud for uploading sketches to your core, which also means core should be connected to internet. Other possibilities are installing local Cloud or uploading sketches in DFU mode, which is more complicated. DFU mode doesn’t require any cloud conenction. There are several good topics about it on this forum.
You can use different modes, preventing Spark Core connecting to the Cloud, It is achieved by SYSTEM_MODE(SEMI_AUTOMATIC); or SYSTEM_MODE(MANUAL); commands, but I can’t find documentation for it, only several topics on the forum. Be brepared for factory reset when experimenting with these commands, as you can’t upload sketch when core is not connected to cloud (Breathing Cyan). Or use DFU mode.
Yes, core actively tries to reconnect to WiFi (and Cloud unless you use different SYSTEM_MODE) and AFIK it doesn’t give up. Be careful of long running loops (>10s), you need to call Spark.process() or a delay() in them, or core drops off the cloud
Still use the iPhone Spark App's functionality of connecting to WiFi?
Yes, the Spark App's ability to connect a core to the network is independent of the code running on the Core. All you have to do is put the core in listening mode (flashing blue) and the Spark app will do its work
Can I do this without the aid of SparkCloud?
Yes and no. You can connect the core to a new wifi connection without the cloud but you won't be able to claim a new core
Would I need to add some additional code to my own code to achieve 1. and/or 2.
N/A
If 1-3 can be achieved; if for some reason my Core disconnects from WiFi or if WiFi goes down, will the Core be able to recognize that it's disconnected and attempt to reconnect?
Thanks @lami for the detailed answers, you really put things into perspective and now I have a reference thread to refer for this specific information!
With your answer to number 4. when you say :
Does this mean 1, That if the core is running for a period of >10s it drops off cloud? OR 2. That if I have one particular loop in my firmware that runs for >10s it drops off the cloud?
It is variant 2. Core needs to call home every once a while and if Cloud doesn’t hear from core for 10s or so, it is considered offline. So avoid loops like:
// wait for data
while (!Serial.ready()) {
// do nothing
}
If nothing would arrive on serial port for 10s, core will drop off. You can avoid it by letting code run off the main loop() function, add a delay() or Spark.process() call.
So you can use something like this:
while (!Serial.ready()) {
Spark.process();
}
I use this code in setup(), it waits until I connect serial console and send anything to Core, so I don’t miss any debug information.