commit
9010b5b282
|
@ -29,6 +29,7 @@ callbacks = []
|
||||||
# Globals for remembering callback data
|
# Globals for remembering callback data
|
||||||
clip = ""
|
clip = ""
|
||||||
btpairing = ''
|
btpairing = ''
|
||||||
|
holdoffirq=False
|
||||||
|
|
||||||
# Check if the SIM800 is powered up
|
# Check if the SIM800 is powered up
|
||||||
def ison():
|
def ison():
|
||||||
|
@ -119,6 +120,9 @@ def processbuffer():
|
||||||
# The same interface as and called by command() but without power so can be called from power()
|
# The same interface as and called by command() but without power so can be called from power()
|
||||||
def command_internal(command="AT", response_timeout=default_response_timeout, required_response=None, custom_endofdata=None):
|
def command_internal(command="AT", response_timeout=default_response_timeout, required_response=None, custom_endofdata=None):
|
||||||
global dirtybuffer
|
global dirtybuffer
|
||||||
|
global holdoffirq
|
||||||
|
# Don't let the interupt process the buffer mid command
|
||||||
|
holdoffirq = True
|
||||||
# Process anything remaining in the buffer
|
# Process anything remaining in the buffer
|
||||||
processbuffer()
|
processbuffer()
|
||||||
# Send the command
|
# Send the command
|
||||||
|
@ -142,12 +146,14 @@ def command_internal(command="AT", response_timeout=default_response_timeout, re
|
||||||
customcomplete = True
|
customcomplete = True
|
||||||
# Check if we are done
|
# Check if we are done
|
||||||
if complete and customcomplete:
|
if complete and customcomplete:
|
||||||
|
holdoffirq = False
|
||||||
return result
|
return result
|
||||||
# We ran out of time
|
# We ran out of time
|
||||||
# set the dirty buffer flag is an out of date end of responcs cound end up in the buffer
|
# set the dirty buffer flag is an out of date end of responcs cound end up in the buffer
|
||||||
if required_response is None:
|
if required_response is None:
|
||||||
dirtybuffer = True
|
dirtybuffer = True
|
||||||
result.append("TIMEOUT")
|
result.append("TIMEOUT")
|
||||||
|
holdoffirq = False
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# Send the command to set the default configuration to the SIM800
|
# Send the command to set the default configuration to the SIM800
|
||||||
|
@ -174,7 +180,7 @@ def power(onoroff, asyncro):
|
||||||
if not asyncro and pwr_key_pin.value():
|
if not asyncro and pwr_key_pin.value():
|
||||||
pwr_key_pin.off()
|
pwr_key_pin.off()
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
# Press the virtual power key if we are off
|
# Press the virtual power key if we are off
|
||||||
if not (ison()==onoroff):
|
if not (ison()==onoroff):
|
||||||
pwr_key_pin.on()
|
pwr_key_pin.on()
|
||||||
if not asyncro:
|
if not asyncro:
|
||||||
|
@ -217,7 +223,8 @@ def netlightscheduled_internal(pinstate):
|
||||||
if pwr_key_pin.value() and ison():
|
if pwr_key_pin.value() and ison():
|
||||||
poweron()
|
poweron()
|
||||||
# Check for incomming commands
|
# Check for incomming commands
|
||||||
processbuffer()
|
if holdoffirq==False:
|
||||||
|
processbuffer()
|
||||||
|
|
||||||
# Netlight IRQ (called for polling uart)
|
# Netlight IRQ (called for polling uart)
|
||||||
def netlightirq_internal(pinstate):
|
def netlightirq_internal(pinstate):
|
||||||
|
@ -669,6 +676,8 @@ def btsppwrite(connection, data):
|
||||||
# Receive data from a Bluetooth serial connection
|
# Receive data from a Bluetooth serial connection
|
||||||
def btsppread(connection):
|
def btsppread(connection):
|
||||||
command()
|
command()
|
||||||
|
# Don't let the interupt process the buffer mid command
|
||||||
|
holdoffirq = True
|
||||||
request = "AT+BTSPPGET=3," + str(connection) + "\n"
|
request = "AT+BTSPPGET=3," + str(connection) + "\n"
|
||||||
uart.write(request)
|
uart.write(request)
|
||||||
data = uart.read()
|
data = uart.read()
|
||||||
|
@ -677,6 +686,7 @@ def btsppread(connection):
|
||||||
if uart.any()==0:
|
if uart.any()==0:
|
||||||
break
|
break
|
||||||
data += uart.read()
|
data += uart.read()
|
||||||
|
holdoffirq = False
|
||||||
if not data.endswith("ERROR\r\n"):
|
if not data.endswith("ERROR\r\n"):
|
||||||
return data[len(request)+2:-6]
|
return data[len(request)+2:-6]
|
||||||
else:
|
else:
|
||||||
|
@ -770,6 +780,8 @@ def fscreate(filename):
|
||||||
def fsreadpart(filename, size=256, start=0):
|
def fsreadpart(filename, size=256, start=0):
|
||||||
mode=int(start>0)
|
mode=int(start>0)
|
||||||
command()
|
command()
|
||||||
|
# Don't let the interupt process the buffer mid command
|
||||||
|
holdoffirq = True
|
||||||
request = "AT+FSREAD=" + str(filename) + "," + str(mode) + "," + str(size) + "," + str(start) + "\n"
|
request = "AT+FSREAD=" + str(filename) + "," + str(mode) + "," + str(size) + "," + str(start) + "\n"
|
||||||
uart.write(request)
|
uart.write(request)
|
||||||
data = uart.read()
|
data = uart.read()
|
||||||
|
@ -778,6 +790,7 @@ def fsreadpart(filename, size=256, start=0):
|
||||||
if uart.any()==0:
|
if uart.any()==0:
|
||||||
break
|
break
|
||||||
data += uart.read()
|
data += uart.read()
|
||||||
|
holdoffirq = False
|
||||||
if not data.endswith("ERROR\r\n"):
|
if not data.endswith("ERROR\r\n"):
|
||||||
return data[len(request)+2:-6]
|
return data[len(request)+2:-6]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
"""Load the SIM800 library at start so it starts in the background while turning on
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sim800
|
|
@ -0,0 +1,21 @@
|
||||||
|
"""Phone app for baic calling functions
|
||||||
|
"""
|
||||||
|
___name___ = "Phone"
|
||||||
|
___license___ = "MIT"
|
||||||
|
___dependencies___ = ["app", "dialogs", "sim800", "ugfx_helper"]
|
||||||
|
___categories___ = ["System"]
|
||||||
|
___bootstrapped___ = True
|
||||||
|
|
||||||
|
from app import *
|
||||||
|
from dialogs import *
|
||||||
|
import ugfx
|
||||||
|
import ugfx_helper
|
||||||
|
import sim800
|
||||||
|
|
||||||
|
ugfx_helper.init()
|
||||||
|
ugfx.clear()
|
||||||
|
|
||||||
|
notocall = prompt_text("Number to call:")
|
||||||
|
|
||||||
|
if (notocall):
|
||||||
|
sim800.call(notocall)
|
|
@ -0,0 +1,31 @@
|
||||||
|
"""SMS app for reading and sending messages
|
||||||
|
"""
|
||||||
|
___name___ = "Phone"
|
||||||
|
___license___ = "MIT"
|
||||||
|
___dependencies___ = ["app", "dialogs", "sim800", "ugfx_helper"]
|
||||||
|
___categories___ = ["System"]
|
||||||
|
___bootstrapped___ = True
|
||||||
|
|
||||||
|
from app import *
|
||||||
|
from dialogs import *
|
||||||
|
import ugfx
|
||||||
|
import ugfx_helper
|
||||||
|
import sim800
|
||||||
|
|
||||||
|
ugfx_helper.init()
|
||||||
|
ugfx.clear()
|
||||||
|
|
||||||
|
menuset = []
|
||||||
|
messages = sim800.listsms(4)
|
||||||
|
|
||||||
|
for message in messages:
|
||||||
|
splitmessage = message.split(",")
|
||||||
|
menuset.insert(0, { "title" : splitmessage[5] + " " + splitmessage[4] + " from " + splitmessage[2], "index" : splitmessage[0] })
|
||||||
|
|
||||||
|
while True:
|
||||||
|
selection = prompt_option(menuset, text="Select message", select_text="Read", none_text="Exit")
|
||||||
|
if (selection):
|
||||||
|
message = sim800.readsms(selection["index"])
|
||||||
|
notice(message, title=selection["title"])
|
||||||
|
else:
|
||||||
|
break
|
Loading…
Reference in New Issue