Please let this be one of those times where I am missing something obvious. First things first, here’s my code:
Node:
var Particle = require('particle-api-js');
var particle = new Particle();
var token = '###abc'; //verified
var deviceId = '###'; //verified
var fnPr = particle.callFunction({ deviceId: deviceId, name: 'myfunction', argument: 'myData', auth: token });
fnPr.then(
function(data) {
console.log('Function called succesfully:', data);
}, function(err) {
console.log('An error occurred:', err);
});
Particle:
void setup() {
Particle.function("myfunction",myFunction);
}
void loop() {}
int myFunction(String command) {
if (command == NULL) {
return 1;
}
}
When running the node script, I get the following back:
Function called succesfully: { body:
{ id: '##########',
last_app: '',
connected: true,
return_value: 1 },
statusCode: 200 }
Just to make sure I wasn’t crazy I also flashed my particle with this:
void setup() {
Particle.function("myfunction",myFunction);
}
void loop() {}
int myFunction(String command) {
return 123;
}
And sure enough, got this back:
Function called succesfully: { body:
{ id: '###########',
last_app: '',
connected: true,
return_value: 123 },
statusCode: 200 }
Any idea on what in the heck is going on?