om

package
v0.0.0-...-a88e0b3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATUS_OK = "1"
)

Variables

View Source
var (
	DefaultPort = 20300

	DefaultReadTimeout  = 5
	DefaultWriteTimeout = 5
)
View Source
var DefaultCert = "" /* 128-byte string literal not displayed */

DefaultCert OM 协议默认的证书

Functions

func FormatOmPath

func FormatOmPath(path string) string

func NewCertficateRequest

func NewCertficateRequest() *certificateRequest

NewCertficateCommand 创建OM协议的认证指令

func NewFactoryRebootRequest

func NewFactoryRebootRequest() *factoryRequest

func NewFileRequest

func NewFileRequest() *fileRequest

func NewObjectRequest

func NewObjectRequest() *objectRequest

func NewRebootRequest

func NewRebootRequest() *rebootRequest

func NewValueRequest

func NewValueRequest() *valueRequest

func QueryFaultCode

func QueryFaultCode(code string) string

Types

type Class

type Class string

Class 定义OM消息类型的结构

const (
	CLS_NONE         Class = ""
	CLS_NAME         Class = "name"         // NAME 消息
	CLS_VALUE        Class = "value"        // VALUE 消息
	CLS_OBJECT       Class = "object"       // OBJECT 消息
	CLS_CERTIFICATE  Class = "certificate"  // CERTIFICATE 消息
	CLS_NOTIFICATION Class = "notification" // NOTIFICATION 消息
)

func (Class) IsLegal

func (own Class) IsLegal() bool

IsLegal 判断是否为合法的消息类型

func (Class) IsMatchCommand

func (own Class) IsMatchCommand(cmd Command) bool

IsMatchCommand 判断消息类型是否匹配命令

type Client

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

Client 定义OM客户端的数据结构

func NewClient

func NewClient(host string) *Client

NewClient 创建一个OM客户端

func (*Client) Close

func (own *Client) Close() error

Close 关闭OM客户端

func (*Client) ConnectAndAuth

func (own *Client) ConnectAndAuth() (err error)

ConnectAndAuth 连接并认证

func (*Client) Execute

func (own *Client) Execute(cmd any) (Responser, error)

Execute 执行 OM 指令

func (*Client) Send

func (own *Client) Send(req Requester) (Responser, error)

GET 发起 OM 请求

func (*Client) WithCertificate

func (own *Client) WithCertificate(cert string) *Client

WithCertificate 设置OM连接的认证证书

func (*Client) WithPort

func (own *Client) WithPort(port int) *Client

WithPort 指定OM连接的端口

func (*Client) WithReadTimeout

func (own *Client) WithReadTimeout(timeout int) *Client

WithReadTimeout 设置OM连接的读超时时间

func (*Client) WithWriteTimeout

func (own *Client) WithWriteTimeout(timeout int) *Client

WithWriteTimeout 设置OM连接的写超时时间

type Codec

type Codec struct{}

func (Codec) Decode

func (own Codec) Decode(reader io.Reader) ([]byte, error)

DecodeOmHeader 解码 OM 响应的头部,返回响应体的长度

func (Codec) Encode

func (own Codec) Encode(cmd any) ([]byte, error)

Encode 编码 OM 指令

type Command

type Command string

Command 定义OM消息命令的结构

const (
	CMD_NONE Command = ""

	// 请求命令
	CMD_REQ_GET      Command = "get"            // 查询
	CMD_REQ_SET      Command = "set"            // 设置
	CMD_REQ_ADD      Command = "add"            // 添加
	CMD_REQ_DELETE   Command = "delete"         // 删除
	CMD_REQ_REBOOT   Command = "reboot"         // 重启
	CMD_REQ_FACTORY  Command = "factory_reboot" // 重置
	CMD_REQ_UPLOAD   Command = "upload"         // 上传
	CMD_REQ_DOWNLOAD Command = "download"       // 下载

	// 响应命令
	CMD_RESP_GET      Command = "get_rsp"      // 查询
	CMD_RESP_SET      Command = "set_rsp"      // 设置
	CMD_RESP_ADD      Command = "add_rsp"      // 添加
	CMD_RESP_DELETE   Command = "delete_rsp"   // 删除
	CMD_RESQ_REBOOT   Command = "reboot_rsp"   // 重启
	CMD_RESP_UPLOAD   Command = "upload_rsp"   // 上传
	CMD_RESP_DOWNLOAD Command = "download_rsp" // 下载
)

func (Command) IsLegal

func (own Command) IsLegal() bool

IsLegal 判断是否为合法的命令类型

func (Command) IsMatchCommand

func (own Command) IsMatchCommand(cmd Command) bool

func (Command) IsRequestCommand

func (own Command) IsRequestCommand() bool

IsRequestCommand 判断是否为请求命令

func (Command) IsResponseCommand

func (own Command) IsResponseCommand() bool

IsResponseCommand 判断是否为响应命令

type FileType

type FileType string
const (
	UPLOAD_TYPE_1  FileType = "1 Firmware Upgrade Image"
	UPLOAD_TYPE_2  FileType = "2 Web Content"
	UPLOAD_TYPE_3  FileType = "3 Vendor Configuration File"
	UPLOAD_TYPE_13 FileType = "13 Work Order File"
	UPLOAD_TYPE_16 FileType = "16 Dt Firmware Upgrade Uu"
	UPLOAD_TYPE_17 FileType = "17 Dt Firmware Upgrade Hc"

	DOWNLOAD_TYPE_1  FileType = "1 软件包"
	DOWNLOAD_TYPE_2  FileType = "2 配置文件"
	DOWNLOAD_TYPE_3  FileType = "3 普通文件"
	DOWNLOAD_TYPE_5  FileType = "5 Dt omcore log file"
	DOWNLOAD_TYPE_6  FileType = "6 Dt omkeeper log file"
	DOWNLOAD_TYPE_7  FileType = "7 Dt omproxy log file"
	DOWNLOAD_TYPE_8  FileType = "8 Dt proxy log file"
	DOWNLOAD_TYPE_9  FileType = "9 Dt atproxy log file"
	DOWNLOAD_TYPE_10 FileType = "10 Dt xds log file"
	DOWNLOAD_TYPE_11 FileType = "11 Dt all log file"
	DOWNLOAD_TYPE_12 FileType = "12 Data Model File"
	DOWNLOAD_TYPE_13 FileType = "14 Dt ordinary log file"
	DOWNLOAD_TYPE_14 FileType = "15 All configure File"
	DOWNLOAD_TYPE_15 FileType = "18 Dt Alarm Model File"
	DOWNLOAD_TYPE_16 FileType = "19 Dt Exception Model File"
	DOWNLOAD_TYPE_17 FileType = "20 Dt Alarm File"
	DOWNLOAD_TYPE_18 FileType = "21 Dt Exception File"
)

func (FileType) IsDownloadType

func (own FileType) IsDownloadType() bool

func (FileType) IsUploadType

func (own FileType) IsUploadType() bool

type Requester

type Requester interface {
	fmt.Stringer

	Validate() error
	GetClass() Class
	GetCommand() Command
}

Requester 定义 OM 请求的接口

type Responser

type Responser interface {
	fmt.Stringer

	// 校验响应数据
	Validate() error
	// 获取响应数据
	GetData() any
	// 获取响应类型
	GetClass() Class
	// 获取响应命令
	GetCommand() Command
}

Responser 定义OM响应的接口

Jump to

Keyboard shortcuts

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