Adding files
This commit is contained in:
parent
79d9672f00
commit
d3fb04dc71
6 changed files with 117 additions and 0 deletions
20
argg.py
Normal file
20
argg.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import argparse
|
||||||
|
import serial
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
argparser = argparse.ArgumentParser(description="Providing AT commands from command line parameters")
|
||||||
|
argparser.add_argument("--command", type=str, default="AT", help="command to be execute into SIM800L module")
|
||||||
|
|
||||||
|
command = argparser.parse_args().command
|
||||||
|
|
||||||
|
|
||||||
|
port = serial.Serial("/dev/serial0", baudrate=9600, timeout=1)
|
||||||
|
port.flush()
|
||||||
|
|
||||||
|
port.write(bytes(command+'\n','utf8'))
|
||||||
|
|
||||||
|
rcv = port.read(150)
|
||||||
|
|
||||||
|
print("received", rcv)
|
||||||
|
time.sleep(1)
|
46
gsminit.py
Normal file
46
gsminit.py
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
import serial
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import requests
|
||||||
|
|
||||||
|
port = serial.Serial("/dev/serial0", baudrate=9600, timeout=1)
|
||||||
|
port.flush()
|
||||||
|
|
||||||
|
data=""
|
||||||
|
print("Finding module")
|
||||||
|
while 1:
|
||||||
|
data="";port.flush()
|
||||||
|
port.write(b'AT\n')
|
||||||
|
data=port.read(150)
|
||||||
|
print("received",data)
|
||||||
|
r=data.find(b'OK')
|
||||||
|
if r>=0: print("AT...good...");break
|
||||||
|
time.sleep(0.75)
|
||||||
|
|
||||||
|
while 1:
|
||||||
|
data="";port.flush()
|
||||||
|
port.write(b'AT+CLIP=1\n')
|
||||||
|
data=port.read(150)
|
||||||
|
print("received",data)
|
||||||
|
r=data.find(b'OK')
|
||||||
|
if r>=0: print("CLIP...good");break
|
||||||
|
time.sleep(0.75)
|
||||||
|
|
||||||
|
print("Finding network")
|
||||||
|
while 1:
|
||||||
|
data="";port.flush()
|
||||||
|
port.write(b'AT+CPIN?\n')
|
||||||
|
data=port.read(150)
|
||||||
|
print("received",data)
|
||||||
|
r=data.find(b'READY')
|
||||||
|
if r>=0: print("READY...good");break
|
||||||
|
time.sleep(0.75)
|
||||||
|
|
||||||
|
while 1:
|
||||||
|
rcv = port.read(150)
|
||||||
|
if b"SM" in rcv:
|
||||||
|
port.write(b'AT+CMGF=1\n')
|
||||||
|
msg = port.write(b'AT+CMGR=1\n')
|
||||||
|
if b'please' in msg: print("got it !!!");port.write(b'AT+CMGDA=DEL ALL\n')#requests.get("http://192.168.0.103:/open"); port.write(b'AT+CMGDA=DEL ALL\n')
|
||||||
|
#print("received", rcv)
|
||||||
|
time.sleep(0.5)
|
24
manage_gpio.py
Normal file
24
manage_gpio.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
from RPi import GPIO
|
||||||
|
import time
|
||||||
|
|
||||||
|
GPIO.setmode(GPIO.BOARD)
|
||||||
|
GPIO.setup(38, GPIO.OUT, initial=GPIO.LOW)
|
||||||
|
GPIO.setup(40, GPIO.OUT, initial=GPIO.LOW)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
GPIO.output(38, GPIO.LOW)
|
||||||
|
time.sleep(0.3)
|
||||||
|
GPIO.output(40, GPIO.HIGH)
|
||||||
|
time.sleep(0.3)
|
||||||
|
GPIO.output(40, GPIO.LOW)
|
||||||
|
time.sleep(0.3)
|
||||||
|
for _ in range(150):
|
||||||
|
GPIO.output(38, GPIO.HIGH)
|
||||||
|
time.sleep(0.002)
|
||||||
|
GPIO.output(38, GPIO.LOW)
|
||||||
|
time.sleep(0.2)
|
||||||
|
time.sleep(5)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
GPIO.cleanup()
|
1
rootmystarter.sh
Normal file
1
rootmystarter.sh
Normal file
|
@ -0,0 +1 @@
|
||||||
|
sudo python3 /home/pi/script.py
|
11
servertest.py
Normal file
11
servertest.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import flask
|
||||||
|
|
||||||
|
app = flask.Flask(__name__)
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def index():
|
||||||
|
return "Okay, it's working guy"
|
||||||
|
|
||||||
|
if __name__=="__main__":
|
||||||
|
app.run(host="0.0.0.0")
|
||||||
|
|
15
sim800ltest.py
Normal file
15
sim800ltest.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import serial
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
#import RPi.GPIO as GPIO
|
||||||
|
|
||||||
|
#GPIO.setmode(GPIO.BOARD)
|
||||||
|
port = serial.Serial("/dev/serial0", baudrate=9600, timeout=1)
|
||||||
|
port.flush()
|
||||||
|
|
||||||
|
port.write(b'AT\r')
|
||||||
|
|
||||||
|
rcv = port.read(100)
|
||||||
|
|
||||||
|
print("received", rcv)
|
||||||
|
time.sleep(1)
|
Loading…
Reference in a new issue