Hi there. I recently replied to this topic(redacted due to double posting policy), asking for help with writing a website that can configure wifi on a new Particle – but then I realized that topic was in the “General” category. So I’ll ask it here, too…
Has anyone successfully figured out a way to write a website that can allow a customer to configure wifi on their brand new Particle-based product?
I just read all 256 posts to this topic. Most of the action occurred last August or so. The firmware versions on new Photons is 0.4.9. Is there a newer version of @mebrunet’s code to match? Is there something else that people are using now? I’d like to either:
Have my customers connect to the soft AP on their new device and configure wifi.
OR
Have my customers connect to my website and configure wifi.
Either way is fine. I’m just at a loss as to how to start.
I can’t quite look at this right now so my help is limited. The folks over @ Hook (gethook.io) have a working web device setup. Here is their js file: http://www.gethook.io/web/assets/js/softap-browser-min.js Try using it since I know it works and let me know how that goes.
@harrisonhjones – That was it. Thanks! My browserification process must have gone wrong. The link you provided to the softap-browser-min.js at gethook worked perfectly. What I tested was:
get the deviceInfo. This returned the ID and claim flag.
get the publicKey
call configure (I used a router that doesn’t broadcast its SSID so I was hoping it would work. It did)
call connect. It rebooted and quickly went through the process of connecting and was breathing cyan within seconds.
What I did NOT do yet was call setClaimCode. I’m not sure how it works. The docs on github say it requires a claimcode that can be gotten via the Particle API, but I don’t see a function that returns a claimcode. Any idea how the claiming is handled?
For reference, here is my test code:
<!doctype html>
<html lang="en">
<head></head>
<body>
<script src="softap-browser-min.js"></script>
<script>
//var sap = new SoftAPSetup();
var sap = new SoftAPSetup({ "protocol": 'http', "timeout": 2000 });
sap.deviceInfo(callback);
function callback(err, dat) {
if (err) { throw err; }
console.log("Device ID: %s, claimed: %s", dat.id, dat.claimed ? "yes" : "no");
sap.publicKey(callback);
function callback(err, dat) {
if (err) { throw err; }
console.log(dat);
sap.configure({
ssid: "something",
security: "wpa2_mixed",
password: "somethingelse",
channel: "6"
}, callback);
function callback(err, dat) {
console.log("Device is configuring");
sap.connect(callback);
function callback(err, dat) {
console.log("Device is attempting to connect to the AP...");
};
};
};
};
</script>
</body>
</html>
I’m in the same boat when it comes to confusion with claiming process.
Here’s what I do:
Create a customer Implicit
1.1. registration form - submit form to particle endpoint with organization fields specified
1.2. emerge at my https page where I save token from url hash to cookie
Create a claim code - nothing organization specific there that I could find.
2.1 Getting response like {“claim_code”: “REALLY LONG STRING HERE”, “device_ids”: []}
2.2 redirecting to non-https sub-domain with claim code as url parameter
SoftAp using above mentioned softap-browser-min.js
3.1. wait for user to reconnect to WiFi to device
3.2 key/id/scan/configure - all coming back with expected results
3.3 setClaimCode with the code from URL
3.4 connect request and wait for user to reconnect to interwebs (breathing syan)
Claim - no organization related params here
4.1 redirecting back to https domain with id in the url parameters
4.2 call to endpoint without “request_transfer” param get error that parameter is needed even though in dashboard device shows as not associated with any customers, with “request_transfer” param getting 403 forbidden {“ok”:false, “errors”: []}
@dperrigan,
I used the working version of browserified JS file linked here by @harrisonhjones. I’m getting device successfully connected, just not assigned to customer account.
By "it" do you mean network setup alone or including device claiming into customer's account? With Hook's working copy of softap-browser-min.js I succeeded in implementing the network setup, but no such luck with claiming.
I'll keep banging at it, but if anybody has a working sample of the browser based setup process that includes claiming the device into customer's account I'd really appreciate sharing it or describing the steps.