Documentation
¶
Index ¶
- func DoRequest(url string, conn *tls.Conn, method string, param interface{}, ...) error
- func EncodeClientRequest(method string, args interface{}) ([]byte, error)
- func NewConnection(g *DefaultGsmModule, address string) (net.Conn, error)
- func NewReader(c net.Conn) io.Reader
- type APN
- type AlreadyConnectedErr
- type Baud
- type ClientRequest
- type ClientResponse
- type Command
- type Config
- type ConfigType
- type Conn
- func (c Conn) Close() error
- func (c Conn) LocalAddr() net.Addr
- func (c Conn) Read(b []byte) (n int, err error)
- func (c Conn) RemoteAddr() net.Addr
- func (c Conn) SetDeadline(t time.Time) error
- func (c Conn) SetReadDeadline(t time.Time) error
- func (c Conn) SetWriteDeadline(t time.Time) error
- func (c Conn) Write(b []byte) (n int, err error)
- type DefaultGsmModule
- func (g *DefaultGsmModule) CloseGsmModule()
- func (g *DefaultGsmModule) CloseTcpConnection() error
- func (g *DefaultGsmModule) CommandEchoOff() error
- func (g *DefaultGsmModule) CommandEchoOn() error
- func (g *DefaultGsmModule) GetLocalIPAddress() (string, error)
- func (g *DefaultGsmModule) GetStatus() (bool, error)
- func (g *DefaultGsmModule) Init() error
- func (g *DefaultGsmModule) IsConnected() (bool, error)
- func (g *DefaultGsmModule) OpenTcpConnection(address string) error
- func (g *DefaultGsmModule) ReadData() (byte, error)
- func (g *DefaultGsmModule) SendRawTcpData(data []byte) (int, error)
- func (g *DefaultGsmModule) Shutdown() error
- func (g *DefaultGsmModule) SwitchGNSSPowerOff() error
- func (g *DefaultGsmModule) SwitchGNSSPowerOn() error
- func (g *DefaultGsmModule) ToggleModule() error
- func (g *DefaultGsmModule) WaitForNetworkRegistration() error
- type Error
- type MaxBytesErr
- type NetworkRegistrationRetries
- type NetworkRegistrationRetryDelay
- type NetworkRegistrationStatus
- type NotReadyErr
- type Reader
- type ResponseMessage
- type SendTimeout
- type TimedOutErr
- type Transport
- type Verbose
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoRequest ¶ added in v0.2.0
func DoRequest(url string, conn *tls.Conn, method string, param interface{}, reply interface{}) error
DoRequest executes a JSON-RPC request with the provided param. A pointer to the result reply must be given for the response to be unmarshalled.
func EncodeClientRequest ¶ added in v0.2.0
EncodeClientRequest encodes parameters for a JSON-RPC client request.
func NewConnection ¶
func NewConnection(g *DefaultGsmModule, address string) (net.Conn, error)
Types ¶
type APN ¶ added in v0.2.0
type APN string
func (APN) Type ¶ added in v0.2.0
func (APN) Type() ConfigType
type AlreadyConnectedErr ¶
type AlreadyConnectedErr struct { }
func (AlreadyConnectedErr) Error ¶
func (e AlreadyConnectedErr) Error() string
type ClientRequest ¶ added in v0.2.0
type ClientRequest struct { JsonRpc string `json:"jsonrpc"` Method string `json:"method"` Params [1]interface{} `json:"params"` Id string `json:"id"` }
ClientRequest represents a JSON-RPC request sent by a client.
type ClientResponse ¶ added in v0.2.0
type ClientResponse struct { JsonRpc string `json:"jsonrpc"` Result *json.RawMessage `json:"result"` Error interface{} `json:"error"` Id string `json:"id"` }
ClientResponse represents a JSON-RPC response returned to a client.
type Command ¶
type Command string
const CheckNetworkRegistrationCommand Command = `AT+CGREG?`
const ConnectCommand Command = `AT+CIPSTART="TCP", "%s", "%s"`
const ConnectionStateCommand Command = `AT+CIPSTATUS`
const DisconnectCommand Command = `AT+CIPCLOSE`
const EchoOffCommand Command = `ATE0`
const EchoOnCommand Command = `ATE1`
const GetLocalIPAddressCommand Command = `AT+CIFSR`
const SendCommand Command = `AT+CIPSEND`
const StatusCommand Command = `AT`
type Config ¶
type Config interface { Type() ConfigType Value() interface{} Default() interface{} }
type ConfigType ¶
type ConfigType string
const APNConfig ConfigType = "APNConfig"
const BaudConfig ConfigType = "Baud"
const NetworkRegistrationRetriesConfig ConfigType = "NetworkRegistrationRetriesConfig"
const NetworkRegistrationRetryDelayConfig ConfigType = "NetworkRegistrationRetryDelayConfig"
const SendTimeoutConfig ConfigType = "SendTimeoutConfig"
const VerboseConfig ConfigType = "VerboseConfig"
type DefaultGsmModule ¶
type DefaultGsmModule struct { TotalDeadline time.Time ReadDeadline time.Time WriteDeadline time.Time // contains filtered or unexported fields }
func NewGsmModule ¶
func NewGsmModule(device string, configs ...Config) (*DefaultGsmModule, error)
NewGsmModule opens a serial connection to the provided serial device.
func (*DefaultGsmModule) CloseGsmModule ¶
func (g *DefaultGsmModule) CloseGsmModule()
CloseGsmModule closes the serial connection to the GSM module.
func (*DefaultGsmModule) CloseTcpConnection ¶
func (g *DefaultGsmModule) CloseTcpConnection() error
CloseTcpConnection closes the current connection.
func (*DefaultGsmModule) CommandEchoOff ¶ added in v0.0.13
func (g *DefaultGsmModule) CommandEchoOff() error
CommandEchoOff turns off the echoing of commands
func (*DefaultGsmModule) CommandEchoOn ¶ added in v0.0.13
func (g *DefaultGsmModule) CommandEchoOn() error
CommandEchoOn turns on the echoing of commands
func (*DefaultGsmModule) GetLocalIPAddress ¶
func (g *DefaultGsmModule) GetLocalIPAddress() (string, error)
GetLocalIPAddress
func (*DefaultGsmModule) GetStatus ¶
func (g *DefaultGsmModule) GetStatus() (bool, error)
GetStatus determines the status of the module.
func (*DefaultGsmModule) Init ¶
func (g *DefaultGsmModule) Init() error
Init checks the GSM module status, and switches it on if it was off; It then waits for network registration.
func (*DefaultGsmModule) IsConnected ¶
func (g *DefaultGsmModule) IsConnected() (bool, error)
IsConnected determines if a connection is currently established.
func (*DefaultGsmModule) OpenTcpConnection ¶
func (g *DefaultGsmModule) OpenTcpConnection(address string) error
OpenTcpConnection attempts to establish a new connection to the given IP and port.
func (*DefaultGsmModule) ReadData ¶
func (g *DefaultGsmModule) ReadData() (byte, error)
func (*DefaultGsmModule) SendRawTcpData ¶
func (g *DefaultGsmModule) SendRawTcpData(data []byte) (int, error)
SendRawTcpData sends the given data to to open connection.
func (*DefaultGsmModule) Shutdown ¶
func (g *DefaultGsmModule) Shutdown() error
Shutdown switches the GSM module off.
func (*DefaultGsmModule) SwitchGNSSPowerOff ¶ added in v0.2.0
func (g *DefaultGsmModule) SwitchGNSSPowerOff() error
func (*DefaultGsmModule) SwitchGNSSPowerOn ¶ added in v0.2.0
func (g *DefaultGsmModule) SwitchGNSSPowerOn() error
func (*DefaultGsmModule) ToggleModule ¶
func (g *DefaultGsmModule) ToggleModule() error
ToggleModule toggles the PWRKEY pin of the module.
func (*DefaultGsmModule) WaitForNetworkRegistration ¶
func (g *DefaultGsmModule) WaitForNetworkRegistration() error
WaitForNetworkRegistration waits for the GSM module to be registered with the network.
type Error ¶ added in v0.2.0
type Error struct {
Data interface{}
}
Error represents an arbitrary error value returned by a JSON-RPC request.
type MaxBytesErr ¶ added in v0.2.0
type MaxBytesErr struct { }
func (MaxBytesErr) Error ¶ added in v0.2.0
func (e MaxBytesErr) Error() string
type NetworkRegistrationRetries ¶
type NetworkRegistrationRetries int
func (NetworkRegistrationRetries) Default ¶
func (NetworkRegistrationRetries) Default() interface{}
func (NetworkRegistrationRetries) Type ¶
func (NetworkRegistrationRetries) Type() ConfigType
func (NetworkRegistrationRetries) Value ¶
func (c NetworkRegistrationRetries) Value() interface{}
type NetworkRegistrationRetryDelay ¶
func (NetworkRegistrationRetryDelay) Default ¶
func (NetworkRegistrationRetryDelay) Default() interface{}
func (NetworkRegistrationRetryDelay) Type ¶
func (NetworkRegistrationRetryDelay) Type() ConfigType
func (NetworkRegistrationRetryDelay) Value ¶
func (c NetworkRegistrationRetryDelay) Value() interface{}
type NetworkRegistrationStatus ¶
type NetworkRegistrationStatus string
const NotRegistered NetworkRegistrationStatus = "0"
const RegisteredHome NetworkRegistrationStatus = "1"
const RegisteredRoaming NetworkRegistrationStatus = "5"
const RegistrationDenied NetworkRegistrationStatus = "3"
const TryingToRegister NetworkRegistrationStatus = "2"
const UnknownRegistrationError NetworkRegistrationStatus = "4"
type NotReadyErr ¶
type NotReadyErr struct { }
func (NotReadyErr) Error ¶
func (e NotReadyErr) Error() string
type ResponseMessage ¶
type ResponseMessage string
const AlreadyConnectedResponse ResponseMessage = "ALREADY CONNECT"
const CloseOkResponse ResponseMessage = "CLOSE OK"
const ConnectFailedResponse ResponseMessage = "CONNECT FAIL"
const ConnectOkResponse ResponseMessage = "CONNECT OK"
const ErrorResponse ResponseMessage = "ERROR"
const OkResponse ResponseMessage = "OK"
const SendOkResponse ResponseMessage = "SEND OK"
const StateConnectOkResponse ResponseMessage = "STATE: CONNECT OK"
const StateTcpClosedResponse ResponseMessage = "STATE: TCP CLOSED"
type SendTimeout ¶ added in v0.0.6
func (SendTimeout) Default ¶ added in v0.0.6
func (SendTimeout) Default() interface{}
func (SendTimeout) Type ¶ added in v0.0.6
func (SendTimeout) Type() ConfigType
func (SendTimeout) Value ¶ added in v0.0.6
func (c SendTimeout) Value() interface{}
type TimedOutErr ¶
type TimedOutErr struct { }
func (TimedOutErr) Error ¶
func (e TimedOutErr) Error() string