peplink

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

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

Go to latest
Published: Sep 4, 2023 License: MIT Imports: 9 Imported by: 0

README

The API client for the Peplink devices Information could be queried from the device via the HTTP API or via SNMP

References

supported HTTP endpoints

  • /api/auth.token.grant
  • /api/info.frw.version
  • /api/status.wan.connection

supported SNMP OIDs

  • serial number

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BandObj

type BandObj struct {
	Name   string    `json:"name"`   // Band Name
	Signal SignalObj `json:"signal"` // Signal information
}

BandObj represents cellular band information.

type BandwidthAllowanceMonitorObj

type BandwidthAllowanceMonitorObj struct {
	Enable  bool `json:"enable"`
	HasSMTP bool `json:"hasSmtp"`
}

type CarrierObj

type CarrierObj struct {
	Name    string `json:"name"`    // Carrier name
	Country string `json:"country"` // Carrier country (field does not appear if lite = yes)
}

CarrierObj represents carrier information.

type CellTowerObj

type CellTowerObj struct {
	CellID      int `json:"cellId"`
	CellPlmn    int `json:"cellPlmn"`
	CellUtranID int `json:"cellUtranId"`
	Tac         int `json:"tac"`
}

CellTowerObj represents cell tower information.

type Client

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

Client for the https://www.peplink.com/ic2-api-doc

func NewClient

func NewClient(ctx context.Context, opts ...Option) (*Client, error)

NewClient creates a new Peplink Client and authenticates against the API Runs token update process in the background

func (*Client) FirmwareVersion

func (c *Client) FirmwareVersion(ctx context.Context) (string, error)

Returns the firmware version of the device

func (*Client) StatusWanConnection

func (c *Client) StatusWanConnection(ctx context.Context) ([]WanStatus, error)

StatusWanConnection returns the status of the WAN connections

type GobiObj

type GobiObj struct {
	RoamingStatus RoamingObj    `json:"roamingStatus"` // Roaming status information
	Network       string        `json:"network"`       // Network name (deprecated in fw8.0.1)
	MobileType    string        `json:"mobileType"`    // Network name (use "mobileType" in fw8.0.1 or later)
	ModulePowerOn bool          `json:"modulePowerOn"` // TODO: doc
	SIM           []SIMGroupObj `json:"-"`
	// SIM information. Extracted not from JSON because contains order field
	RemoteSIM               RemoteSIMObj            `json:"remoteSim,omitempty"`     // Remote SIM information (only when remote SIM is enabled)
	SpeedFusionConnect5gLTE SpeedFusionConnect5gLTE `json:"speedfusionConnect5gLte"` // TODO: doc
	Carrier                 CarrierObj              `json:"carrier"`                 // Carrier information
	CarrierAggregation      bool                    `json:"carrierAggregation"`      // TODO: doc
	SignalLevel             int                     `json:"signalLevel"`             // Signal Level [0,5]
	RAT                     []RatObj                `json:"rat"`                     // Radio Access Technology (RAT) information
	IMEI                    string                  `json:"imei"`                    // International Mobile Equipment Identity (IMEI)
	MEID                    MEIDObj                 `json:"meid"`                    // Hex and Dec value of Mobile Equipment Identifier (MEID)
	ESN                     string                  `json:"esn"`                     // Electronic Serial Number (ESN)
	DataTechnology          string                  `json:"dataTechnology"`          // Data Technology
	MCC                     string                  `json:"mcc"`                     // Mobile Country Code (MCC)
	MNC                     string                  `json:"mnc"`                     // Mobile Network Code (MNC)
	CellTower               CellTowerObj            `json:"cellTower"`               // Cell Tower information
	Model                   string                  `json:"model"`
	Firmware                string                  `json:"firmware"`
}

GobiObj represents Gobi network information.

type MEIDObj

type MEIDObj struct {
	Hex string `json:"hex"` // MEID value in HEX
	Dec string `json:"dec"` // MEID value in DEC
}

MEIDObj represents Mobile Equipment Identifier (MEID) information.

type ModemObj

type ModemObj struct {
	Name         string     `json:"name"`                 // Modem adaptor name
	VendorID     int        `json:"vendorId"`             // Modem adaptor vendor ID
	ProductID    int        `json:"productId"`            // Modem adaptor product ID
	Manufacturer string     `json:"manufacturer"`         // Modem adaptor manufacturer
	Carrier      CarrierObj `json:"carrier"`              // Carrier Information
	SignalLevel  int        `json:"signalLevel"`          // Signal level [0,5]
	Network      string     `json:"network"`              // Network name (deprecated in fw8.0.1)
	MobileType   string     `json:"mobileType"`           // Network name (use "mobileType" in fw8.0.1 or later)
	IMSIStr      string     `json:"imsi,omitempty"`       // International Mobile Subscriber Identity (IMSI)
	ICCID        []string   `json:"iccid,omitempty"`      // Integrated Circuit Card Identity (ICCID)
	ESN          []string   `json:"esn,omitempty"`        // Electronic Serial Number (ESN)
	MTN          []string   `json:"mtn,omitempty"`        // Mobile Telecommunications Network (MTN)
	APN          string     `json:"apn,omitempty"`        // APN
	Username     string     `json:"username,omitempty"`   // Username for APN
	Password     string     `json:"password,omitempty"`   // Password for APN
	DialNumber   string     `json:"dialNumber,omitempty"` // Dial number for APN
	Band         []BandObj  `json:"band"`                 // Cellular band information
	Gobi         GobiObj    `json:"gobi"`                 // Gobi network information
}

ModemObj represents modem adaptor information.

type Option

type Option func(*options) error

func WithHTTPBasicClientID

func WithHTTPBasicClientID(id string) Option

func WithHTTPBasicClientSecret

func WithHTTPBasicClientSecret(secret string) Option

func WithHTTPBasicURL

func WithHTTPBasicURL(url string) Option

func WithSNMPAddress

func WithSNMPAddress(address string) Option

func WithSNMPCommunity

func WithSNMPCommunity(community string) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type RatObj

type RatObj struct {
	Name string    `json:"name"` // RAT Name
	Band []BandObj `json:"band"` // Band information
}

RatObj represents Radio Access Technology (RAT) information.

type RemoteSIMObj

type RemoteSIMObj struct {
	IMSI         string `json:"imsi"`               // IMSI
	SerialNumber string `json:"serialNumber"`       // Serial Number
	Slot         int    `json:"slot"`               // Number of slot
	AutoApp      bool   `json:"autoApp,omitempty"`  // Indicates if APN, Username, and Password fields are auto-detect
	APN          string `json:"apn,omitempty"`      // APN (only available in fw8.1.1 or later)
	Username     string `json:"username,omitempty"` // Username for APN (only available in fw8.1.1 or later)
	Password     string `json:"password,omitempty"` // Password for APN (only available in fw8.1.1 or later)
}

RemoteSIMObj represents remote SIM information.

type RoamingObj

type RoamingObj struct {
	Code    int    `json:"code"`    // Roaming Status Code {0, 1, 2}
	Message string `json:"message"` // Readable Roaming Status Code and message relation
}

RoamingObj represents roaming status information.

type SIMGroupObj

type SIMGroupObj struct {
	Active                    bool                         `json:"active"`
	SimCardDetected           bool                         `json:"simCardDetected"`
	Imsi                      string                       `json:"imsi"`
	Iccid                     string                       `json:"iccid"`
	AutoApn                   bool                         `json:"autoApn"`
	Apn                       string                       `json:"apn"`
	BandwidthAllowanceMonitor BandwidthAllowanceMonitorObj `json:"bandwidthAllowanceMonitor"`
}

SIMGroupObj represents a group of SIM cards.

type SIMObj

type SIMObj struct {
	Status   string `json:"status"`             // SIM card status {In Use, SIM Card Detected, No SIM Card Detected}
	Active   bool   `json:"active"`             // SIM card active status
	APN      string `json:"apn,omitempty"`      // APN
	Username string `json:"username,omitempty"` // Username for APN
	Password string `json:"password,omitempty"` // Password for APN
	IMSI     string `json:"imsi,omitempty"`     // International Mobile Subscriber Identity (IMSI)
	ICCID    string `json:"iccid,omitempty"`    // Integrated Circuit Card Identity (ICCID)
	MTN      string `json:"mtn,omitempty"`      // Mobile Telecommunications Network (MTN)
}

SIMObj represents SIM card information.

type Signal

type Signal struct {
	RSSI     int     `json:"rssi,omitempty"`     // Received Signal Strength Indicator (RSSI), only appear in Gobi and Modem
	SINR     float64 `json:"sinr,omitempty"`     // Signal to Interference plus Noise Ratio (SINR), only appear in Gobi and Modem
	SNR      float64 `json:"snr,omitempty"`      // Signal-to-noise ratio (SNR), only appear in Gobi and has value
	ECIO     float64 `json:"ecio,omitempty"`     // Energy to Interference Ratio (Ec/Io), only appear in Gobi and has value
	RSRP     float64 `json:"rsrp,omitempty"`     // Reference Signal Received Power (RSRP), only appear in Gobi and Modem
	RSRQ     float64 `json:"rsrq,omitempty"`     // Reference Signal Received Quality (RSRQ), only appear in Gobi
	Strength float64 `json:"strength,omitempty"` // Wi-Fi signal strength, only appear in Wifi
}

Signal represents the signal information.

type SignalObj

type SignalObj struct {
	RSSI     int     `json:"rssi,omitempty"`     // Received Signal Strength Indicator (RSSI)
	SINR     float64 `json:"sinr,omitempty"`     // Signal to Interference plus Noise Ratio (SINR)
	SNR      float64 `json:"snr,omitempty"`      // Signal-to-noise ratio (SNR)
	ECIO     float64 `json:"ecio,omitempty"`     // Energy to Interference Ratio (Ec/Io)
	RSRP     float64 `json:"rsrp,omitempty"`     // Reference Signal Received Power (RSRP)
	RSRQ     float64 `json:"rsrq,omitempty"`     // Reference Signal Received Quality (RSRQ)
	Strength float64 `json:"strength,omitempty"` // Wi-Fi signal strength
}

SignalObj represents signal information.

type SpeedFusionConnect5gLTE

type SpeedFusionConnect5gLTE struct {
	Active bool   `json:"active"`
	Iccid  string `json:"iccid"`
}

TODO: doc

type WanStatus

type WanStatus struct {
	// Name of the WAN connection
	Name string `json:"name"`
	// LED color for UI { empty, gray, red, yellow, green, flash }
	StatusLed string `json:"statusLed"`
	// WAN port is performing WAN as LAN or not
	AsLan bool `json:"asLan"`
	//WAN is enabled or not
	Enable bool `json:"enable"`
	// WAN is locked or not
	Locked bool `json:"locked"`
	// Only appear if Connection is scheduled and currently off
	ScheduledOff bool `json:"scheduledOff"`
	// WAN status message
	Message string `json:"message"`
	// WAN connection uptime in seconds
	Uptime int `json:"uptime"`
	// WAN connection type
	// For cellular WAN
	// In fw8.0.1 or later, it will return “cellular”.
	// Before fw8.0.1, it will return “gobi”
	// { modem, wireless, gobi, cellular, ipsec, adsl, ethernet }
	Type string `json:"type"`

	// For cellular WAN
	// In fw8.0.1 or later, it will return “cellular”.
	// Before fw8.0.1, it will return “gobi”
	// { modem, wireless, gobi, cellular, ipsec, adsl, ethernet }
	VirtualType string `json:"virtualType"`
	// Priority of the WAN. The field will not appear if the WAN is disabled
	Priority int `json:"priority"`
	//Group set of the WAN connection
	Groupset int `json:"groupset"`
	// IP address
	Ip string `json:"ip"`
	// Subnet mask. The field will not appear if ip is not exist or lite=yes
	Mask int `json:"mask"`
	// Gateway. The field will not appear if ip is not exist or lite=yes
	Gateway string `json:"gateway"`
	// Connection method, DHCP or Static IP. The field will not appear if lite=yes
	//{ dhcp static }
	Method string `json:"method"`
	// Connection mode. The field will not appear if lite=yes
	// { NAT, IP Forwarding }
	Mode string `json:"mode"`
	// DNS Server list. The field will not appear if lite=yes
	Dns []string `json:"dns"`
	// Additional IP address list. The field will not appear if lite=yes
	AditionalIp []string `json:"aditionalIp"`
	// MTU value. The field will not appear if auto or lite=yes
	// [576, 9000]
	MTU int `json:"mtu"`
	// MSS value. The field will not appear if auto or lite=yes
	// [536, 8960]
	MSS int `json:"mss"`
	// MAC address. The field will not appear if lite=yes
	Mac string `json:"mac"`
	// WAN connection detail for wireless. The field will only appear if type is wifi
	Wireless WifiInfo `json:"wireless"`
	// WAN connection detail for modem. The field will only appear if type is modem
	Modem ModemObj `json:"modem"`
	// WAN connection detail for gobi. The field will only appear if type is cellular
	Cellular GobiObj `json:"cellular"`
	//WAN connection detail for gobi. The field will only appear if type is gob NOTE: This object is deprecated in firmware 8.0.1.
	Gobi GobiObj `json:"gobi"`
}

type WifiInfo

type WifiInfo struct {
	SSID   string `json:"ssid"`   // SSID of the Wifi. The field will not appear if lite=yes
	BSSID  string `json:"bssid"`  // BSSID. The field will not appear if lite=yes
	Signal Signal `json:"signal"` // Signal information
}

WifiInfo represents information about Wi-Fi networks.

Jump to

Keyboard shortcuts

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