modem

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLogoutError

func IsLogoutError(err error) bool

IsLogoutError checks if an error is a LogoutError

Types

type CableModem

type CableModem struct {
	HWVersion       string `json:"hw_version"`
	Vendor          string `json:"vendor"`
	BOOTVersion     string `json:"boot_version"`
	CoreVersion     string `json:"core_version"`
	Model           string `json:"model"`
	ProductType     string `json:"product_type"`
	FlashPart       string `json:"flash_part"`
	DownloadVersion string `json:"download_version"`
}

CableModem represents the cable modem hardware information

type Channel

type Channel struct {
	ChannelID   string `json:"channel_id"`
	LockStatus  string `json:"lock_status"`
	Frequency   string `json:"frequency"`
	SNR         string `json:"snr,omitempty"` // Only for downstream
	PowerLevel  string `json:"power_level"`
	Modulation  string `json:"modulation"`
	SymbolRate  string `json:"symbol_rate,omitempty"`  // Only for upstream
	ChannelType string `json:"channel_type,omitempty"` // Only for upstream
}

Channel represents a downstream or upstream channel

type Client

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

Client represents the modem HTTP client

func NewClient

func NewClient(baseURL string) *Client

NewClient creates a new modem client

func (*Client) FetchModemInfo

func (c *Client) FetchModemInfo(ctx context.Context) (*ModemInfo, error)

FetchModemInfo fetches and parses modem information

func (*Client) Login

func (c *Client) Login(ctx context.Context) error

Login performs authentication with the modem

func (*Client) LoginAndFetch

func (c *Client) LoginAndFetch(ctx context.Context) (*ModemInfo, error)

LoginAndFetch performs login and then fetches modem information

func (*Client) Logout

func (c *Client) Logout() error

Logout clears the session and removes stored cookies

func (*Client) SetCredentials

func (c *Client) SetCredentials(username, password string)

SetCredentials sets the username and password for authentication

type Database

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

Database represents the SQLite database for storing modem history

func NewDatabase

func NewDatabase() (*Database, error)

NewDatabase creates a new database connection and initializes tables

func (*Database) Close

func (d *Database) Close() error

Close closes the database connection

func (*Database) EndSession

func (d *Database) EndSession(sessionID int64) error

EndSession marks a session as ended

func (*Database) ExportData

func (d *Database) ExportData(mode ExportMode, sessionID int64) (*ExportResult, error)

ExportData exports data based on the specified mode

func (*Database) StartSession

func (d *Database) StartSession() (int64, error)

StartSession creates a new session and returns its ID

func (*Database) StoreModemInfo

func (d *Database) StoreModemInfo(sessionID int64, info *ModemInfo) error

StoreModemInfo stores complete modem information in the database

type DownstreamExport

type DownstreamExport struct {
	Timestamp  time.Time
	SessionID  int64
	ChannelID  string
	LockStatus string
	Frequency  string
	SNR        string
	PowerLevel string
	Modulation string
}

type ErrorChannel

type ErrorChannel struct {
	ChannelID              string `json:"channel_id"`
	UnerroredCodewords     string `json:"unerrored_codewords"`
	CorrectableCodewords   string `json:"correctable_codewords"`
	UncorrectableCodewords string `json:"uncorrectable_codewords"`
}

ErrorChannel represents error codeword information for a channel

type ErrorExport

type ErrorExport struct {
	Timestamp              time.Time
	SessionID              int64
	ChannelID              string
	UnerroredCodewords     string
	CorrectableCodewords   string
	UncorrectableCodewords string
}

type ExportMode

type ExportMode int

ExportMode represents different export modes

const (
	ExportCurrent ExportMode = iota
	ExportSession
	ExportAll
)

type ExportResult

type ExportResult struct {
	Downstream []DownstreamExport
	Upstream   []UpstreamExport
	Errors     []ErrorExport
}

ExportResult holds exported data

type LogoutError

type LogoutError struct {
	Message string
}

LogoutError represents an error when the user is logged out and needs to authenticate

func (LogoutError) Error

func (e LogoutError) Error() string

type ModemInfo

type ModemInfo struct {
	CableModem     CableModem     `json:"cable_modem"`
	Downstream     []Channel      `json:"downstream"`
	Upstream       []Channel      `json:"upstream"`
	ErrorCodewords []ErrorChannel `json:"error_codewords"`
	LastUpdated    time.Time      `json:"last_updated"`
}

ModemInfo represents the complete modem information

type StoredCookie

type StoredCookie struct {
	Name     string    `json:"name"`
	Value    string    `json:"value"`
	Domain   string    `json:"domain"`
	Path     string    `json:"path"`
	Expires  time.Time `json:"expires"`
	Secure   bool      `json:"secure"`
	HttpOnly bool      `json:"httpOnly"`
}

StoredCookie represents a cookie that can be serialized to JSON

type UpstreamExport

type UpstreamExport struct {
	Timestamp   time.Time
	SessionID   int64
	ChannelID   string
	LockStatus  string
	Frequency   string
	SymbolRate  string
	PowerLevel  string
	Modulation  string
	ChannelType string
}

Jump to

Keyboard shortcuts

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