Hello
I m planning to send my device to a few customers. My question:
Is a way to hard-code the wifi name and password settings on my device, so that the customer will be able to run the device in their house once they receive it?
Let’s say we dont want to do method 1 above, Is there a way to set up wifi credentials of my customers network without needing them to login to particle.io?
Extra questions
If the customer needs to login as per Method 2 above, how can I hide the code from him?
Do you know of any good Xamarin examples that implemented setting up wifi?
There would be, but how would that ensure your customer will be able to connect it to his WiFi network? Customers tend to have a different SSID/password as you will have hardcoded and I'd guess they won't like to give you their credentials in order to pre-programm them into the devcice.
There are several ways via a USB connections, but the most appealing way IMHO is the use of the SoftAP setup page.
This way your customer will never see the code anyway, since it's only running on the device, no source code is stored on the device what-so-ever.
I have the same sort of requirement. Before the SoftAP example @ScruffR refers to above the only way I figured I could do this reliably was to have a keyboard input and a small screen to allow a dialogue for the end user to enter credentials (password). A word of warning - this requires some development (keyboard interface - PS/2 because there is not native USB support, display and admin menu, understanding of how to scan for available networks, access and clear the cached network details and how to set credentials (add network)).
I have evaluated the softAP example that is provided in the documents - it works. I am not a HTML/javascript programmer and the javascript is quite dense. My criticisms of the softAP example are that 1. A user has to find a WAP called PHOTON-??? and point their browser to 192.168.0.1 - not very user friendly 2. It shows Device ID to an end user - whereas I would prefer to use a friendly name [Device Name would be nice to use but that needs to be got from the Particle Cloud]. 3. The web app connected message at the end isn’t reliable - often gets stuck on ‘connecting…’ although it has connected the photon. If none of those are an issue then I would definitely recommend you try it out.
Just a little history on why the Photon Wi-Fi network name is like that: If you get a new Photon, under the barcode on the side of the box is a code that ends in something like Q7RA-0. The Wi-Fi network name will be Photon-Q7RA. This is done so if you’re at a hackathon or class or other place where multiple people are setting up their Photons at the same time, you can tell which one is yours!
[quote="ScruffR, post:2, topic:23575"]
Customers tend to have a different SSID/password as you will have hardcoded and I'd guess they won't like to give you their credentials in order to pre-programm them into the devcice.
[/quote]I was thinking in the lines that I would ask the customer what their SSID & Password is, update the code and only then ship it. Viable maybe?
Do you know of any C# examples that used SoftAP setup ?
I thing this must be due to dditional restrictions @armor was faced with.
There are several other options but you know your what you can expect of your customers and what not, so some of these might be viable for you.
e.g. @jvanier has set up a nice installer for CLI that makes installing everything required to set up a device a piece of cake.
Why would you want to do that?
You just connect any WiFi enabled device to your Photon in listening mode and navigate in a browser to 192.168.0.1 (or if you add a mDNS name to that) and follow the instructions.
Is it possible your customers download an “install app” on their phone? If so, you could have the app listen for a UDP broadcast from the Particle device. Once you have a connection, use the app to let the customer type in credentials and such to set up the device. If you plan to have multiple devices at the customer’s location, you will need some means to identify each. The typical way is to have a single button/switch to press during the install or to turn them on in succession.
Is there a programmatic way of knowing the wi-fi network name? It would be more user friendly to say (on a screen as I have) please look for WAP Photon-Q7RA.
Thanks - just being able to set the SSID is a useful piece of information!
I had to go and look at the documentation of the firmware because I was sure I hadn’t seen either System.get or System.set. They are not documented as system calls. I did a search of the community and it picked up one long thread that stretched over a year where at the end @jvanier provided the answer you have given. As an Elite could you recommend a better way to find out about this stuff?
Not really
The problem is Particle + Elites are just a few people with so many open tasks on their slates and limited time, that documenting sometimes gets left behind. But it's a permanent Work In Progress
As @ScruffR mentioned, customers may not want to give you their wifi credentials to add to the photon. I recently developed a wifi enabled touch light for my family. Asking for their wifi credentials so they could plug in their light without setup was a viable solution in my case. You can find the details of how I set wifi credentials via code on my Particle device at my blog, if you choose to go this route.
I appreciate that want to promote your blog, but you really should mention in your post there that folks should be using the four-argument version of WiFi.setCredentials(); as explained in this section of the doc when any of the networks are not “visible” to the Photon when you set the credentials.
// for hidden and offline networks on the Photon, the security cipher is also needed
// Cipher options are WLAN_CIPHER_AES, WLAN_CIPHER_TKIP and WLAN_CIPHER_AES_TKIP
WiFi.setCredentials("SSID", "PASSWORD", WPA2, WLAN_CIPHER_AES));
Thanks for the feedback! I’m not sure that specifying the authentication procedure and security cipher are entirely necessary with the way I did my set up. If someone were to flash their particle device with this code, then the setCredentials function would get called every time the setup function runs, and presumably one of the specified SSIDs would be within view when this happens (not talking about hidden SSIDs here), otherwise we would not be able to connect to any of the wifi devices specified anyways (having a WAP come into view after the setup function has run is another case that is not accounted for).
I ended up updating my examples to to use the four-argument version of setCredentials and would appreciate any feedback. However, there is something to be said about the trade-off between simplicity with the two-argument version vs. the four-argument version.