go_at

package module
Version: v0.0.0-...-e3f82b8 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: MIT Imports: 5 Imported by: 0

README

GO-AT

GoDoc Go Report Card

A way to send AT command or something else to modem.

Develop base huawei mh5000-31

Usage

You can send some at commend that we packed.

package main

import (
   "fmt"

   devices "github.com/JackyCZJ/go-at"
   "github.com/albenik/go-serial/v2"

   huawei "github.com/JackyCZJ/go-at/huawei/mh5000-31"
)

func main() {

   opt := []serial.Option{
       serial.WithDataBits(8),
       serial.WithStopBits(serial.OneStopBit),
       serial.WithBaudrate(devices.BaudRate),
       serial.WithParity(serial.OddParity),
   }
   h := new(huawei.HUAWEI)
   h.Init("/dev/ttyUSB1", opt...)
   res, err := h.HCSQ()
   if err != nil {
       fmt.Println("Got error result:", err)
       return
   }
   for i := range res {
       data, _ := res[i].Serialization()
       fmt.Println(string(data))
   }

}

or send some command.

	opt := []serial.Option{
		serial.WithDataBits(8),
		serial.WithStopBits(serial.OneStopBit),
		serial.WithBaudrate(devices.BaudRate),
		serial.WithParity(serial.OddParity),
	}
	h := new(huawei.HUAWEI)
	h.Init("/dev/ttyUSB1", opt...)
	h.Cmd("...some command")

Documentation

Index

Constants

View Source
const BaudRate = 115200

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Name     string
	Port     *serial.Port
	PortName string
	Result   func(str string) (bool, error)
	Opt      []serial.Option
	*sync.Mutex
}

func (*Device) Cmd

func (d *Device) Cmd(command string) (result string, err error)

Cmd send command to devices and return result when result contains ok.

func (*Device) Connect

func (d *Device) Connect() (*serial.Port, error)

Connect : Connect to devices with configure.

func (*Device) SetPortName

func (d *Device) SetPortName(portName string)

SetPortName ,default will be /dev/ttyUSB1

type HCSQs

type HCSQs struct {
	Sysmode string
	Rssi    string `json:"rssi,omitempty"`
	Rsrp    string `json:"rsrp,omitempty"`
	Ecio    string `json:"ecio,omitempty"`
	Sinr    string `json:"sinr,omitempty"`
	Rsrq    string `json:"rsrq,omitempty"`
	Rscp    string `json:"rscp,omitempty"`
}

type Modem

type Modem interface {
	//Get Devices info
	DeviceInfo() (Product, error)
	//Query Signal strength
	SignalStrength() ([]HCSQs, error)
	//What Network provider now?
	CurrentNetwork() (string, error)
	//is it register to operator
	IsRegistered() bool
	//iS NSA or SA?
	IsNSA() bool
	//Ipv4 or ipv6 and it's addr
	PDPAddr() (net.IP, error)
	//Dial operator
	Dial() error

	/*Pin management*/
	//PinLockStatus Query pin lock status
	PinLockStatus() bool
}

Todo: ⬇️ ⬇️ ⬇️

type Product

type Product struct {
	Manufacturer string
	Model        string
	Revision     string
	IMEI         string
	GCAP         string `json:"+GCAP:"`
}

type SysInfoEx

type SysInfoEx struct {
	SrvStatus  int `json:"srv_status"`
	SrvDomain  int `json:"srv_domain"`
	RoamStatus int `json:"roam_status"`
	SimState   int `json:"sim_state"`
	//Lock state unsupported now
	LockState   int    `json:"lock_state,omitempty"`
	SysMode     int    `json:"sysmode"`
	SysModeName string `json:"sysmode_name"`
	SubMode     int    `json:"submode"`
	SubModeName string `json:"submode_name"`
}

Directories

Path Synopsis
huawei
mh5000-31
utils.go: Convert to human readable format
utils.go: Convert to human readable format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL