Documentation ¶
Overview ¶
Package network contains drivers to manage various network interfaces including modems.
Index ¶
- Constants
- Variables
- func Cmd(port io.ReadWriter, cmd string) (string, error)
- func CmdATI(port io.ReadWriter) (string, error)
- func CmdAt(port io.ReadWriter) error
- func CmdAttach(port io.ReadWriter) error
- func CmdBg96ForceLTE(port io.ReadWriter) error
- func CmdCesq(port io.ReadWriter) (rsrq, rsrp int, err error)
- func CmdCops(port io.ReadWriter) (carrier string, err error)
- func CmdFunFull(port io.ReadWriter) error
- func CmdFunMin(port io.ReadWriter) error
- func CmdGGA(port io.ReadWriter) (string, error)
- func CmdGetFwVersionBG96(port io.ReadWriter) (string, error)
- func CmdGetImei(port io.ReadWriter) (string, error)
- func CmdGetPhoneNum(port io.ReadWriter) (string, error)
- func CmdGetSignal(port io.ReadWriter) (int, int, error)
- func CmdGetSim(port io.ReadWriter) (string, error)
- func CmdGetSimBg96(port io.ReadWriter) (string, error)
- func CmdOK(port io.ReadWriter, cmd string) error
- func CmdQcsq(port io.ReadWriter) (service bool, rssi, rsrp, rsrq int, err error)
- func CmdQspn(port io.ReadWriter) (network string, err error)
- func CmdReboot(port io.ReadWriter) error
- func CmdSetApn(port io.ReadWriter, apn string) error
- func CmdSica(port io.ReadWriter) error
- func GetIP(ifaceName string) (string, error)
- func RsrpValueToDb(value int) float64
- func RsrqValueToDb(value int) float64
- type BG96ScanMode
- type DummyInterface
- type Ethernet
- type Interface
- type InterfaceConfig
- type InterfaceStatus
- type Manager
- type Modem
- type ModemConfig
- type State
Constants ¶
const ( BG96ScanModeUnknown BG96ScanMode = -1 BG96ScanModeAuto = 0 BG96ScanModeGSM = 1 BG96ScanModeLTE = 3 )
valid scan modes
const APNHologram = "hologram"
APNHologram is the APN to use on the Hologram network
const APNKajeet = "kajeet.gw12.vzwentp"
APNKajeet is the APN to use on the Kajeet network
const APNVerizon = "vzwinternet"
APNVerizon is the APN to use on VZ network
Variables ¶
var DebugAtCommands = false
DebugAtCommands can be set to true to debug at commands
var ErrorModemNotDetected = errors.New("No modem detected")
ErrorModemNotDetected is returned if we try an operation and the modem is not detected
Functions ¶
func Cmd ¶
func Cmd(port io.ReadWriter, cmd string) (string, error)
Cmd send a command to modem and read response retry 3 times. Port should be a RespReadWriter.
func CmdBg96ForceLTE ¶
func CmdBg96ForceLTE(port io.ReadWriter) error
CmdBg96ForceLTE forces BG96 modems to use LTE only, (no 2G)
func CmdCesq ¶
func CmdCesq(port io.ReadWriter) (rsrq, rsrp int, err error)
CmdCesq is used to send the AT+CESQ command
func CmdCops ¶
func CmdCops(port io.ReadWriter) (carrier string, err error)
CmdCops is used determine what carrier we are connected to
func CmdFunFull ¶
func CmdFunFull(port io.ReadWriter) error
CmdFunFull sets the modem functionality to full
func CmdFunMin ¶
func CmdFunMin(port io.ReadWriter) error
CmdFunMin sets the modem functionality to min
func CmdGGA ¶
func CmdGGA(port io.ReadWriter) (string, error)
CmdGGA gets GPS information from modem
func CmdGetFwVersionBG96 ¶
func CmdGetFwVersionBG96(port io.ReadWriter) (string, error)
CmdGetFwVersionBG96 gets FW version from BG96 modem
func CmdGetImei ¶
func CmdGetImei(port io.ReadWriter) (string, error)
CmdGetImei gets IMEI # from modem
func CmdGetPhoneNum ¶
func CmdGetPhoneNum(port io.ReadWriter) (string, error)
CmdGetPhoneNum gets phone number from modem
func CmdGetSignal ¶
func CmdGetSignal(port io.ReadWriter) (int, int, error)
CmdGetSignal gets signal strength
func CmdGetSimBg96 ¶
func CmdGetSimBg96(port io.ReadWriter) (string, error)
CmdGetSimBg96 returns SIM for bg96 modems
func CmdOK ¶
func CmdOK(port io.ReadWriter, cmd string) error
CmdOK runs the command and checks for OK response
func CmdQcsq ¶
func CmdQcsq(port io.ReadWriter) (service bool, rssi, rsrp, rsrq int, err error)
CmdQcsq is used to send the AT+QCSQ command
func CmdQspn ¶
func CmdQspn(port io.ReadWriter) (network string, err error)
CmdQspn is used to send the AT+QSPN command
func CmdSetApn ¶
func CmdSetApn(port io.ReadWriter, apn string) error
CmdSetApn is used to set the APN using the GCDCONT command
Types ¶
type BG96ScanMode ¶
type BG96ScanMode int
BG96ScanMode is a type that defines the varios BG96 scan modes
func CmdBg96GetScanMode ¶
func CmdBg96GetScanMode(port io.ReadWriter) (BG96ScanMode, error)
CmdBg96GetScanMode returns the current modem scan mode
type DummyInterface ¶
type DummyInterface struct { }
DummyInterface is an interface that always reports detected/connected
func (*DummyInterface) Configure ¶
func (d *DummyInterface) Configure() (InterfaceConfig, error)
Configure stub
func (*DummyInterface) Enable ¶
func (d *DummyInterface) Enable(en bool) error
Enable or disable interface
func (*DummyInterface) GetStatus ¶
func (d *DummyInterface) GetStatus() (InterfaceStatus, error)
GetStatus return interface status
type Ethernet ¶
type Ethernet struct {
// contains filtered or unexported fields
}
Ethernet implements the Interface interface
func (*Ethernet) Configure ¶
func (e *Ethernet) Configure() (InterfaceConfig, error)
Configure the interface
func (*Ethernet) GetStatus ¶
func (e *Ethernet) GetStatus() (InterfaceStatus, error)
GetStatus returns ethernet interface status
type Interface ¶
type Interface interface { Desc() string Configure() (InterfaceConfig, error) Connect() error GetStatus() (InterfaceStatus, error) Reset() error Enable(bool) error }
Interface is an interface that network drivers implement
type InterfaceConfig ¶
InterfaceConfig contains static information about an interface
type InterfaceStatus ¶
type InterfaceStatus struct { Detected bool Connected bool Operator string Signal int Rsrp int Rsrq int IP string }
InterfaceStatus defines the status of an interface
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is used to configure the network and manage the lifecycle.
func (*Manager) AddInterface ¶
AddInterface adds a network interface to the manager. Interfaces added first have higher priority
func (*Manager) Error ¶
func (m *Manager) Error()
Error is called any time there is a network error after errResetCnt errors are reached, we reset all the interfaces and start over
func (*Manager) Run ¶
func (m *Manager) Run() (State, InterfaceConfig, InterfaceStatus)
Run must be called periodically to process the network life cycle -- perhaps every 10s
type Modem ¶
type Modem struct {
// contains filtered or unexported fields
}
Modem is an interface that always reports detected/connected
func (*Modem) Configure ¶
func (m *Modem) Configure() (InterfaceConfig, error)
Configure modem interface
func (*Modem) GetLocation ¶
GetLocation returns current GPS location
func (*Modem) GetStatus ¶
func (m *Modem) GetStatus() (InterfaceStatus, error)
GetStatus return interface status