Access SMS, GSM and 3G features of Huawei and compatible modems from your own apps via clean and pragmatic Python API

Get started

Python 3 support and other news

  1. Python 3 support now arrived to PyHumod, our pythonic API to Huawei and compatible GSM modems.
  2. Project site and repository moved to Github. See also brushed up documentation and improved website. If you use PyHumod please fork us, give PyHumod a star or watch for updates.
  3. Lots of new features and bug fixes.
New features include (presently under humod/siminfo.py):
  • ability to show system info in one go (operator, roaming status, signal strenght, SIM status etc)
  • simple GSM0338 decoder for those who don't read bytes
  • multipart message concatenation, which we hope to integrate into modem.sms_list()
  • show IMSI
  • show operator
  • show phone number (works with some SIMs)
  • phone number formatting
  • SMS time to python datetime
We hope to integrate these better into PyHumod to provide a first class API.

    Guide to GSM error codes and their meanings (+CMS errors)

    Here's a handy list outlining message service errors. These are the error codes for +CMS ERROR coupled with their human readable meanings. Now when a GSM modem barks at you you may have some idea why.

    • Error code - Meaning
    • 0-127 - GSM 04.11 Annex E-2 values
    • 128-255 - GSM 03.40 section 9.2.3.22 values
    • 300 - Device failure
    • 301 - SMS service of device reserved
    • 302 - Operation not allowed
    • 303 - Operation not supported
    • 304 - Invalid PDU mode parameter
    • 305 - Invalid text mode parameter
    • 310 - SIM not inserted
    • 311 - SIM PIN necessary
    • 312 - PH-SIM PIN necessary
    • 313 - SIM failure
    • 314 - SIM busy
    • 315 - SIM wrong
    • 320 - Memory failure
    • 321 - Invalid memory index
    • 322 - Memory full
    • 330 - SMSC (message service center) address unknown
    • 331 - No network service
    • 332 - Network timeout
    • 500 - Unknown error
    • 512 - Manufacturer specific

    This 3rd party website maintains a full list.


    Troubleshooting "AtCommandError: +CMS ERROR: 500"

    If AtCommandError exception is thrown with "+CMS ERROR: 500" output, it literally means "SMS could not be sent" (which you must have figured out by now). Those are the possible reasons:
    • You lost coverage.
      In this case, the modem will typically seem to hang for 10-15 seconds. The delay is caused by an attempt to scan and associate with the cellular network. Run get_networks() on humodem.Modem's instance to see what networks are in range.
    • You use wrong Service Senter.
      Run get_service_center() on a humod.Modem's instance to see your service center; you can set a new value with set_service_center().
    • Potentially everything that prevents an SMS from being sent.

    Huawei E1752 modem support on Ubuntu Linux

    For the E1752 model the network manger applet will not pop up unlike other dongles as it also acts as a storage device.

    sudo apt-get install usb-modeswitch

    Put this in /etc/usb-modeswitch.conf

    # Huawei E1752
    DefaultVendor = 0x12d1
    DefaultProduct = 0x1446
    TargetVendor = 0x12d1
    TargetProduct = 0x1001
    MessageEndpoint = 0x01
    MessageContent = "55534243000000000000000000000011060000000000000000000000000000"
    

    Optionally: network manager > mobile broadband > o2 pay as you go > ... enter your own pin on the end

    sudo usb_modeswitch

    Now you should be able to:

    python
    import serial
    ser = serial.Serial('/dev/ttyUSB0')
    ser.write("at\r")
    ser.readline()
    

    PyHumod 0.03 released for downloads

    Latest PyHumod can be downloaded from:

    The changes include:

    DevelGuide updated + some changes in the source.

    I found some time to update PyHumod Developer's Guide. The wikidoc has been extended by the event handling section. I also worked on the source code in the mercurial repository and today's changes include:
    • deprecation of *_pbent, all SMS-related and entering Text/PDB mode commands. I will update the documentation reflecting it as soon as pyhumod-0x03 is available for download. I must admit I didn't put a lot of thought initially into the naming of the methods and they were a little random. From version 0.03 on, all SMS related Modem() methods will start with sms_* prefix, the phone book related ones with pbent_* prefix and so on.
    • Code cleanup to avoid repetition. See _common_enable for details.
    • Enabling CLIP (Calling line identification presentation). This will be useful in conjunction with event handler, as it tells you who (what number) is actually calling you.

    PyHumod Developers Guide ...

    A very short developers guide has been published in response to mistletoe's request on the mailing list. I hope you'll find it useful.