Issues with softAPsetup

We are trying to use softAP-setup-js library for claiming the photon and providing it the wifi credentials. We are using with browserify. We are running into some beginner issues. Any feedback on the below error would be appreciated.

Also, are there still issues with HTTP as indicated on https://github.com/spark/softap-setup-js? I guess not reading other forums on this topic. Hope this can be reflected on the github page.

Below is the code snippet we are trying with ionic/angularjs and the error we are getting.

    //https://github.com/spark/softap-setup-js
    var options = {
        //"host": "192.168.0.1",//10.0.0.1
        "keepAlive": true,
        "timeout": 2000,
        "noDelay": true,
        //"channel": 6,
        "protocol": "http",// "tcp",
        //"port": 80 //5609 (will default to 80 if protocol = http and no port specified)
    };
		//var sap = new SoftAPSetup({});
    var sap = new SoftAPSetup(options);
	
//var sap = new SoftAPSetup({ protocol: 'http', port: 80 });


//if(!config.get('ssid')) {

	//console.log("* Please specify the ssid of the AP with which you wish to connect your device...");
	//console.log("Example: %s %s --ssid BestWiFiNetworkEver --password SuperSecretPassword --security wpa2_mixed", process.argv[0], path.relative(process.cwd(), __filename));
	//process.exit(1);
//}

console.log("Obtaining device information...");

function done(err, dat) {

  alert("done!");
	if(err) { console.log("error!"); throw err; }
	console.log("dat: ", dat);//"err:", err, 
	console.log("Successfully sent connect request. Now wait for breathing cyan!");

}
	
function connect(err, dat) {

  alert("connect!");
	if(err) { console.log("error!"); throw err; }
	console.log("dat: ", dat);//"err:", err, 
	console.log("Configured device. Issuing connect request...");

	sap.connect(done);
}

function configure(err, dat) {

  alert("configure!");
	if(err) { console.log("error!"); throw err; }
	console.log("dat: ", dat);//"err:", err, 
	console.log("-------");
	console.log("Scanned APs. Configuring device...");

	sap.configure({
		ssid: "SANTHOSH",//config.get('ssid')
		security: "wep_psk",//wpa2_mixed//security: config.get('security') || undefined
		password: "9845583071",//password: config.get('password') || undefined
		//channel: config.get('channel') || 11
		//channel: "<CHANNEL>"
	}, connect);

}

function scan(err, dat) {

  alert("scan!");
	if(err) { console.log("error!"); throw err; }
	console.log("dat: ", dat);//"err:", err, 
	console.log("-------");
	console.log("Received public key. Scanning for APs...");
	sap.scan(configure);
}

function key(err, dat) {

  alert("key!");
	if(err) { console.log("error!"); throw err; }
	console.log("dat: ", dat);//"err:", err, 
	console.log("-------");
	console.log("Requesting public key...");
	sap.publicKey(scan);
}

function claim(err, dat) {

  alert("claim!");
	if(err) { console.log("error!"); alert("error!"); throw err; }
	console.log("dat: ", dat);//"err:", err, 
	console.log("-------");
	console.log("Obtained device information. Setting claim code...");
	sap.setClaimCode("wat", key);
}

sap.deviceInfo(claim);

Error:

app-device.js:103 Uncaught Error: Invalid JSON received from device.httpEnd @ softap-browser.js:24667g @ softap-browser.js:18727EventEmitter.emit @ softap-browser.js:18658endReadableNT @ softap-browser.js:20845afterTickTwo @ softap-browser.js:21920Item.run @ softap-browser.js:19067drainQueue @ softap-browser.js:19037
user-app.js:366 resolved myaccount

Thanks!
Priya

1 Like