You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
966 B
Python

from sim800l import SIM800L
import logging
import os
import time
import subprocess
import random
1 year ago
logging.getLogger().setLevel(5)
sim800l = SIM800L(port='/dev/serial0', baudrate=115000, timeout=3.0)
audios = ["love1.wav", "love2.wav", "love3.wav"]
print(sim800l.command("ATS0=0\n"))
time.sleep(2)
print(sim800l.command("AT\n"))
time.sleep(5)
print(sim800l.command("AT+DDET=1"))
time.sleep(3)
while True:
activecall = sim800l.command("AT+CPAS\n") #check if someone is calling or not
1 year ago
if "3" in activecall: #if someone is calling
print("some one is calling")
sim800l.command("ATA\n") #answer the phone
1 year ago
audio = rando`m.choice(audios)
print("playing python file")
os.system("play " + audio + " &")
while True:
#check if call is still active
callisactive = sim800l.command("AT+CPAS\n")
if "+CPAS: 0" in callisactive: #call is not active anymore
print ("call stopped")
1 year ago
os.system("sudo killall play")
break