Code Monkey home page Code Monkey logo

smssender's Introduction

SMSSender

The Simple http server, that can communicate with the GSM modem over serial connection and send sms messages

Tested on the modem: Huawei i3131

Usage

After start the server you can send GET requests in the next format:

http://<host>[:port]/?c=<command>&access-token=<valid_auth_key>[&params=<params_in_the_json>]

Available next commands:

  • send_sms - sends an sms in the PDU mode, Require additional parameters {"phone": "", "text": ""}
  • get_balance - requests a balance for SIM card and parses response

Example - If you want to create sms, Send the request to the server with next parameters:

  • c=send_sms
  • access-token=
  • params in the next format:
{
    "phone": "89203058686", 
    "text": "Ваша заявка №12346 Принята в обработку. См. http://d3.ru/1dhk54ff"
}

Where:

  • phone have format: (+?7|8)(){11}
  • text can contains up to 160 of ascii symbols, or up to 70 cyrillic or other utf-8 symbols

Parameters should be encoded to the url format.

After processing, server sends response in the next format:

  • if all OK HTTP 200OK
{
    "response": "success"
    "code": 0
}
  • if happens internal error HTTP 500
{
    "error": "<error description>"
    "code": <int>
}
  • if authenticate fails HTTP 401
{
    "error": "Authenticate error"
    "code": <int>
}

Possible errors:

  • 10 - command is required
  • 21 - the text should not be an empty string
  • 22 - The text should not be longer than 160 characters to ascii
  • 23 - The text should not be longer than 70 characters for not ascii
  • 30 - phone number is required
  • 31 - phone number has invalid format
  • 32 - payload is required
  • 33 - internal modem error. The message not sended
  • 40 - SmsHandler instance has no attribute ''
  • 41 - Authenticate error

if all ok - code has zero value

Full request:

192.168.0.175:8080/?c=send_sms&access-token=500a7317788e421227edf73552a4dd10&params={"phone": "%2B79203058686", "text": "Your task №12346 is done"}

Installing

You must install next packages:

Actualize the .config file. Choose IP address, port for server and parameters for serial connection. Fill the auth keys. Ex.

[HTTP]
host=192.168.0.175
port=8080

[LOG]
file=app.log

[SERIAL]
port=COM12
baudrate=9600

[AUTH]
key_param=access-token
keys=[{"key": "500a7f0d325e421227edfd2952a4dd10"}, {"key": "54b41191a856acc1be94812d7549d77f"}]

Prepare modem

  • Set modem to the USB port
  • Install the drivers
  • Check whether there a new serial ports in the list of devices. For example: you should found port with name "HUAWEI Mobile Connect - 3G PC UI Interface"
  • For Microsoft Windows OS only: Stop the service, which the occupy serial port. For example "MegaFon Internet Service" 8 Add the exception for service and port to the firewall
  • Run the server
python main.py

smssender's People

Contributors

armit avatar

Watchers

 avatar  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.