Giter VIP home page Giter VIP logo

sim-access's Introduction

sim-access

A Python module for managing SIM modules

Setup

The setup is:

  • A serial sim module SIM7500A (SIM800L is supported too).
  • A USB to serial module connecting my computer with SIM7500A.

The reason I am using a USB to Serial module is because I always want to make things easier to integrate with different setups. I hate connecting different GPIO wires with the SIM module and this is not sexy at all. With a USB to Serial module. It can be easier to plug and unplug to your systems.

Coding

Texts and Calls

To receive SMS and calls, you need to write a class from base class SIMModuleBase. There are two method you need to implement. on_sms() and on_call(). Here is one example.

class MySIM(SIMModuleBase):
    def on_sms(self, number, content):
        print('Text from: {0}, Content: \"{1}\"'.format(number, content))

    def on_call(self, number):
        print('Got phone call from {0}'.format(number))
        time.sleep(5)
        self.call_hangup()

    def on_call_missed(self, number):
        ''' This function is not working for SIM800
        '''
        self.sms_send(number, 'Sorry, I missed your call!')

if __name__ == '__main__':
    MySIM().mainloop()

You can detach the mainloop thread

    a.mainloop(True)

You can manage the loop yourself

    while True:
        # do something 1 ...
        a.loop_once()
        # do something 2 ...

GPS

You can also get your GPS locations, date and time using method gps_location_date_time

    class MySIM(SIMModuleBase):
        ...
    
    sim = MySIM()
    ((mylong, mylat), mydate, mytime) = sim.gps_location_date_time('<YOUR APN>')
    print('Longitude: {0}\nLatitude: {1}\nDate: {2}\nTime: {3}\n'.format(mylong, mylat, mydate, mytime))

Whenever you received an SMS, on_sms() willl be called. If you receive a phone call, on_call() will be called. Please note that on_call() could be called multiple times during a phone call.

There is no implemenation of answering the phone call right now. The SIM module I bought does not support answering phone calls.

Implementation

Internally, I use a thread to monitor incoming texts and calls.

sim-access's People

Contributors

wilsonwang371 avatar

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.