# Event Reporting and SMS sample

**URL:** <https://forum.sierrawireless.com/t/event-reporting-and-sms-sample/6872>\
**Category:** ALEOS Application Framework\
**Created:** [November 21, 2013, 3:28pm UTC](https://forum.sierrawireless.com/t/event-reporting-and-sms-sample/6872 "2013-11-21T15:28:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmp](https://avatars.discourse-cdn.com/v4/letter/n/ee7513/32.png) [@nmp](https://forum.sierrawireless.com/u/nmp)\
**Post date:** [November 21, 2013, 3:28pm UTC](https://forum.sierrawireless.com/t/event-reporting-and-sms-sample/6872/1 "2013-11-21T15:28:11Z")

</div>

Below sample allows to monitor the state of Digital input 1, and upon state change, send a SMS to predefined phone number.

* * *

* * *

local sms = require ‘sms’  
local sched = require “sched”  
local os = require “os”  
local devicetree = require ‘devicetree’  
– add the wished phone number below, international format, removing leading 0  
local send\_sms\_to = ‘00336xxxxxxxx’  
local in1 = ‘system.aleos.io.in1’

* * *

– function called upon IO state change  
function when\_dig\_input\_changes (din\_data)  
print("Digital input 1 state changed to: ", din\_data[in1])  
local sendmsg = 'ATM ID: 77123 | Location: Dubai Mall | Alert: Digital input 1 state changed to: ’ … din\_data[in1]  
print(‘Sending SMS message [’, sendmsg, '] to ', send\_sms\_to)  
assert(sms.send(send\_sms\_to, sendmsg, ‘7bits’))  
end

* * *

function main ()  
print(“Starting EventReporting sample app”)  
assert(sms.init())  
assert(devicetree.init())

– Be notified, through a callback, every time a given variable changes.  
– This is done through method:  
– “devicetree.register (list\_of\_variables, callback, passive\_vars)”  
assert(devicetree.register(in1, when\_dig\_input\_changes))  
end

sched.run(main)  
sched.loop()
