2018-08-28 18:12:57 -04:00
|
|
|
"""SMS app for reading and sending messages
|
|
|
|
"""
|
2018-08-31 12:43:14 -04:00
|
|
|
___name___ = "SMS"
|
2018-08-28 18:12:57 -04:00
|
|
|
___license___ = "MIT"
|
2018-08-28 18:35:45 -04:00
|
|
|
___dependencies___ = ["app", "dialogs", "sim800", "ugfx_helper"]
|
2018-08-28 18:12:57 -04:00
|
|
|
___categories___ = ["System"]
|
|
|
|
___bootstrapped___ = True
|
|
|
|
|
|
|
|
from app import *
|
|
|
|
from dialogs import *
|
2018-08-28 18:35:45 -04:00
|
|
|
import ugfx
|
|
|
|
import ugfx_helper
|
|
|
|
import sim800
|
2018-08-28 18:12:57 -04:00
|
|
|
|
2018-08-30 17:24:55 -04:00
|
|
|
sim800.poweron()
|
|
|
|
|
2018-08-28 18:12:57 -04:00
|
|
|
ugfx_helper.init()
|
|
|
|
ugfx.clear()
|
|
|
|
|
|
|
|
menuset = []
|
|
|
|
messages = sim800.listsms(4)
|
|
|
|
|
2018-08-29 14:58:04 -04:00
|
|
|
def send_message():
|
|
|
|
number = ""
|
|
|
|
message = ""
|
|
|
|
while True:
|
|
|
|
num = prompt_text("Number to message:", init_text=number)
|
|
|
|
if num is None:
|
|
|
|
return
|
|
|
|
message = prompt_text("Message:", init_text=message)
|
|
|
|
if message is not None:
|
|
|
|
if sim800.sendsms(number, message):
|
|
|
|
return
|
|
|
|
|
2018-08-28 18:12:57 -04:00
|
|
|
for message in messages:
|
|
|
|
splitmessage = message.split(",")
|
|
|
|
menuset.insert(0, { "title" : splitmessage[5] + " " + splitmessage[4] + " from " + splitmessage[2], "index" : splitmessage[0] })
|
|
|
|
|
2018-08-29 14:58:04 -04:00
|
|
|
menuset.insert(0, { "title" : "Send message...", "index" : -1 })
|
|
|
|
|
2018-08-28 18:12:57 -04:00
|
|
|
while True:
|
2018-08-29 14:58:04 -04:00
|
|
|
selection = prompt_option(menuset, text="Select message", select_text="Read", none_text="Exit")
|
2018-08-31 12:43:14 -04:00
|
|
|
if (selection):
|
|
|
|
if (selection["index"]==-1):
|
|
|
|
send_message()
|
|
|
|
else:
|
|
|
|
message = sim800.readsms(selection["index"])
|
|
|
|
notice(message, title=selection["title"])
|
2018-08-31 13:18:52 -04:00
|
|
|
if prompt_boolean("Delete this message?", title=selection["title"]):
|
|
|
|
sim800.deletesms(selection["index"])
|
|
|
|
for menuitem in menuset:
|
|
|
|
if menuitem["index"]==selection["index"]:
|
|
|
|
menuset.remove(menuitem)
|
2018-08-29 14:58:04 -04:00
|
|
|
else:
|
|
|
|
break
|
2018-08-31 11:20:30 -04:00
|
|
|
|
|
|
|
restart_to_default()
|