Modifying file
This commit is contained in:
parent
5fb88692ca
commit
e71d1500b1
1 changed files with 8 additions and 8 deletions
16
sim800l.py
16
sim800l.py
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
import os,time,sys
|
import os,time,sys
|
||||||
import serial
|
import serial
|
||||||
|
|
||||||
|
@ -14,9 +13,9 @@ def convert_to_string(buf):
|
||||||
return bytes(tmp).decode('utf-8').strip()
|
return bytes(tmp).decode('utf-8').strip()
|
||||||
|
|
||||||
class SIM800L:
|
class SIM800L:
|
||||||
def __init__(self,ser):
|
def __init__(self,ser="/dev/serial0"):
|
||||||
try:
|
try:
|
||||||
self.ser=serial.Serial("/dev/serial0", baudrate=9600, timeout=1)
|
self.ser=serial.Serial(ser, baudrate=9600, timeout=1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.exit("Error: {}".format(e))
|
sys.exit("Error: {}".format(e))
|
||||||
self.incoming_action = None
|
self.incoming_action = None
|
||||||
|
@ -28,11 +27,12 @@ class SIM800L:
|
||||||
self.savbuf = None
|
self.savbuf = None
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.command('ATE0\n') # command echo off
|
self.command('ATE0\n') # command echo off
|
||||||
self.command('AT+CLIP=1\n') # caller line identification
|
self.command('AT+CLIP=1\n') # caller line identification
|
||||||
self.command('AT+CMGF=1\n') # plain text SMS
|
self.command('AT+CMGF=1\n') # plain text SMS
|
||||||
self.command('AT+CLTS=1\n') # enable get local timestamp mode
|
self.command('AT+CLTS=1\n') # enable get local timestamp mode
|
||||||
self.command('AT+CSCLK=0\n') # disable automatic sleep
|
self.command('AT+CSCLK=0\n') # disable automatic sleep
|
||||||
|
self.command('AT+CNMI=2,1,0,0,0\n') # allow new SMS notification as +CMTI: "SM",<index> where <index> is location of SMS
|
||||||
|
|
||||||
def callback_incoming(self,action):
|
def callback_incoming(self,action):
|
||||||
self.incoming_action = action
|
self.incoming_action = action
|
||||||
|
|
Loading…
Reference in a new issue