How to send and receive data via a GSM modem during an active call (Python and AT Command)

I wrote the Python program below to communicate with my D-Link DWM-156 GSM modem . This program waits for incoming calls and when it receives a warning, RING accepts this call.

Fortunately, it works great;)

Program:

import time import serial phone = serial.Serial("COM10", 115200, timeout=5) try: time.sleep(1) while(1): x = phone.readline() print(x) if (x == b'RING\r\n'): phone.write(b'ATA\r') time.sleep(0.5) finally: phone.close() 

Exit during operation:

 >>> ================================ RESTART ================================ >>> b'' b'' b'' b'\r\n' b'RING\r\n' #Here, my friend (named "Jimmy",for example), called me. b'OK\r\n' b'' b'' b'' b'' b'' 

As you see above, immediately after receiving an incoming call, the GSM modem receives it and from this point to the end, we have an active call.

My questions:

1 - Is it possible to send or receive some data (for example, SMS) during this active call? Or, at least, can I make noise on the other side of this channel (i.e., on the speaker of Jimmy's phone) during this active call? (I don’t want to send a recognizable sound, enough noise. Although the methodology for sending a recognizable voice is really better.)

2 - Why does this program detect incoming calls but not detect incoming SMS? See below. You can see the output of my program when Jimmy sent 3 SMS to my GSM modem (and he received a β€œdelivered” notification in his mobile phone for everyone).

 >>> ================================ RESTART ================================ >>> b'' b'' b'' b'' b'' b'' b'' 

As you see above, I received nothing , and he sent 3 SMS! Why?

+7
python gsm pyserial at-command
source share
1 answer

Most GSM modems need some initialization so that they report incoming SMS messages. I believe in what Khalil spoke about. They are part of the set of AT commands that you must send before entering your loop.

In the past, I did this with several different models of GSM modems and I remember that even if there are some details specific to the device, the general commands that you need to send are the same.

A quick search will lead me to:

Perhaps you can use them as a starting point.

0
source share

All Articles