network

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CarrierProfileAuto    CarrierProfile = 0
	CarrierProfileNone                   = 1
	CarrierProfileATT                    = 2
	CarrierProfileVerizon                = 3
)

define value carrier profiles

View Source
const (
	TechnologyLTEMWithNBIOTFallback Technology = 0
	TechnologyNBIOTWithLTEMFallback            = 1
	TechnologyLTEM                             = 2
	TechnologyNBIOT                            = 3
)

define valid technologies

View Source
const (
	ModeTransparent   Mode = 0
	ModeAPI                = 1
	ModeAPIWithEscape      = 2
	ModePython             = 4
	ModeBypass             = 5
)

define valid modes

Variables

This section is empty.

Functions

This section is empty.

Types

type CarrierProfile

type CarrierProfile int

CarrierProfile is used to lock modem to a particular carrier

func (CarrierProfile) String

func (cp CarrierProfile) String() string

type Mode

type Mode int

Mode defines operating mode

func (Mode) String

func (m Mode) String() string

type Modem

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

Modem is a typethat defines a modem

func NewModem

func NewModem(port io.ReadWriter, apn string, debug bool) *Modem

NewModem creates a new modem type

port should be a respreader

func (*Modem) Cmd

func (m *Modem) Cmd(cmd string) (string, error)

Cmd a command to modem and read response retry 3 times

func (*Modem) Configure

func (m *Modem) Configure() error

Configure is used to set up the modem

func (*Modem) GetInfo

func (m *Modem) GetInfo() (ret ModemInfo, err error)

GetInfo is used to get static info from modem

func (*Modem) GetSettings

func (m *Modem) GetSettings() (ret ModemSettings, err error)

GetSettings are used to fetch the modem settings

func (*Modem) GetState

func (m *Modem) GetState() (ret ModemState, err error)

GetState is used to return modem state

func (*Modem) HTTPGet

func (m *Modem) HTTPGet(urlIn string) ([]byte, error)

HTTPGet executes a http get command

func (*Modem) Reset

func (m *Modem) Reset() error

Reset modem

func (*Modem) SetAPN

func (m *Modem) SetAPN() error

SetAPN is used to set the modem APN assumes modem is in command mode

func (*Modem) SetCarrierProfile

func (m *Modem) SetCarrierProfile(profile CarrierProfile) error

SetCarrierProfile updates the carrier profile in the modem

func (*Modem) SetMode

func (m *Modem) SetMode(mode Mode) error

SetMode updates the operating mode

func (*Modem) SetTechnology

func (m *Modem) SetTechnology(tech Technology) error

SetTechnology updates the network technology setting in the modem

func (*Modem) SwitchCmdMode

func (m *Modem) SwitchCmdMode() error

SwitchCmdMode switches the mode modem to command mode try 3 times

func (*Modem) Write

func (m *Modem) Write() error

Write stores changes to non-voltatile memory

type ModemInfo

type ModemInfo struct {
	ICCID     string
	IMEI      string
	FWVersion string
}

ModemInfo describes information about the modem that is fairly static

func (ModemInfo) String

func (mi ModemInfo) String() string

type ModemManager

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

ModemManager is used to configure a modem and manage the modem lifecycle.

func NewModemManager

func NewModemManager(modem *Modem) *ModemManager

NewModemManager constructor

func (*ModemManager) GetState

func (mm *ModemManager) GetState() (ModemState, error)

GetState must be called periodically to process the modem life cycle -- perhaps every 10s

type ModemSettings

type ModemSettings struct {
	APN            string
	CarrierProfile CarrierProfile
	Technology     Technology
	Mode           Mode
}

ModemSettings describe the current modem settings

func (ModemSettings) String

func (ms ModemSettings) String() string

type ModemState

type ModemState struct {
	Detected  bool
	Connected bool
	Operator  string
	Signal    int
}

ModemState describes the current state of the modem

func (ModemState) String

func (ms ModemState) String() string

type State

type State int

State is used to describe the state of a device

const (
	StateNotDetected State = iota
	StateConfigure
	StateDisconnected
	StateConnected
	StateError
)

define valid states

func (State) String

func (s State) String() string

type Technology

type Technology int

Technology is used to define Cat-M or NB-Iot operation

func (Technology) String

func (nt Technology) String() string

Jump to

Keyboard shortcuts

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