Skip to content

Latest commit

 

History

History
63 lines (50 loc) · 2.64 KB

README.md

File metadata and controls

63 lines (50 loc) · 2.64 KB

cablemodemutil

PkgGoDev Build Tests Lint CodeQL Go Report Card

A go library for interfacing with Cable Modems.

This currently only works (and has been tested with) an Arris S33 Cable Modem. If you would like to add support for other cable modems, please file an Issue or submit a pull request with details for further discussion.

If you're looking for a command-line interface to use this library, please see cablemodemcli.

Example usage

package main

import (
  "fmt"
  "os"

  "github.com/tuxdude/cablemodemutil"
)

func main() {
  host := "192.168.100.1"
  protocol := "https"
  user := "admin"
  pass := "password"

  // Use the cable modem information to build the retriever.
  input := cablemodemutil.RetrieverInput{
    Host:           host,
    Protocol:       protocol,
    SkipVerifyCert: true,
    Username:       user,
    ClearPassword:  pass,
  }
  cm := cablemodemutil.NewStatusRetriever(&input)

  // This is a synchronous call to retrieve the status and takes
  // anywhere from two to ten seconds on average.
  st, err := cm.Status()
  if err != nil {
    fmt.Fprintf(os.Stderr, "Error: %s\n", err)
    os.Exit(1)
  }

  // Access the status information.
  // More detailed fields are available in the status, please
  // refer to the documentation.
  fmt.Printf("Model: %s\n", st.Info.Model)
  fmt.Printf("Serial Number: %s\n", st.Info.SerialNumber)
  fmt.Printf("MAC Address: %s\n", st.Info.MACAddress)
  fmt.Printf("Connection Established Timestamp: %s\n", st.Connection.EstablishedAt)
  fmt.Printf("Firmaware version: %s\n", st.Software.FirmwareVersion)
  fmt.Printf("DOCSIS Version: %s\n", st.Software.DOCSISSpecVersion)
  fmt.Printf("Downstream Channel: %d Hz\n", st.Startup.Downstream.FrequencyHZ)

  os.Exit(0)
}