master
Your Name 1 year ago
parent 9198d070b2
commit 203ca08eb4

@ -4,7 +4,7 @@ import os
import time
import subprocess
import random
#logging.getLogger().setLevel(5)
logging.getLogger().setLevel(5)
sim800l = SIM800L(port='/dev/serial0', baudrate=115000, timeout=3.0)
audios = ["love1.wav", "love2.wav", "love3.wav"]
@ -17,9 +17,8 @@ time.sleep(3)
while True:
activecall = sim800l.command("AT+CPAS\n") #check if someone is calling or not
if "+CPAS: 3" in activecall: #if someone is calling
print("some one is calling")
time.sleep(3) #wait 3 seoncds
if "3" in activecall: #if someone is calling
print("some one is calling")
sim800l.command("ATA\n") #answer the phone
audio = random.choice(audios)
print("playing python file")
@ -29,5 +28,5 @@ while True:
callisactive = sim800l.command("AT+CPAS\n")
if "+CPAS: 0" in callisactive: #call is not active anymore
print ("call stopped")
os.system("killall play")
os.system("sudo killall play")
break

@ -2,7 +2,7 @@ from sim800l import SIM800L
import logging
import os
import time
import subprocess
#import subprocess
#logging.getLogger().setLevel(5)
sim800l = SIM800L(port='/dev/serial0', baudrate=115000, timeout=3.0)
@ -20,15 +20,15 @@ while True:
time.sleep(3) #wait 3 seoncds
sim800l.command("ATA\n") #answer the phone
print("playing python file")
# os.system("play test.wav &")
p = subprocess.Popen([sys.executable, 'audio.py'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
os.system("play test.wav &")
#p = subprocess.Popen([sys.executable, 'audio.py'],
#stdout=subprocess.PIPE,
#stderr=subprocess.STDOUT)
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")
# os.system("killall play")
p.terminate()
os.system("killall play")
#p.terminate()
break

@ -0,0 +1,53 @@
from sim800l import SIM800L
import logging
import os
import time
logging.getLogger().setLevel(5)
play = False
call = False
audios = ["love1.wav", "love2.wav", "love3.wav"]
sim800l = SIM800L(port='/dev/serial0', baudrate=115000, timeout=3.0)
print(sim800l.command("ATS0=0\n"))
time.sleep(2)
print(sim800l.command("AT\n"))
time.sleep(5)
#print(sim800l.command("AT+DDET=1\n"))
#time.sleep(3)
#print("<>")
time.sleep(3)
while True:
if call is False:
try:
activecall = sim800l.command("AT+CPAS\n", waitfor=1500) #check if someone is calling or not
except:
activecall = ""
print(activecall)
r = sim800l.check_incoming()
print(r)
if r[-1] is not None and "3" in r[-1] and call is False: #if someone is callin
print("some one is calling")
call = True
time.sleep(1) #wait 3 seoncds
sim800l.command("ATA\n") #answer the phone
if play is False:
print("playing sound file")
import random
audio = random.choice(audios)
os.system("play " + audio + " &")
play = True
#check =sim800l.command("AT+DDET=?\n")
#print(check)
while True:
#check if call is still active
callisactive = sim800l.command("AT+CPAS\n")
r = sim800l.check_incoming()
print(r)
if r[-1] is not None:
if "0" in r[-1]: #call is not active anymore
print ("call stopped")
os.system("sudo killall play")
call = False
play = False
break
Loading…
Cancel
Save