Skip to content

Instantly share code, notes, and snippets.

@syed
Created September 13, 2012 02:49
Show Gist options
  • Save syed/3711525 to your computer and use it in GitHub Desktop.
Save syed/3711525 to your computer and use it in GitHub Desktop.
This is a simple on[x] script that I wrote to remind my friend to bring tent, sleeping bag and anti leech powder for our trek
// Initializing variables
var message = "Tent + Sleeping bag le kar aana aur agar aapke paas " +
"anti leech hai woh jo powder etc woh be le kar aana";
var contact = { name : "Dhiraj",phoneNumber : "+91123456789" } ;
var msg_time = new Date(2012,8,12,8,0,0,0); // Date(year, month, day, hours, minutes, seconds, milliseconds);
var msg_time_ms = msg_time.getTime();
// End of variables initializing
console.log('Started script: Text a message ' + ' at ' + msg_time);
function sendTextMessage(){
device.messaging.sendSms({
to: contact.phoneNumber,
body: message
},
function (err) {
if (err) {
console.error('Error sending text message: ' + JSON.stringify(err));
}
}
);
console.log('Sent SMS to ' + contact.phoneNumber );
}
// get the alarm every day at the given hou
device.scheduler.setTimer(
{
name: 'messageTimer',
time: msg_time.getTime(),
repeat: false,
exact: true
},
sendTextMessage);
console.log('Completed script: Text a message to y friends every ' + msg_time);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment