37 lines
912 B
Python
Executable File
37 lines
912 B
Python
Executable File
#!/usr/bin/python
|
|
#
|
|
# GSM-Modul anschalten, falls ein keine Antwort gibt...
|
|
#
|
|
import time
|
|
import RPi.GPIO as GPIO
|
|
import serial
|
|
|
|
def PowerOn():
|
|
# RPi.GPIO Layout verwenden (wie Pin-Nummern)
|
|
GPIO.setmode(GPIO.BOARD)
|
|
|
|
# Pin 11 (GPIO 17) auf Output setzen
|
|
GPIO.setup(11, GPIO.OUT)
|
|
|
|
# Druecken simulieren
|
|
GPIO.output(11, GPIO.HIGH)
|
|
|
|
# Pause, mindestens eine Sekunde gemaess https://www.itead.cc/wiki/RPI_SIM800_GSM/GPRS_ADD-ON_V2.0
|
|
time.sleep(1.5)
|
|
|
|
# Weg vom Taster...
|
|
GPIO.output(11, GPIO.LOW)
|
|
|
|
# Cleanup
|
|
GPIO.cleanup()
|
|
|
|
with serial.Serial('/dev/ttyAMA0', 115200, timeout=2) as ser:
|
|
ser.write(b'AT\n')
|
|
line = ser.readline()
|
|
line = ser.readline()
|
|
print "Feedback: %s" % (line)
|
|
if line.strip() != "OK":
|
|
print "Modem reagiert nicht, evtl. abgeschaltet... wir schalten es ein..."
|
|
PowerOn()
|
|
ser.close() # close port
|