-
Notifications
You must be signed in to change notification settings - Fork 2
/
readsms.py
75 lines (55 loc) · 1.87 KB
/
readsms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
##############################################################
# #
# P R O J E K T A V A L O N #
# #
# #
# Script for reading sms and interpreting commands #
# #
# (c) Stefan Wismer - [email protected] #
# #
##############################################################
# Importing generic things
import ddxInterface
# And the Driver Class
import iridium
# Debug level: 0 is nothing, more is more (max: 3)
debug = 1
# Modem Handler
modem = iridium.IridiumModem(debug)
# Global Stuff
msg = 'something that is not null'
if debug > 0:
print "\n"
print "PROJECT AVALON - SMS Receiving Script"
print "=====================================\n\n"
print "SMS Receiving Script is running... Debug Mode is on\n"
# Open Store
if debug > 0:
print "Trying to Open DDX-Store..."
try:
store = ddxInterface.ddxStore()
except:
print "\n\n\nFailed to Connect to the DDX Store. Exiting..."
exit()
else:
if debug > 0:
print "Sucessful.\n"
# Open a serial connection to the modem...
modem.serial_open("/dev/ttyUSB0",2400)
# Reset it
modem.reset()
# Enter PIN - Code
# modem.enter_pin("1111", "1234")
new_sms = modem.get_num_new_sms()
if debug > 0:
print "There are %d new sms!" % new_sms
if new_sms > 0:
max_count = modem.get_newest_sms_count()
if debug > 0:
print "Newest SMS has count %d" % max_count
for i in range(0,new_sms):
text = modem.read_sms(max_count - new_sms + i + 1)
if debug > 0:
print text
# Ending Note... (debug level -1)
print "Script completed. Bye! \n\n"