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

2

21

I wrote the below Python program to communicate with my D-Link DWM-156 GSM modem. This program wait for incoming calls and as it receive a RING alert, it accepts that call.

Fortunately it works fine ;)

The 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()

Output during running:

>>> ================================ 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 accept it and from that point to the end, we have an active call.

My questions:

1- Is it possible to send/receive some data (SMS for example) during this active call? Or at least can I make a 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 recognisable sound, a noise is enough. Although having a methodology to send recognisable voice is really better.)

2- Why this program detect incoming calls, but doesn't detect incoming SMSs? Look below. You can see output of my program when Jimmy sent 3 SMSs to my GSM modem (And he received "delivered" notification in his my mobile phone for all of them).

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

As you see above, I received nothing, while he sent 3 SMSs! Why?

Divulgence answered 20/6, 2015 at 12:38 Comment(5)
I still don't get it what kind of data you want to send during an Active call?...and you said "noise" is enough...for what purpose?Wirework
The type of data doesn't matter. In the first step I just want to see if it is possible to receive some data during active call or not. When you call to you friend using you mobile phone for example, if you friend suddenly press one of the keys (1,2 .... ) you hear a beep, right? I want to receive this beep! What is the purpose? The purpose is write a program that handles this kind of commands (commands after call.)Did you ever experienced those automatic answers that a woman on the other side says "press 1 for x, press 2 for y" and so on?I almost want to wrote a program like This(Not exactly)Divulgence
@KhalilAmmour-خليلعمور I said I want to send "noise", because : 1- This commands are not really recognisable sounds for us and those are some numbers only. 2- I didn't want to make the problem complicated.Divulgence
Concerning your second question...you need to check your "3.5.3.3.1 +CNMI - New Message Indications To Terminal Equipment " configuration, read it from "sparkfun.com/datasheets/Cellular%20Modules/…"Wirework
sparkfun.com/datasheets/Cellular%20Modules/…Wirework
N
2

Question 1:

I think that what you need are DTMF Tones. DTMF tones are those sounds that you can hear if you're talking with your friend Jimmy and he presses the number buttons. Each button ([0-9],#,*,[A-D],P) has its specific tone.

You can find a good description about how they are composed here.

I just report here that there are two standard commands allowing you to deal with DTMF tones:

  • AT+VTD=<duration> - Setting tones duration
  • AT+VTS=<dtmfSequence> - Sending a sequence of tones

Question 2:

As correctly reported in one comment above, URCs (unsolicited result codes) for incoming Short Messages can be enabled by means of AT+CNMI command, which description can be found here.

Nichy answered 6/11, 2019 at 16:15 Comment(0)
I
0

Most GSM modems will need some initialization so that they signal incoming SMSs. I believe that's what Khalil was refering to. These come as a set of AT commands you should send before entering your loop.

I've done this successfully in the past with a few different GSM modem brands and recall that even though there are some device specific details, the general commands you need to send are the same.

A quick search lead me to:

Maybe you can use them as a starting point.

Individuality answered 5/7, 2015 at 2:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.