Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add long sms concat info for received sms #93

Open
wants to merge 181 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
525d1ba
Add basic data/GPRS setup commands to modem class
faucamp Jul 23, 2013
af621b4
Commit for branch switch
faucamp Jul 26, 2013
1e64387
deleteStoredSms: tweaked AT com for Siemens MC53
paolo-losi Feb 4, 2014
54ebfd8
increased default timeout for AT response
paolo-losi Feb 17, 2014
31a7849
Merge remote-tracking branch 'boomer74/master'
paolo-losi Feb 18, 2014
9780c85
ReceivedSms.udh
paolo-losi Feb 19, 2014
ff7e755
+CREG parsing fix
paolo-losi Feb 19, 2014
4ce4081
enable sms notif only when callbacks are defined
paolo-losi Feb 22, 2014
44257cf
processStoredSms: more explicit error message
paolo-losi Feb 22, 2014
3468fa3
Patch to make it work with python 3.4
youtux Sep 11, 2014
0076b9d
fix to _decodeAddressField()
paolo-losi Sep 12, 2014
9a34749
SMS txt timeout 15 -> 60 seconds
paolo-losi Sep 18, 2014
def3290
FIX: pack and unpack septets of len zero
paolo-losi Sep 23, 2014
5e31fdf
Add UDH info in ReceivedSms.
yuriykashin Oct 9, 2014
576352c
Fix a mistake.
yuriykashin Oct 9, 2014
81b43ce
Dirty fix for https://github.com/yuriykashin/python-gsmmodem/issues/1
yuriykashin Feb 7, 2015
29ca5f5
Added a function sendSms under the class receivedSms to send message …
Aug 4, 2015
2dbfe1c
Added access function for receivedSms class to use the modem functions.
jeromez80 Aug 4, 2015
811df24
Added getModem, setForwarding
jeromez80 Aug 4, 2015
3a14eb1
Fixed bug on responseTimeout
jeromez80 Aug 4, 2015
c463773
Fixed parameter bug in checkForwarding and setForwarding
jeromez80 Aug 4, 2015
4e3b931
Bug period in setForwarding
jeromez80 Aug 4, 2015
36bc98a
Wrap setForwarding with "
jeromez80 Aug 4, 2015
b38331a
Fixed bug in getModem
jeromez80 Aug 5, 2015
923ab50
Bug in sendSms and getModem functions
jeromez80 Aug 5, 2015
2b66590
Option to disable request for delivery report
epol Jan 2, 2016
9625cb8
added "waittingForModemToStartInSeconds" argument to GsmModem.conect(…
alejandroMA Jan 16, 2016
7f6e089
Ignore bad formated characters on serial line
Cyril-Roques Jan 19, 2016
0010fbd
Changed the wait fro modem to start, from sleep to hearth beats
alejandroMA Feb 8, 2016
138a3d2
Update serial_comms.py
havefunworkhard Apr 1, 2016
e87cca6
ZTE fixes
Jun 8, 2016
7278405
regex fix for ussd
Jun 9, 2016
0c24019
unicoded sms support
alex-eri Jun 11, 2016
4288c6c
python 3.2,3.3 compatibility
alex-eri Jun 11, 2016
057b76d
bytes for python3
alex-eri Jun 11, 2016
6d27b55
supporting modem's info channel with new pyserial
alex-eri Jun 11, 2016
c6a5fbf
porting str to bytes for python3
alex-eri Jun 11, 2016
073a463
zte fixes
alex-eri Jun 11, 2016
537904d
drop 2.6 and 3.2 due site libraries used with drops
alex-eri Jun 11, 2016
86c2f67
Merge pull request #1 from alejandroMA/master
PeteLawler Jul 4, 2016
b29a157
Support for modems which hangs after AT command for getting list of d…
Jul 5, 2016
4c0187e
Support for SMS encoding AT command
Jul 5, 2016
b463d4d
Support for SMS encoding AT command - bugfixes
Jul 5, 2016
53dacbf
Automatic change of modem sms encoding before sending
Jul 5, 2016
386c34b
BUGFIX: explicitly convert input text to UTF-8 (default encoding is h…
Jul 5, 2016
e387530
Lorger timeout in order to support VERY long messages
Jul 5, 2016
240d2f6
Support SIM800L
bennyslbs Aug 8, 2016
a6a5083
Merge remote-tracking branch 'Cyril-Roques/master'
Aug 14, 2016
f61c87d
Merge remote-tracking branch 'PeteLawler/master'
Aug 14, 2016
09dcb90
Merge remote-tracking branch 'alex-eri/master'
Aug 18, 2016
0e4ade3
Merge remote-tracking branch 'tomchy/master'
Aug 18, 2016
37360a4
tomchy/master utf8 decode fix
Aug 18, 2016
db4f8fb
alex-eri/master merge fix
Aug 18, 2016
8496975
Merge remote-tracking branch 'bennyslbs/master'
Aug 18, 2016
0f36d8c
Merge remote-tracking branch 'epol/master'
Aug 18, 2016
e3cd0a4
Merge remote-tracking branch 'rags22489664/master'
Aug 18, 2016
3306c00
handling incoming DTMF from fataevalex/master
Aug 18, 2016
6d5fc5b
Merge remote-tracking branch 'paolo-losi/master'
Aug 18, 2016
3e66fd5
Undo drop of 'Func' from incomingCallCallbackFunc and smsReceivedCall…
Aug 18, 2016
ac55aa7
Merge remote-tracking branch 'yuriykashin/master'
Aug 18, 2016
376235a
dirty fix warning
Aug 18, 2016
5a1c5fd
Merge remote-tracking branch 'foXes68/patch-1'
Aug 18, 2016
99a416f
Another fixes for broken paolo-losi's variable renames
Aug 19, 2016
eaa2c61
version 0.10
Aug 19, 2016
b1825d8
Re-added _placeHolderCallback
bennyslbs Aug 20, 2016
ba050b8
Not all modems support +CLAC (At least not SIM800L)
bennyslbs Aug 20, 2016
cfceb67
Merge pull request #1 from bennyslbs/master
babca Aug 20, 2016
ad5d52d
setup.py new pip repo package name
Sep 7, 2016
2627925
readme update
Sep 7, 2016
acaba6c
Update modem.py:277
lucasea777 Sep 8, 2016
e5258fb
Merge pull request #7 from lucasea777/master
babca Sep 8, 2016
4723c7d
passing dsrdtr=True and rtscts=True to Serial to avoid Broken Pipe error
lucasea777 Sep 12, 2016
d7ac128
Bug solved: prepending the 'b' letter when using .format()
lucasea777 Sep 12, 2016
edc218e
Merge pull request #1 from babca/master
lucasea777 Sep 12, 2016
46e07b1
update readme
babca Sep 13, 2016
d6679d0
Merge pull request #8 from lucasea777/master
babca Sep 13, 2016
42618a5
CPIN command timeout increased
babca Sep 14, 2016
8beb557
updated readme
babca Sep 14, 2016
c7a4636
added getter for SIM Own Number
babca Oct 29, 2016
6cda611
prepending the 'b' letter to missing commands
damadmai Nov 5, 2016
ea1f5e5
add decoding for lines.pop in _handleIncomingCall()
damadmai Nov 5, 2016
91b1a35
Merge pull request #16 from damadmai/bytes-patch
babca Nov 5, 2016
b374753
add regex matching for CNUM / ownNumber
damadmai Nov 5, 2016
6fea37b
Merge pull request #17 from damadmai/cnum-fix
babca Nov 5, 2016
d71e0a2
add decoding for enc_list response
damadmai Nov 8, 2016
428aae4
add gsmbusy property
damadmai Nov 8, 2016
f380f82
Merge pull request #18 from damadmai/bytes-patch
babca Nov 8, 2016
6ebe374
Merge pull request #19 from damadmai/gsmbusy-addition
babca Nov 8, 2016
663c112
v0.11
babca Nov 10, 2016
ffa64ad
v0.11
babca Nov 10, 2016
19c0a5c
v0.11
babca Nov 10, 2016
c5ad8b2
change to prepend + always for CLIP
damadmai Nov 19, 2016
a1b1459
Merge pull request #20 from damadmai/plus-fix
babca Nov 20, 2016
f475688
Remove trailing whitespace
damadmai Nov 20, 2016
2404881
Change to use bytes in serial_comms Python 2 and 3
damadmai Nov 20, 2016
f7f8147
Move all en/deocde() to serial_comm
damadmai Nov 20, 2016
9af9512
Remove unnecessary d() calls
damadmai Nov 20, 2016
0eed53a
Merge pull request #22 from damadmai/python3-fix
babca Nov 20, 2016
47facc8
fix invalid literal for int() with base 10
babca Nov 24, 2016
964f104
Minor doc correction
PeteLawler Jan 12, 2017
1de464e
Merge pull request #26 from PeteLawler/patch-1
babca Jan 16, 2017
64637de
Add optional argument for message text in sendsms util
tahajahangir Feb 23, 2017
26b45cf
Merge pull request #28 from tahajahangir/sendsms_message_new
babca Feb 23, 2017
356f3ed
Add an option in sendsms.py to prevent concurrent modem access
tahajahangir Feb 23, 2017
6633fc5
PDU: Fix message concatenation
tomchy Mar 6, 2017
c378122
PDU: Support text mode for sending SMS messages
tomchy Mar 6, 2017
d421b88
Unittest: Fix SMS-related unit tests
tomchy Mar 6, 2017
faeaa46
PDU: Add limited alphabet for text-mode messages
tomchy Mar 6, 2017
24711df
Unittest: Fix modem/edgeCases unit tests
tomchy Mar 6, 2017
4b67377
Unittest: Fix gsmmodem/GeneralApi unit tests and invalid response ins…
tomchy Mar 6, 2017
e8db391
Fix alphanumeric address decoding
Mar 6, 2017
75772b7
Modem/calls: Fix string/unicode to int call type translation
tomchy Mar 6, 2017
e3bfe98
Unittest: Add responses for command recognition queies inside fake mo…
tomchy Mar 6, 2017
edb86e6
Merge pull request #30 from tomchy/pr/pdu-multipart
babca Mar 6, 2017
a33ae73
Unittest: support iterative calling
tomchy Mar 6, 2017
f315fab
Merge pull request #31 from tomchy/pr/unittest-modem-edge
babca Mar 6, 2017
7d83584
Resolve conflicts with merged PR
tomchy Mar 6, 2017
e500f31
Better alphanumeric address decoding fix
babca Mar 6, 2017
d13b4a9
Modem: add handler for modems which does not support AT+CSCS command
tomchy Mar 6, 2017
00a2525
import math removed
babca Mar 6, 2017
732479f
Merge pull request #32 from tomchy/pr/unittest-modem-api
babca Mar 6, 2017
fe7acc7
mistake in nibble2octet
babca Mar 6, 2017
068c6b4
Merge pull request #35 from tomchy/pr/unittest-modem-calls
babca Mar 6, 2017
e185234
PDU: fix invalid decoding of large time zone values. Resolves #15.
tomchy Mar 7, 2017
a55822a
PDU: possible fix for invalid decoding of large time zone values.
tomchy Mar 7, 2017
6de5cba
PDU: Use integer type explicitly inisde time zone conversion
tomchy Mar 7, 2017
4caa11d
Merge pull request #36 from tomchy/pr/pdu-timezone-fix
babca Mar 7, 2017
8903fb2
Unittest: Python3+ compatibility
tomchy Mar 7, 2017
925874a
Travis: remove --use-mirrors flag (deprecated)
tomchy Mar 7, 2017
697003c
Merge pull request #37 from tomchy/pr/unittest-python3
babca Mar 7, 2017
a8b449d
PDU: Invalid, non-BCD time zone values
tomchy Mar 7, 2017
aae5290
Travis and Coveralls badges fixed
babca Mar 7, 2017
fcec8f8
Coverage badge now pointing to babca repo
babca Mar 7, 2017
3628336
Unittest: Test if modem will switch to UCS2 in case of unicode charac…
tomchy Mar 8, 2017
ebb49b8
Modem: use setters/getters to set/unset TextMode
tomchy Mar 8, 2017
8f80ae9
PDU: Python 2.* has problem with handling unicode strings without spe…
tomchy Mar 8, 2017
7bcfbe0
Unittest: fix test vectors
tomchy Mar 8, 2017
bf37779
Merge pull request #38 from tomchy/pr/pdu-switch-encoding
babca Mar 8, 2017
09065e6
PDU: Solve problem with unicode strings inside Python 2.7
tomchy Mar 8, 2017
91d8d07
Unittest: Fall into GSM while user sends too long messages
tomchy Mar 8, 2017
ef52f5b
Unittest: add tests for smsEncoding and smsSupportedEncoding properties
tomchy Mar 8, 2017
5bbb43c
Modem: raise an error if required encoding scheme is not supported
tomchy Mar 8, 2017
51fa489
Modem: do not raise an error if modem does not support +CSCS command …
tomchy Mar 8, 2017
77e620c
Modem: improved exceptions inside smsEncoding setter
tomchy Mar 8, 2017
3d178f4
Merge pull request #39 from tomchy/pr/pdu-encoding-tests
babca Mar 8, 2017
85994a8
Add python 3.6 inside TravisCI configuration
babca Mar 15, 2017
4ef955e
v0.12 release
Mar 15, 2017
2849814
Rebase to master
tomchy Mar 15, 2017
459159f
Merge pull request #29 from tahajahangir/sendsms_lock
babca Mar 15, 2017
6e69c26
Merge pull request #42 from tomchy/pr/pdu-timezone-fix
babca Mar 22, 2017
53c3f53
Merge branch 'master' of https://github.com/babca/python-gsmmodem
Apr 4, 2017
014ed00
empty write() removed
Apr 4, 2017
1973c95
change wrong attribute _encoding to _smsEncoding
shaljam Jun 6, 2017
c170f1b
Merge pull request #46 from shaljam/master
babca Jun 6, 2017
2f045df
Merge branch 'master' of https://github.com/babca/python-gsmmodem
Jun 8, 2017
b5e8571
Unnecessary semicolon removed
isidroamv Jun 27, 2017
524af1a
Merge pull request #48 from isidroamv/patch-1
babca Jul 11, 2017
5e206d3
Merge remote-tracking branch 'upstream/master'
Jul 25, 2017
f88e107
Merge pull request #49 from 9dogs/master
babca Jul 25, 2017
81bdf5b
HUAWEI CEND notification format fix
Aug 4, 2017
5e41dbe
Merge pull request #50 from 9dogs/master
babca Aug 7, 2017
72b088d
smsStatusReportCallback was called twice (fixed)
babca Nov 10, 2017
d569015
log smsStatusReportCallback errors in _handleSmsStatusReportTe too
babca Nov 10, 2017
8bbd76c
Callback fixes
babca Nov 10, 2017
bd7c54f
_placeholderCallback removed from serial_comms.py too
babca Nov 10, 2017
5f8b047
condition bugfix/typo
babca Nov 10, 2017
0d04314
reverted changes in callbacks, needs to be redone
babca Nov 18, 2017
5bccf97
Update modem.py
malanovo Jan 16, 2018
3e775b7
add long sms concat info support for recived sms
yurenchen000 Apr 13, 2018
9c7ae29
Add long sms concat info for received sms
yurenchen000 Apr 13, 2018
5784c9a
Merge branch 'master' of https://github.com/yurenchen000/python-gsmmodem
yurenchen000 Apr 13, 2018
8f594f9
Fix supportedCommands property for Siemens modems
ffix Jul 12, 2018
2afbf63
Merge pull request #57 from malanovo/patch-1
babca Nov 6, 2018
4abcc93
Fix brand mistake. It's actually Teleofis, not Siemens. Add test docs…
ffix Nov 30, 2018
c459b63
fix connect for modem's which don't support AT+DDET command
phreaker0 Feb 15, 2019
f446d26
Merge pull request #62 from ffix/siemens-commands-fix
babca Mar 11, 2019
ae0afb6
README.md very short How to use section added
babca Mar 11, 2019
26faba4
simple FAQ
babca Mar 11, 2019
2d39776
Updated URL to pyserial library
babca Mar 19, 2019
5c816ba
Merge pull request #72 from phreaker0/fix-sim7000E
babca Mar 22, 2019
ad17d5a
Merge branch 'master' into master
lcnittl Nov 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ htmlcov

# Working copy files
*.swp

.DS_Store
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
language: python
python:
- "3.6"
- "3.5"
- "3.4"
- "3.3"
- "3.2"
- "2.7"
- "2.6"
install:
# Install unittest2 on Python 2.6
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install --use-mirrors unittest2; fi
- if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install unittest2; fi
# Install coveralls (for coveralls.io integration)
- pip install coveralls
- pip install -r requirements.txt --use-mirrors
- pip install -r requirements.txt
script: python setup.py coverage
after_success: coveralls
12 changes: 12 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@ the01 <https://github.com/the01>
Frederico Rosmaninho
David Beitey <https://github.com/davidjb>
BOOMER74 <https://github.com/BOOMER74>
Cyril-Roques <https://github.com/Cyril-Roques>
PeteLawler <https://github.com/PeteLawler>
alex-eri <https://github.com/alex-eri>
tomchy <https://github.com/tomchy>
bennyslbs <https://github.com/bennyslbs>
epol <https://github.com/epol>
rags22489664 <https://github.com/rags22489664>
fataevalex <https://github.com/fataevalex>
paolo-losi <https://github.com/paolo-losi>
yuriykashin <https://github.com/yuriykashin>
foXes68 <https://github.com/foXes68>
babca <https://github.com/babca>

27 changes: 27 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
* Wed Mar 15 2017 babca - 0.12
– stable release
- unit tests fixed after rapid merging – credits to: tomchy
- python3.6 support added
– message concatenation fixes and more

* Thu Nov 10 2016 babca - 0.11
- added getter for SIM own number
- added option for blocking incoming calls (GSMBUSY)
- various python3 fixes

* Thu Aug 18 2016 babca - 0.10
– Probably a new code maintainer for 2016
- All commits published for the last 3 years merged into a one branch
– Compatibilty for python3 added, needs further testing!
– experimental GPRS support
– more:
– change AT_CNMI command if needed
– waitingForModemToStartInSeconds
– timeouts increased
– ability to check SMS encodings supported by modem - smsSupportedEncoding()
– better modem specific support (incl. simcom)
– TE SMS status reports handling support
– option to disable requesting delivery reports
– incoming DTMF support
– todo: check AT+CMGD support for 1 or 2 params and use appropriate command format

* Thu Jul 18 2013 Francois Aucamp <[email protected]> - 0.9
- Added UDH support for SMS PDUs
- Stored messages APIs made public
Expand Down
76 changes: 54 additions & 22 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
python-gsmmodem
===============
python-gsmmodem-new v0.12
=========================
*GSM modem module for Python*

python-gsmmodem is a module that allows easy control of a GSM modem attached
Expand Down Expand Up @@ -28,56 +28,71 @@ Bundled utilities:
- **identify-modem.py**: simple utility to identify attached modem. Can also be
used to provide debug information used for development of python-gsmmodem.

How to use this package
-----------------------

Go to `examples/` directory in this repo.


Requirements
------------

- Python 2.6 or later
- Python 2.7 or later
- Python 3.3 or later
- pyserial


How to install this package
---------------------------

There are two ways to install ``python-gsmmodem``:
There are multiple ways to install ``python-gsmmodem-new`` package:

Automatic installation
~~~~~~~~~~~~~~~~~~~~~~
Automatic installation of the latest "stable" release from PyPI
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

pip install python-gsmmodem
pip install python-gsmmodem-new

`pip <http://www.pip-installer.org>`_ will automatically download and install
all dependencies, as required. You can also utilise ``easy_install`` in the
same manner as using ``pip`` above.

If you are utilising ``python-gsmmodem`` as part of another project,
If you are utilising ``python-gsmmodem-new`` as part of another project,
add it to your ``install_requires`` section of your ``setup.py`` file and
upon your project's installation, it will be pulled in automatically.

Manual installation
~~~~~~~~~~~~~~~~~~~
Manual installation of the latest "stable" release from PyPI
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Download and extract the ``python-gsmmodem`` archive from `PyPI
<https://pypi.python.org/pypi/python-gsmmodem>`_ for the current release
version, or clone from `GitHub <https://github.com/faucamp/python-gsmmodem>`_.
Next, do this::
Download a ``python-gsmmodem-new`` archive from `PyPI
<https://pypi.python.org/pypi/python-gsmmodem-new>`_, extract it and install the package with command::

python setup.py install

Note that ``python-gsmmodem`` relies on ``pyserial`` for serial communications:
http://pyserial.sourceforge.net
Note that ``python-gsmmodem-new`` package relies on ``pyserial`` for serial communications:
https://github.com/pyserial/pyserial

Installation of the latest commit from GitHub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Clone from GitHub::

git clone https://github.com/babca/python-gsmmodem.git
cd python-gsmmodem/
python setup.py install

Note that ``python-gsmmodem-new`` package relies on ``pyserial`` for serial communications:
https://github.com/pyserial/pyserial

Testing the package
-------------------

.. |Build Status| image:: https://travis-ci.org/faucamp/python-gsmmodem.png?branch=master
.. _Build Status: https://travis-ci.org/faucamp/python-gsmmodem

.. |Build Status| image:: https://travis-ci.org/babca/python-gsmmodem.svg?branch=master
.. _Build Status: https://travis-ci.org/babca/python-gsmmodem

.. |Coverage Status| image:: https://coveralls.io/repos/faucamp/python-gsmmodem/badge.png?branch=master
.. _Coverage Status: https://coveralls.io/r/faucamp/python-gsmmodem
.. |Coverage Status| image:: https://coveralls.io/repos/github/babca/python-gsmmodem/badge.svg?branch=master
.. _Coverage Status: https://coveralls.io/github/babca/python-gsmmodem?branch=master

|Build Status|_ |Coverage Status|_

Expand All @@ -100,7 +115,7 @@ Building documentation
This package contains `Sphinx <http://sphinx-doc.org>`_-based documentation.
To manually build or test the documentation locally, do the following::

git clone https://github.com/faucamp/python-gsmmodem.git
git clone https://github.com/babca/python-gsmmodem.git
cd python-gsmmodem
pip install .[doc]
cd doc
Expand All @@ -110,6 +125,7 @@ For true isolation, you may wish to run the above commands within a
`virtualenv <http://www.virtualenv.org/>`_, which will help you manage
this development installation.


License information
-------------------

Expand All @@ -118,3 +134,19 @@ See AUTHORS for all authors and contact information.

License: GNU Lesser General Public License, version 3 or later; see COPYING
included in this archive for details.

FAQ
---

List all modem ports
~~~~~~~~~~~~~~~~~~~~

You can simply list all ttyUSB devices before and after pluging the modem in.

ls /dev/ttyUSB*


Device or resource busy error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check running processes. The device could be occupied by another program or another instance of gsmmodem which is still running in the background. Run ``sudo lsof | grep tty``, try to locate the problematic process and ``sudo kill <PID>``.
12 changes: 6 additions & 6 deletions examples/incoming_call_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Demo: handle incoming calls

Simple demo app that listens for incoming calls, displays the caller ID,
optionally answers the call and plays sone DTMF tones (if supported by modem),
optionally answers the call and plays sone DTMF tones (if supported by modem),
and hangs up the call.
"""

Expand All @@ -27,29 +27,29 @@ def handleIncomingCall(call):
print('Answering call and playing some DTMF tones...')
call.answer()
# Wait for a bit - some older modems struggle to send DTMF tone immediately after answering a call
time.sleep(2.0)
time.sleep(2.0)
try:
call.sendDtmfTone('9515999955951')
except InterruptedException as e:
# Call was ended during playback
print('DTMF playback interrupted: {0} ({1} Error {2})'.format(e, e.cause.type, e.cause.code))
print('DTMF playback interrupted: {0} ({1} Error {2})'.format(e, e.cause.type, e.cause.code))
finally:
if call.answered:
print('Hanging up call.')
call.hangup()
else:
else:
print('Modem has no DTMF support - hanging up call.')
call.hangup()
else:
print(' Call from {0} is still ringing...'.format(call.number))

def main():
print('Initializing modem...')
#logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
modem = GsmModem(PORT, BAUDRATE, incomingCallCallbackFunc=handleIncomingCall)
modem.connect(PIN)
print('Waiting for incoming calls...')
try:
try:
modem.rxThread.join(2**31) # Specify a (huge) timeout so that it essentially blocks indefinitely, but still receives CTRL+C interrupt signal
finally:
modem.close()
Expand Down
38 changes: 38 additions & 0 deletions examples/own_number_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python

"""\
Demo: read own phone number
"""

from __future__ import print_function

import logging

PORT = '/dev/vmodem0'
BAUDRATE = 115200
PIN = None # SIM card PIN (if any)

from gsmmodem.modem import GsmModem

def main():
print('Initializing modem...')
# Uncomment the following line to see what the modem is doing:
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
modem = GsmModem(PORT, BAUDRATE)
modem.connect(PIN)

number = modem.ownNumber
print("The SIM card phone number is:")
print(number)

# Uncomment the following block to change your own number.
# modem.ownNumber = "+000123456789" # lease empty for removing the phone entry altogether

# number = modem.ownNumber
# print("A new phone number is:")
# print(number)

# modem.close();

if __name__ == '__main__':
main()
14 changes: 8 additions & 6 deletions examples/sms_handler_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@
from gsmmodem.modem import GsmModem

def handleSms(sms):
print(u'== SMS message received ==\nFrom: {0}\nTime: {1}\nMessage:\n{2}\n'.format(sms.number, sms.time, sms.text))
# long sms Concatenation support: reference, parts, number
concat = sms.concat.__dict__ if sms.concat else {}
print(u'== SMS message received ==\nFrom: {0}\nTime: {1}\nconcat: {2}\nMessage:\n{3}\n'.format(sms.number, sms.time, concat, sms.text))
print('Replying to SMS...')
sms.reply(u'SMS received: "{0}{1}"'.format(sms.text[:20], '...' if len(sms.text) > 20 else ''))
print('SMS sent.\n')

def main():
print('Initializing modem...')
# Uncomment the following line to see what the modem is doing:
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
modem = GsmModem(PORT, BAUDRATE, smsReceivedCallbackFunc=handleSms)
modem.smsTextMode = False
modem.smsTextMode = False
modem.connect(PIN)
print('Waiting for SMS message...')
try:
print('Waiting for SMS message...')
try:
modem.rxThread.join(2**31) # Specify a (huge) timeout so that it essentially blocks indefinitely, but still receives CTRL+C interrupt signal
finally:
modem.close();
modem.close()

if __name__ == '__main__':
main()
Loading