Any one have any luck connecting Alexa with Particle Argon?
My code apparently works fine on particle photon, but not on Argon? Is this to be expected and something needs to change for it to work on Mesh devices? I am simply exposing a function to the cloud, and the making a POST request on AWS Lambda.
Hey @ParticleD! Thanks for your reply. Yeah i am a little confused as well on what i am missing. Since it seemed to be working fine on particle photon.
This is pretty much the code used in AWS Lambda
var sparkHst = "api.particle.io";
var sparkPath = "/v1/devices/" + deviceid + "/caller";
console.log("[LOG] Path = " + sparkPath);
var args = 'add';
makeParticleRequest(sparkHst, sparkPath, args, accessToken, function(resp) {
var json = JSON.parse(resp);
});
function makeParticleRequest(hname, urlPath, args, accessToken, callback){
// Particle API parameters
var options = {
hostname: hname,
port: 443,
path: urlPath,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': '*.*'
}
}
var postData = "access_token=" + accessToken + "&" + "args=" + args;
console.log("[LOG] Post Data: " + postData);
// Call Particle API
var req = http.request(options, function(res) {
console.log('[LOG] STATUS: ' + res.statusCode);
console.log('[LOG] HEADERS: ' + JSON.stringify(res.headers));
var body = "";
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('[LOG] BODY: ' + chunk);
body += chunk;
console.log('[LOG] BODY: ' + body["error"]);
});
res.on('end', function () {
callback(body);
});
});
req.on('error', function(e) {
console.log('[LOG] problem with request: ' + e.message);
});
// write data to request body
req.write(postData);
req.end();
}
and then i am exposing the function in the particle code.
One thing you definetly want to change is getting rid of the legacy syntax Spark.function() have been called Particle.function() for years now - sooner or later the Spark.xxx() syntax should get deprecated.
Also in your lambda, shouldn’t the definition of makeParticleRequest() be before its first invocation?
Where (when) are deviceid and accessToken defined?
What do you get in your console logs?
Hey @ParticleD, here is the complete code. Not doing anything fancy, just waiting for the slot add, if it comes the servo moves up and down, otherwise stays still.
@ScruffR Yeah i noticed the Particle.Function() as well, tried it as well to check if this made any difference, but got the same result. So went back to my original code.
the deviceid and access token are defined right above var sparkHst = “api.particle.io”;.
Have you double checked the device ID and also made sure you actually deployed your altered lambda, updated your ARN (in case it changed in the process) and rescanned your Alexa devices?
Yeah I know that now, I’d just never come across it before.
@muneebr1 re: Photon vs. Gen3 – it’s a completely different microcontroller so it’s an apple vs. orange thing. For one thing, the clock speed of Gen3 is just over 1/2 that of the Photon.
So i luckily had a particle photon lying around so i tested, and everything worked fine. I also tested another particle Argon and it still dosent work.
At this point i feel like it was a big mistake upgrading to the mesh, i had a high hopes, but most of the libraries arent supported, the hardware itself has issues, and now this.
I was working on a deadline which has been shattered completely, and now i have to redo everything with a different controller.