Since you’re using semi-automatic mode, you won’t be connected to the Spark cloud until the first time you call Spark.connect. This means that the first time you call Spark.connected it will always be false. That said, it shouldn’t make it break, just unneeded code. You also don’t need to clear the credentials, you can just set them and overwrite the old ones.
I think the reason it might be connecting with the old credentials is because you’re not calling WiFi.on anywhere. It’s unclear in the documentation, but if you use anything except automatic mode you need to call that yourself. It’s being called implicitly with Spark.connect here, but I’m assuming that since it’s not on when you’re setting credentials they’re not actually being saved.
I’m also curious as to why you have a while loop trying to connect in addition the Spark.connect call above it.
Now I can give the SSID and password to the SD card and spark can read those credential at the beginning and connect with them.
However I figured that, spark keeps the previous credentials as well, and as far as I noticed it connects to strongest network, not sure though. Maybe someone can explain this process better? Any way, here you have a solution
I am really surprised that there isn’t a simple solution to being able to change the SSID and Password of a Spark core as needed when distributing these gizmos. I also have a small run (dozens of devices?) that need to be mailed out and locally reconfigured by the recipient.
I can see the catch-22 situation.
When packaging a Spark core based product, good practice would be to provide a recessed ‘Reset/Setup’ pushbutton inside the case but accessible through a small hole from the outside, similar to the one found on many devices, the kind that you need to press with a paperclip. Pressing the button during bootup would place the Spark core in ‘beacon mode’ (I made that up, I don’t know the proper term), where it would be seen by a mobile app device and show/ask for SSID and password, which could then be written back to the Spark core.
But then, the button should not be necessary at all; if the Spark fails to connect to WiFi, it should be possible to automatically drop to what I call ‘beacon mode’ and be visible to enter new credentials. Having a button provides physical security where you have to press a button rather than just drive-by.
You could even have an option in the mobile app to require a password (as stored in the core’s flash) to change the connectivity settings.
This business of plugging in USB cables, using SD cards with text files, sharing accounts, etc is really rinky-dink for what should be basic built-in functionality on a device of this type.
I am disappointed that the ‘bigger picture’ has been ignored.
You do realise that this ‘beacon mode’ you’re talking about already exists in the form of the ‘listening mode’, noticeable by the blinking blue LED? You can get there by holding the MODE button until it starts blinking blue. You can then pass it new credentials through the app. So your whole concept of using a button to get to this mode is already there.
As long as there are credentials stored, it will keep cycling through them to see if any match. To have it go to listening mode if it doesn’t find anything would be rather impractical. What if my wifi drops out for a minute, then my device will be stuck in listening mode while it could have recovered.
What can be done is loading up your firmware, after which you erase the credentials. This way, the device will automatically go to listening mode, and will stay there until it gets valid credentials.
I could be mistaken, but I don’t believe you have to have claimed the device in order to be able to change the credentials. The Spark app uses the TI software to configure the credentials, after which it can link it to your account. Seeing as you could also use the TI stand-alone app, there shouldn’t be a reason why you’d need to have claimed the device beforehand. There’s even a Java SDK if I’m not mistaken, so you can configure it with a computer/laptop which has a wireless connection.
On the Apple AppStore it’s listed under TI WiFi SMARTCONFIG. Not sure about android, but Google should able to help you out.
It’s included in the Spark app, so if you can use that, there’s no need to download TI’s.
I’m not sure where I said that, but I’ll take your word for it…
The Photon and Core use different technologies, so make sure you don’t mix them up. The Core kinda “throws” credentials through the ether where they can be picked up, whereas you make a connection with the photon. How they work exactly, I don’t really know.
I think this thread might contain some useful information in regard to the softAP setup process, and what possibilities there are/might be:
I’ve been trying to figure out a way to ship out the product to customer, but having the customer configure the device wifi credentials using spark app is a significant hurdle, as this would be confusing for most of my customer base (elderly).
I was going through the other startups using spark products for the customer configuration best practice however none of their online literature indicate how customers should configure their products, probably because most are still in beta or haven’t launched yet.
The challenge here is how the customer can input and maintain the user name and password through my app ? any clue on how to do that, or the current best practice for customer side configuration ?
In the docs, there’s a section for product creators, which should deal with this in some way. There are the mobile SDK’s, which you can use to embed the setup process in your own apps. Alternatively, you could go with a browser based setup. It all depends a bit on what you prefer, or your customers.
I see this thread is a bit old and that most of it deals with the Spark Core. I wonder if, since then, an endorsed solution has been provided where end users can set their WiFi credentials in a pre-claimed device without having to log in to the Spark account used to claim the device.
All I need is an Android Particle app that would allow me to set the wifi credentials of a device without having to log in or sign up to anything. It does not need to be branded under my company name. It could be a generic app. Unfortunately I am not versed enough to write my own Android app so I am hoping a solution already exists.