Giter VIP home page Giter VIP logo

gsm-tc35-python-library's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gsm-tc35-python-library's Issues

7bit encoding not handled correctly

Issue received from mail:

The message has "@" char at the beginning, it transforms it to "¡" when sending the message out.
It looks like the issue only appears on messages which are non-utf-8, regardless if they are multipart or not.

Example of sendSMS that works/fail:
"@Vtests 13 kols 33" - received "¡Vtests 13 kols 33" (fail)
"a@Vtests 13 kols 33" - received "a¡Vtests 13 kols 33" (fail)
"\@Vtests 13 kols 33" - received "\@Vtests 13 kols 33" (works with "\")
"tests 13 kols ā 33 @d" (works)

When trying to read a message which contains "@" from the device, it (@ char) is returned as hex "\x00" somwhat similar behavior to this.

Send MMS (multipart SMS)

It is currently possible to send SMS but not multipart SMS (more than 140 char or more than 70 special char).
The module can handle that but this should be implemented in the library.

Add repository in pypi (pip) repositories once very stable

What should be done before adding this lib to pypi:

  • codecov Fully implement unit-test (40 hours)
  • Add possibility to install test requirement package from setup.py (1 hour)
  • Launch test with python 2.7 and check if possible to add python 2.7 compatibility (between 2 and 10 hours)
  • Build Status Add more python revision in travis and be sure everything is fine (2 hours)
  • Change major revision of the lib (0 min)
  • Test the library with real TC35 as much as possible (2 hours)
  • Update and check the main readme and be sure the example are working (2 hours)
  • Update documentation to add information on how to build/launch test (1 hour)
  • Tag (30 min)
  • Add repository in pypi (pip) repositories

Getting Phonebook entries or SMS may not work

Calling multiple times function to get SMS or Phonebook entries will not work every time.
--> Need to investigate, add more logs and fix the issue.

Potential errors:

  • Waiting the "OK" fails
  • "empty" line not handled
  • Timeout
  • ...

Test the library with unit-test

It would be great to unit-test this library.


Basic example checking what is written to the serial port and sending only specific data into the serial port.

It is not using unittest.mock (would be better with mock)...

import unittest
from GSMTC35 import GSMTC35
import logging
#from unittest.mock import patch

logger = logging.getLogger()
#logger.setLevel(logging.DEBUG)

# Basic simulation of GSM "hardware" (serial port)
class FakeSerial:
  __in_waiting = 0
  __read = ""
  __write = 0
  __check_write = ""
  __is_open = True
  __is_closed = True
  def __init__(self, in_waiting=50, read="OK\r\n", write=50, check_write="", is_open=True, is_closed=True):
    self.__in_waiting = in_waiting
    self.__read = read.encode()
    self.__write = write
    self.__check_write = check_write.encode()
    self.__is_open = is_open
    self.__is_closed = is_closed
  def inWaiting(self):
    return self.__in_waiting
  def read(self, dummy):
    return self.__read
  def write(self, data):
    if len(self.__check_write) > 0:
      assert self.__check_write == data
    return self.__write
  def isOpen(self):
    return self.__is_open
  def close(self):
    return self.__is_closed

# Generate a GSMTC35 instance with a fake GSM "hardware" module
def generateGsm(in_waiting=50, read="OK\r\n", write=50, check_write="", is_open=True, is_closed=True):
  level = logging.getLogger().getEffectiveLevel()
  logger.setLevel(logging.CRITICAL)
  gsm = GSMTC35.GSMTC35()
  gsm.setup("COMundefined")
  logger.setLevel(level)
  gsm.serial = FakeSerial(in_waiting, read, write, check_write, is_open, is_closed)
  return gsm

# All test
class TestGSMTC35(unittest.TestCase):
  def test_FailToConnectToDevice(self):
    level = logging.getLogger().getEffectiveLevel()
    logger.setLevel(logging.CRITICAL)
    gsm = GSMTC35.GSMTC35()
    assert gsm.setup("COMundefined") == False
    logger.setLevel(level)

    def test_Reboot(self):
      assert generateGsm(read="^SYSSTART\r\n",check_write="AT+CFUN=1,1\r\n").reboot() == True

# Launch all unit-test
unittest.main()

result:

> python test.py
..
 ----------------------------------------------------------------------
Ran 2 tests in 0.001s
OK

Python 2.7 support

Since latest fix and improvements, python2.7 is not fully supported for sendSMS (mostly with special char).
It should be or at least it should not throw error if full python3/python2.7 is not possible.

UTF-8 support

Hi Quentin,

Super useful library! I'm loving it!

One issue that I did not manage to resolve - when I try to send

Python GSMTC35.py --serialPort COM3 --sendSpecialSMS +37125502235 "Hello Jānis"

I receive unreadable characters on my phone.

For tests, I'm using windows 10, Python 3.7

Is it possible to resolve this somehow?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.