Quipu
This modules provides SMS and 3G functionnalities in node.js.
From Wikipedia article:
"A quipu usually consisted of colored, spun, and plied thread or strings made from cotton or camelid fiber. For the Inca, the system aided in collecting data and keeping records, ranging from monitoring tax obligations, properly collecting census records, calendrical information, and military organization."
Getting started
After creating a file called myPINcode.js
containing module.exports = xxxx;
your pin code, you can use the library as follows:
var quipu = require("./index.js");
var yourNumber = "336........";
var devices = {
modem: "/dev/ttyUSB0",
sms: "/dev/ttyUSB2"
};
quipu.handle("initialize", devices);
quipu.sendSMS("Hello from quipu.", yourNumber);
quipu.on("smsReceived", function(sms){
console.log(sms);
});
quipu.handle("open3G");
setTimeout(function(){
quipu.handle("close3G");
}, 30000)
quipu.handle("openTunnel", 2222, 9632, "kerrigan");
setTimeout(function(){
quipu.handle("closeTunnel");
}, 30000)
Behind the scene, there is a final state machine (FSM) with the following states:
Compressing messages
160 characters is not a lot and you have useful characters like curly braces that ar not well handeled by sms protocol. So parser.js
provides and encode
and decode
functions that can help you pass json objects through the air:
// to send encoded, as sms don't like curly braces and other stuff
var parser = require("./parser.js")
parser.encode(devices)
.then(function(msg){
quipu.sendSMS(msg, yourNumber);
})
.catch(function(err){
console.log(err);
});
// and to decode use
quipu.on("smsReceived", function(sms){
parser.decode(sms.body)
.then(function(object){
console.log(object);
})
});
References
AT commands:
SMS format:
PPP: