From e71d1500b1e346c81171993ac67288bf374d3471 Mon Sep 17 00:00:00 2001 From: chabisik Date: Mon, 12 Dec 2022 17:06:54 +0100 Subject: [PATCH] Modifying file --- sim800l.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sim800l.py b/sim800l.py index 93f4559..6bdac9a 100644 --- a/sim800l.py +++ b/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", where is location of SMS def callback_incoming(self,action): self.incoming_action = action