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 serial
|
||||
|
||||
|
@ -14,9 +13,9 @@ def convert_to_string(buf):
|
|||
return bytes(tmp).decode('utf-8').strip()
|
||||
|
||||
class SIM800L:
|
||||
def __init__(self,ser):
|
||||
def __init__(self,ser="/dev/serial0"):
|
||||
try:
|
||||
self.ser=serial.Serial("/dev/serial0", baudrate=9600, timeout=1)
|
||||
self.ser=serial.Serial(ser, baudrate=9600, timeout=1)
|
||||
except Exception as e:
|
||||
sys.exit("Error: {}".format(e))
|
||||
self.incoming_action = None
|
||||
|
@ -28,11 +27,12 @@ class SIM800L:
|
|||
self.savbuf = None
|
||||
|
||||
def setup(self):
|
||||
self.command('ATE0\n') # command echo off
|
||||
self.command('AT+CLIP=1\n') # caller line identification
|
||||
self.command('AT+CMGF=1\n') # plain text SMS
|
||||
self.command('AT+CLTS=1\n') # enable get local timestamp mode
|
||||
self.command('AT+CSCLK=0\n') # disable automatic sleep
|
||||
self.command('ATE0\n') # command echo off
|
||||
self.command('AT+CLIP=1\n') # caller line identification
|
||||
self.command('AT+CMGF=1\n') # plain text SMS
|
||||
self.command('AT+CLTS=1\n') # enable get local timestamp mode
|
||||
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):
|
||||
self.incoming_action = action
|
||||
|
|
Loading…
Reference in a new issue