tmhi

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 11 Imported by: 0

README

tmhi-gateway

Go Reference codecov CI Go Report Card FOSSA Status

Go library for interacting with T-Mobile Home Internet gateways (Nokia and Arcadyan models).

Features

  • Authenticate with Nokia and Arcadyan gateways
  • Reboot gateway devices
  • Retrieve signal strength information
  • Check gateway status
  • Make custom HTTP requests to gateway APIs

Installation

go get github.com/hugoh/tmhi-gateway

Quick Start

package main

import (
    "fmt"
    "time"

    gateway "github.com/hugoh/tmhi-gateway"
)

func main() {
    cfg := &gateway.GatewayConfig{
        IP:       "192.168.12.1",
        Username: "admin",
        Password: "your-password",
        Timeout:  5 * time.Second,
    }

    gw := gateway.NewArcadyanGateway(cfg)

    result, err := gw.Login()
    if err != nil {
        panic(err)
    }

    fmt.Println("Logged in:", result.Success)
}

Supported Gateways

  • Nokia (NewNokiaGateway(cfg))
  • Arcadyan (NewArcadyanGateway(cfg))

API

Gateway Interface

All gateway implementations satisfy the Gateway interface:

type Gateway interface {
    Login() (*LoginResult, error)
    Reboot() error
    Request(method, path string) (*InfoResult, error)
    Info() (*InfoResult, error)
    Status() (*StatusResult, error)
    Signal() (*SignalResult, error)
}
Response Types
  • LoginResult - Authentication result with token/session info
  • StatusResult - Gateway status check result
  • SignalResult - Signal strength information (4G/5G metrics)
  • InfoResult - Gateway information response

Development

Prerequisites
  • mise (task runner and tool manager)
Running Tests
# Run all tests
mise test

# Run CI checks (lint + test + coverage)
mise ci

License

MIT License - see LICENSE for details.

FOSSA Status

Documentation

Overview

Package tmhi provides gateway communication for TMHI modems.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAuthentication indicates an authentication failure.
	ErrAuthentication = errors.New("could not authenticate")
	// ErrNotImplemented indicates an unsupported operation.
	ErrNotImplemented = errors.New("command not implemented")
	// ErrRebootFailed indicates a reboot operation failed.
	ErrRebootFailed = errors.New("reboot failed")
	// ErrSignalFailed indicates a signal operation failed.
	ErrSignalFailed = errors.New("signal failed")
)

Sentinel errors for gateway operations.

Functions

func NewAuthError

func NewAuthError(status int, message string) error

NewAuthError creates a new AuthenticationError.

func NewGatewayError

func NewGatewayError(op string, status int, message string, err error) error

NewGatewayError creates a new GatewayError.

Types

type ArcadyanGateway

type ArcadyanGateway struct {
	*GatewayCommon
	// contains filtered or unexported fields
}

ArcadyanGateway implements Gateway for Arcadyan-based T-Mobile gateways.

func NewArcadyanGateway

func NewArcadyanGateway(cfg *GatewayConfig) *ArcadyanGateway

NewArcadyanGateway creates a new Arcadyan gateway instance.

func (*ArcadyanGateway) Info

func (a *ArcadyanGateway) Info(ctx context.Context) (*InfoResult, error)

Info retrieves gateway information.

func (*ArcadyanGateway) Login

func (a *ArcadyanGateway) Login(ctx context.Context) error

Login authenticates with the Arcadyan gateway.

func (*ArcadyanGateway) Reboot

func (a *ArcadyanGateway) Reboot(ctx context.Context) error

Reboot restarts the Arcadyan gateway.

func (*ArcadyanGateway) Request

func (a *ArcadyanGateway) Request(ctx context.Context, method, path string) (*InfoResult, error)

Request makes an HTTP request to the gateway.

func (*ArcadyanGateway) Signal

func (a *ArcadyanGateway) Signal(ctx context.Context) (*SignalResult, error)

Signal retrieves signal strength information.

func (*ArcadyanGateway) Status

func (a *ArcadyanGateway) Status(ctx context.Context) (*StatusResult, error)

Status checks the gateway connection status.

type AuthenticationError

type AuthenticationError struct {
	Status  int
	Message string
}

AuthenticationError represents an authentication failure with the gateway.

func (*AuthenticationError) Error

func (e *AuthenticationError) Error() string

func (*AuthenticationError) Is

func (*AuthenticationError) Is(target error) bool

Is checks if the target error matches ErrAuthentication.

func (*AuthenticationError) Unwrap

func (*AuthenticationError) Unwrap() error

type FiveGSignal

type FiveGSignal struct {
	SignalData

	AntennaUsed string
	GNBID       int
}

FiveGSignal contains 5G signal information.

type FourGSignal

type FourGSignal struct {
	SignalData

	ENBID int
}

FourGSignal contains 4G signal information.

type Gateway

type Gateway interface {
	Login(ctx context.Context) error
	Reboot(ctx context.Context) error
	Request(ctx context.Context, method, path string) (*InfoResult, error)
	Info(ctx context.Context) (*InfoResult, error)
	Status(ctx context.Context) (*StatusResult, error)
	Signal(ctx context.Context) (*SignalResult, error)
}

Gateway defines the interface for T-Mobile gateway implementations.

type GatewayCommon

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

GatewayCommon provides shared functionality for gateway implementations.

func NewGatewayCommon

func NewGatewayCommon(cfg *GatewayConfig) *GatewayCommon

NewGatewayCommon creates a new GatewayCommon with the given configuration.

func (*GatewayCommon) CheckWebInterface

func (gc *GatewayCommon) CheckWebInterface(ctx context.Context) *StatusResult

CheckWebInterface checks if the gateway web interface is accessible.

type GatewayConfig

type GatewayConfig struct {
	IP       string
	Username string
	Password string
	Timeout  time.Duration
	Retries  int
	DryRun   bool
	Debug    bool
}

GatewayConfig holds configuration values needed for gateway client operations.

type GatewayError

type GatewayError struct {
	Op         string
	Err        error
	HTTPStatus int
	Message    string
}

GatewayError represents a gateway operation failure.

func (*GatewayError) Error

func (e *GatewayError) Error() string

func (*GatewayError) Unwrap

func (e *GatewayError) Unwrap() error

type GenericSignalInfo

type GenericSignalInfo struct {
	APN          string
	HasIPv6      bool
	Registration string
	Roaming      bool
}

GenericSignalInfo contains generic signal information.

type InfoResult

type InfoResult struct {
	Data        map[string]any
	Raw         []byte
	ContentType string
	StatusCode  int
}

InfoResult contains gateway information response.

func (*InfoResult) String

func (r *InfoResult) String() string

type NokiaGateway

type NokiaGateway struct {
	*GatewayCommon
	// contains filtered or unexported fields
}

NokiaGateway implements Gateway for Nokia-based T-Mobile gateways.

func NewNokiaGateway

func NewNokiaGateway(cfg *GatewayConfig) *NokiaGateway

NewNokiaGateway creates a new Nokia gateway instance.

func (*NokiaGateway) Info

Info is not implemented for Nokia gateway.

func (*NokiaGateway) Login

func (n *NokiaGateway) Login(ctx context.Context) error

Login authenticates with the Nokia gateway.

func (*NokiaGateway) Reboot

func (n *NokiaGateway) Reboot(ctx context.Context) error

Reboot restarts the Nokia gateway.

func (*NokiaGateway) Request

func (*NokiaGateway) Request(_ context.Context, _, _ string) (*InfoResult, error)

Request is not implemented for Nokia gateway.

func (*NokiaGateway) Signal

Signal is not implemented for Nokia gateway.

func (*NokiaGateway) Status

func (n *NokiaGateway) Status(ctx context.Context) (*StatusResult, error)

Status checks the gateway connection status.

type SignalData

type SignalData struct {
	Bands []string
	Bars  float64
	CID   int
	RSRP  int
	RSRQ  int
	RSSI  int
	SINR  int
}

SignalData contains signal metrics.

type SignalResult

type SignalResult struct {
	FourG   *FourGSignal
	FiveG   *FiveGSignal
	Generic GenericSignalInfo
}

SignalResult contains complete signal information.

type StatusResult

type StatusResult struct {
	WebInterfaceUp bool
	StatusCode     int
	Registration   string
	Error          error
}

StatusResult contains status check result.

Jump to

Keyboard shortcuts

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