Giter VIP home page Giter VIP logo

modem's Introduction

modem

A low level Go driver for AT modems.

Build Status Coverage Status Go Report Card License: MIT

modem is a Go library for interacting with AT based modems.

The initial impetus was to provide functionality to send and receive SMSs via a GSM modem, but the library may be generally useful for any device controlled by AT commands.

The at package provides a low level driver which sits between an io.ReadWriter, representing the physical modem, and a higher level driver or application.

The AT driver provides the ability to issue AT commands to the modem, and to receive the info and status returned by the modem, as synchronous function calls.

Handlers for asynchronous indications from the modem, such as received SMSs, can be registered with the driver.

The gsm package wraps the AT driver to add higher level functions to send and receive SMS messages, including long messages split into multiple parts, without any knowledge of the underlying AT commands.

The info package provides utility functions to manipulate the info returned in the responses from the modem.

The serial package provides a simple wrapper around a third party serial driver, so you don't have to find one yourself.

The trace package provides a driver, which may be inserted between the AT driver and the underlying modem, to log interactions with the modem for debugging purposes.

The cmd directory contains basic commands to exercise the library and a modem, including retrieving details from the modem, sending and receiving SMSs, and retrieving the SIM phonebook.

Features

Supports the following functionality:

  • Simple synchronous interface for AT commands
  • Serialises access to the modem from multiple goroutines
  • Asynchronous indication handling
  • Tracing of messages to and from the modem
  • Pluggable serial driver - any io.ReadWriter will suffice

Usage

The at package allows you to issue commands to the modem and receive the response. e.g.:

modem := at.New(ioWR)
info, err := modem.Command("I")

produces the following interaction with the modem (exact results will differ for your modem):

2018/05/17 20:39:56 w: ATI
2018/05/17 20:39:56 r:
Manufacturer: huawei
Model: E173
Revision: 21.017.09.00.314
IMEI: 1234567
+GCAP: +CGSM,+DS,+ES

OK

and returns this info:

info = []string{
    "Manufacturer: huawei",
    "Model: E173",
    "Revision: 21.017.09.00.314",
    "IMEI: 1234567",
    "+GCAP: +CGSM,+DS,+ES",
    }

Refer to the modeminfo for an example of how to create a modem object such as the one used in this example.

For more information, refer to package documentation, tests and example commands.

Package Documentation Tests Example code
at go.dev reference at_test modeminfo
gsm go.dev reference gsm_test sendsms, waitsms
info go.dev reference info_test phonebook
serial go.dev reference serial_test modeminfo, sendsms, waitsms
trace go.dev reference trace_test sendsms, waitsms

modem's People

Contributors

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