Receive an SMS
In previous generations, the digisms Python module was used to receive SMS messages:
- Specify a handler to receive the SMS text message.
- Register a callback by invoking the Callback(handler) function.
Previous API
import digisms
def sms_callback(sms):
print """\
Message from: %s
at: %s
====================
%s
====================
""" % (sms.source_addr, sms.timestamp, sms.message)
# Register the SMS callback
my_callback = digisms.Callback(sms_callback)
# Leave the program executing
input()
my_callback.unregister_callback()
In the new XBee gateways, the digidevice.sms Python module is used to receive SMS messages.:
- Specify a handler to receive the SMS text message.
- Register a callback by invoking the Callback(handler) function.
New API
from digidevice import sms
def sms_callback(sms):
print("\nMessage from: %s" % sms['from'])
print("====================")
print(sms['message'])
print("====================")
# Register the SMS callback
my_callback = sms.Callback(sms_callback)
# Leave the program executing
input()
my_callback.unregister_callback()