How to reject or accept an incoming call to my GSM modem using AT commands in Python?

Abraham

I've wrote the below Python program to wait for incoming calls and accept or reject them. Based on this document and this document, the appropriate AT commands to accept an incoming call is ATA or ATS0 or ATS0<n>. And also the appropriate commands to reject the incoming call is ATH or AT H.

I tried all the above commands, but the incoming call neither answered nor rejected!

My Python 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'AT H') # I replaced this 'AT H' with all the above
                                 # commands, but nothing changed about the
                                 # incoming call. It always ringing.
            time.sleep(2)

finally:
    phone.close()

Results for AT H:

>>> ================================ RESTART ================================
>>> 
b''
b''
b'\r\n'
b'RING\r\n'
b'AT H\r\n'
b'RING\r\n'
b'AT H\r\n'
b'RING\r\n'
b'AT H\r\n'
b'RING\r\n'
b'AT H\r\n'
b'RING\r\n'

Results for ATH:

>>> ================================ RESTART ================================
>>> 
b''
b''
b''
b'\r\n'
b'RING\r\n'
b'ATH\r\n'
b'RING\r\n'
b'ATH\r\n'
b'RING\r\n'
b'ATH\r\n'
b'RING\r\n'

Results for ATA:

>>> ================================ RESTART ================================
>>> 
b''
b''
b''
b'\r\n'
b'RING\r\n'
b'ATA\r\n'
b'RING\r\n'
b'ATA\r\n'
b'RING\r\n'
b'ATA\r\n'
b'RING\r\n'

Results for ATS0:

>>> ================================ RESTART ================================
>>> 
b''
b''
b''
b'\r\n'
b'RING\r\n'
b'ATS0\r\n'
b'RING\r\n'
b'ATS0\r\n'
b'RING\r\n'

As you see above, the GSM modem regardless of the AT command that I send to it, continue to ringing. What's wrong about my program?

Note that my modem is a D-Link DWM-156 and I can send SMS or make a call successfully using it in Python. Thanks in advance.

Iron Fist

Add to the end of each AT command a CR to make it a valid AT command

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to redirect already answered incoming call using pjsip?

分類Dev

How to Intercept incoming call in Mule

分類Dev

Setting my ISP's modem to let me call via my landline when I'm not home, using its internal hidden SIP server

分類Dev

How to answer automatically and programatically an incoming call on android

分類Dev

How to read the number of incoming call on Android Device

分類Dev

How to achieve a "contact" button on incoming call screen

分類Dev

GSM Modem Send Message in UCS2 format error

分類Dev

how to make Asterisk Reject SIP call with code 503

分類Dev

Why SQLITE doesn't accept My INTEGER/TEXT data larger than 8, using Python 3?

分類Dev

How to get incoming call's network(carrier) details in android

分類Dev

Using a mobile hotspot as a modem?

分類Dev

How to get first letter commands using python's cmd?

分類Dev

PopUp while receiving Incoming Call

分類Dev

how get socket port number from an accept call (C UNIX)

分類Dev

Twilio add incoming call to queue and call to the agent

分類Dev

How to accept `choices` in Python argparse irrespective of case?

分類Dev

How to call a field in my controller

分類Dev

How to unlock a USB Broadband Modem

分類Dev

How to Ditch CenturyLink Fiber "Modem"

分類Dev

How can I get the caller from an incoming phone call webhook request?

分類Dev

MySQL - how to show some field in select query that accept my condition

分類Dev

Using Python 3 on a Raspberry Pi, how to call MPlayer and passing a URL

分類Dev

How to Keep a Single Instance of class in PHP(Laravel 5) for all the incoming connections to my site?

分類Dev

How can I configure a backup Internet connection to work instantly ? I have an adsl connection as my primary connection and a usb modem?

分類Dev

Get incoming call number programmatically on android 10

分類Dev

Intercept incoming call in a rooted Android (Jelly Bean)

分類Dev

Get event for incoming call when application in background

分類Dev

Windows 8.1 detect incoming phone call

分類Dev

CMake - how to call installation commands from the top level AFTER these commands from subdirectories?

Related 関連記事

  1. 1

    How to redirect already answered incoming call using pjsip?

  2. 2

    How to Intercept incoming call in Mule

  3. 3

    Setting my ISP's modem to let me call via my landline when I'm not home, using its internal hidden SIP server

  4. 4

    How to answer automatically and programatically an incoming call on android

  5. 5

    How to read the number of incoming call on Android Device

  6. 6

    How to achieve a "contact" button on incoming call screen

  7. 7

    GSM Modem Send Message in UCS2 format error

  8. 8

    how to make Asterisk Reject SIP call with code 503

  9. 9

    Why SQLITE doesn't accept My INTEGER/TEXT data larger than 8, using Python 3?

  10. 10

    How to get incoming call's network(carrier) details in android

  11. 11

    Using a mobile hotspot as a modem?

  12. 12

    How to get first letter commands using python's cmd?

  13. 13

    PopUp while receiving Incoming Call

  14. 14

    how get socket port number from an accept call (C UNIX)

  15. 15

    Twilio add incoming call to queue and call to the agent

  16. 16

    How to accept `choices` in Python argparse irrespective of case?

  17. 17

    How to call a field in my controller

  18. 18

    How to unlock a USB Broadband Modem

  19. 19

    How to Ditch CenturyLink Fiber "Modem"

  20. 20

    How can I get the caller from an incoming phone call webhook request?

  21. 21

    MySQL - how to show some field in select query that accept my condition

  22. 22

    Using Python 3 on a Raspberry Pi, how to call MPlayer and passing a URL

  23. 23

    How to Keep a Single Instance of class in PHP(Laravel 5) for all the incoming connections to my site?

  24. 24

    How can I configure a backup Internet connection to work instantly ? I have an adsl connection as my primary connection and a usb modem?

  25. 25

    Get incoming call number programmatically on android 10

  26. 26

    Intercept incoming call in a rooted Android (Jelly Bean)

  27. 27

    Get event for incoming call when application in background

  28. 28

    Windows 8.1 detect incoming phone call

  29. 29

    CMake - how to call installation commands from the top level AFTER these commands from subdirectories?

ホットタグ

アーカイブ