Modifying file

This commit is contained in:
chabisik 2022-12-12 17:06:54 +01:00
parent 5fb88692ca
commit e71d1500b1

View file

@ -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
@ -33,6 +32,7 @@ class SIM800L:
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