gsm

package module
v0.0.0-...-c9bf49a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

README

GSMGo

Introduction

GSMGo is SMS HTTP server with REST API, written in Go language.

Server enables you to send SMS messages with simple HTTP POST request:

# curl -X POST -d '{"text": "Message Example", "number": "+38164182xxxx"}' http://localhost:38164
{
"message": "success",
"status": "OK"
}

GSMGo uses libGammu so it has support for many different phones. Check Gammu Phone Database for details.

Download

Binaries are compiled with static build of libGammu, so gammu/libgammu is not required to be installed.

Usage

Usage of gsmgo:
  -bind string
        Bind address (default ":38164")
  -config string
        Config file
  -debug
	    Enable debugging
  -password string
        Password
  -username string
        Username

If you start server with username and password, it will be protected with HTTP Basic Auth.

Config file is required. Example config is shown below, it will be searched for in /etc/gsmgo.conf then ~/.gsmgo.conf and finally in directory where binary is located. You can also point it with -config option.

[gammu]
device = /dev/ttyACM0
name = Ericsson Ericsson_F3507g_Mobile_Broadband_Minicard_Composite_Device
connection = at

You can try to detect your device with gammu-detect from gammu package and then just copy /etc/gammurc file to /etc/gsmgo.conf.

Compile

Install libgammu library and devel package:

apt-get install libgammu-dev libgammu

Install server to $GOPATH/bin:

go get github.com/gen2brain/gsmgo
go install github.com/gen2brain/gsmgo/server/gsmgo

Documentation

Index

Constants

View Source
const (
	ERR_NONE    = C.ERR_NONE
	ERR_UNKNOWN = C.ERR_UNKNOWN
	ERR_TIMEOUT = C.ERR_TIMEOUT
	ERR_EMPTY   = C.ERR_EMPTY
)

Variables

This section is empty.

Functions

func StartSMSD

func StartSMSD(config string, programName string) (err error)

Types

type GSM

type GSM struct {
	// contains filtered or unexported fields
}

Gammu GSM struct

func NewGSM

func NewGSM() (g *GSM, err error)

Returns new GSM

func (*GSM) AlwaysReadUntilBreak

func (g *GSM) AlwaysReadUntilBreak()

func (*GSM) Connect

func (g *GSM) Connect() (err error)

Connects to phone

func (*GSM) EnableDebug

func (g *GSM) EnableDebug()

Enables global debugging to stderr

func (*GSM) GetUSSDByCode

func (g *GSM) GetUSSDByCode(code string, device string) (string, error)

func (*GSM) IsConnected

func (g *GSM) IsConnected() bool

Checks if phone is connected

func (*GSM) ReadSMS

func (g *GSM) ReadSMS(delete bool) (messages []*SmsRead, err error)

func (*GSM) SendLongSMS

func (g *GSM) SendLongSMS(text, number string) (err error)

func (*GSM) SendSMS

func (g *GSM) SendSMS(text, number string) (err error)

Sends message

func (*GSM) SetCallBack

func (g *GSM) SetCallBack(fx func(string, string) error)

func (*GSM) SetConfig

func (g *GSM) SetConfig(config string, section int) (err error)

Reads configuration file

func (*GSM) Terminate

func (g *GSM) Terminate() (err error)

Terminates connection and free memory

func (*GSM) WaitForSMS

func (g *GSM) WaitForSMS(wait int) error

type Modem

type Modem struct {
	Port *serial.Port
}

func NewModem

func NewModem(deviceName string) (*Modem, error)

func (*Modem) Expect

func (m *Modem) Expect(possibilities []string) (string, error)

func (*Modem) Read

func (m *Modem) Read() (string, error)

func (*Modem) ReadWithContext

func (m *Modem) ReadWithContext(ctx context.Context) <-chan *respChan

func (*Modem) ReadWithTimeout

func (m *Modem) ReadWithTimeout(ctx context.Context) (string, error)

func (*Modem) Send

func (m *Modem) Send(command string)

func (*Modem) SendCommand

func (m *Modem) SendCommand(command string, waitForOk bool) (string, error)

type SmsRead

type SmsRead struct {
	Location int
	Folder   int
	Number   string
	Text     string
}

Directories

Path Synopsis
server
gsmgo command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL