var sms;
function onInit() {
Bluetooth.setConsole(1);
Serial1.setup(115200, { rx: D1, tx : D2 });
var ATSMS = require("ATSMS");
sms = new ATSMS(Serial1);
sms.init(function(err) {
if (err) throw err;
console.log("Initialised!");
sms.list("ALL", function(err,list) {
if (err) throw err;
if (list.length)
console.log(list);
else
console.log("No Messages");
});
// and to send a message:
//sms.send('+441234567890','Hello world!', callback)
});
sms.on('message', function(msgIndex) {
console.log("Got message #",msgIndex);
sms.get(msgIndex, function(err, msg) {
if (err) throw err;
print("Read message", msg);
var txt = msg.text.toLowerCase();
if (txt=="on") LED1.set();
if (txt=="off") LED1.reset();
// delete all messages to stop us overflowing
sms.delete("ALL");
});
});
}
onInit();
It's a minor tweak but it seems you had sms.on('message' being called while sms was still undefined, and I imagine that would have caused an error.
Using save on send with the code as provided from the 'Control Bluetooth Lights with SMS' tutorial should have worked fine though.
With the PIR, did you ensure that GND was properly shared between all devices? That's usually the biggest cause of this kind of problem - that to send a signal you actually need two wires (GND and signal), not just the signal wire on its own.
And for the 2v00 upgrade, did you try long-pressing the button when you apply power? http://www.espruino.com/Puck.js#resetting-puck-js That would clear out any old saved code that might potentially have caused problems when you upgraded
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi! For SMS, can you try:
It's a minor tweak but it seems you had
sms.on('message'
being called whilesms
was still undefined, and I imagine that would have caused an error.Using
save on send
with the code as provided from the 'Control Bluetooth Lights with SMS' tutorial should have worked fine though.With the PIR, did you ensure that GND was properly shared between all devices? That's usually the biggest cause of this kind of problem - that to send a signal you actually need two wires (GND and signal), not just the signal wire on its own.
And for the 2v00 upgrade, did you try long-pressing the button when you apply power? http://www.espruino.com/Puck.js#resetting-puck-js That would clear out any old saved code that might potentially have caused problems when you upgraded