EasyManuals Logo
Home>Digi>Server>Connect EZ Mini

Digi Connect EZ Mini User Manual

Digi Connect EZ Mini
774 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #473 background imageLoading...
Page #473 background image
Applications Develop Python applications
Digi Connect EZ Mini User Guide
473
def sms_test_callback(sms, info):
print(f"SMS message from {info['content.number']} received")
print(sms)
print(info)
COND.acquire()
COND.notify()
COND.release()
def send_sms(destination, msg):
print("sending SMS message", msg)
if len(destination) == 10:
destination = "+1" + destination
send(destination, msg)
if __name__ == '__main__':
if len(sys.argv) > 1:
dest = sys.argv[1]
else:
dest = '+15005550006'
my_callback = Callback(sms_test_callback, metadata=True)
send_sms(dest, 'Hello World!')
print("Please send an SMS message now.")
print("Execution halted until a message is received or 60 seconds have
passed.")
# acquire the semaphore and wait until a callback occurs
COND.acquire()
try:
COND.wait(60.0)
except Exception as err:
print("exception occured while waiting")
print(err)
COND.release()
my_callback.unregister_callback()
Example script using digidevice.sms to send CLI commands
The following example script listens for an incoming SMS message from a specific phone number
(2223334444) and then executes the SMS message as a CLI command. If the CLI command being run
has output, it will send that output as a response SMS message. If the CLI command being run has no
output but ran successfully, the script will instead send an OK response SMS message. Errors in
running the CLI will have those error messages sent as a SMS response.
#!/usr/bin/python
# Take an incoming SMS message from a specified phone number and run it as
# a CLI command. Send a reponse SMS to the sender before running the command
import os
import threading
import sys
from digidevice import cli
from digidevice.sms import Callback, send
COND = threading.Condition()
allowed_incoming_phone_number = '2223334444'
def sms_test_callback(sms, info):
if info['content.number'] == allowed_incoming_phone_number:
print(f"SMS message from {info['content.number']} received")

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Digi Connect EZ Mini and is the answer not in the manual?

Digi Connect EZ Mini Specifications

General IconGeneral
BrandDigi
ModelConnect EZ Mini
CategoryServer
LanguageEnglish

Related product manuals