Currently, I'm working with simcom SIM7600G-H (using AT-command set) to create the voice call to notice user about some specified notifications. I'm able to create voice call and hang up it, but don't know how to play a pre-recorded audio into it. Is there anyway to perform that task. My code to create voice call with simcom is below:
import serial
import time
ser = serial.Serial("COM5", 115200)
ser.flushInput()
phone_number = '09xxxxxxx'
text_message = 'test simcom 7600'
def checkStart():
while True:
ser.write(('AT\r\n').encode())
time.sleep(0.1)
if ser.inWaiting():
time.sleep(0.01)
recBuff = ser.read(ser.inWaiting())
print('try to start\r\n' + recBuff.decode() )
print(recBuff.decode())
if 'OK' in recBuff.decode():
print("ok")
recBuff = ''
return
else:
time.sleep(1)
def sendAt(command,back,timeout):
rec_buff = ''
ser.write((command+'\r\n').encode())
time.sleep(timeout)
if ser.inWaiting():
time.sleep(0.01 )
rec_buff = ser.read(ser.inWaiting())
if back not in rec_buff.decode():
print(command + ' ERROR')
print(command + ' back:\t' + rec_buff.decode())
return 0
else:
print(rec_buff.decode())
return 1
def PhoneCall(phone_number):
sendAt('ATD'+phone_number+';','OK',1)
time.sleep(20)
ser.write('AT+CHUP\r\n'.encode())
print('Call disconnected')
try:
checkStart()
PhoneCall(phone_number)
time.sleep(20)
sendAt("ATH")
except:
print("Unable to connect!")
if ser != None:
ser.close()
I've been busy with the same issue. I've used the QMI interface to enable PCM. I've used ModemManager to add qmi_wwan and enable audio through QMI. When you got that working with ModemManager mmcli -m 0
will show you an audio serial port on probably /dev/ttyUSB4
To enable PCM on the 7600 you should execute AT+CPCMREG=1
. After that you can use a serial connection to stream audio data to the serial port.
I used sox to convert the audio data to the 8k 16 bit format:
sox input.wav -r 8000 -b 16 out.wav
You could use wave to load in the wave file https://docs.python.org/3/library/wave.html
Don't forget to disable xonxoff
rtscts
for serial.
I advise you to use dbus to communicate with 7600