4G模块 AT指令服务

lijian b3d0901dc7 更新文档 2 vuotta sitten
.idea 3823c2a74a first commit 2 vuotta sitten
netAtSDK b3d0901dc7 更新文档 2 vuotta sitten
server b3d0901dc7 更新文档 2 vuotta sitten
services b3d0901dc7 更新文档 2 vuotta sitten
.gitignore 3823c2a74a first commit 2 vuotta sitten
README.md b3d0901dc7 更新文档 2 vuotta sitten
config.toml 117f116c3d 实现rpcx服务,完善文档 2 vuotta sitten
go.mod 117f116c3d 实现rpcx服务,完善文档 2 vuotta sitten
go.sum 117f116c3d 实现rpcx服务,完善文档 2 vuotta sitten
main.go 117f116c3d 实现rpcx服务,完善文档 2 vuotta sitten

README.md

4G DTU AT指令远程配置服务端

  • 4G DTU有一个socket通道接入本服务,并保持长连接
  • 本服务通过RPCX对外暴露服务接口

1.rpc接口文档

通用参数

type BaseArgs struct {
    IMEI string
}

1.1 查询基站GPS信息

返回的lat, lng为原始坐标

  • 方法名: GetGPSInfo
  • 请求参数:

    type BaseArgs struct {
    	IMEI string
    }
    
    • 返回参数:
    type GPSInfoReply struct {
    	Lat float64
    	Lng float64
    }
    

1.2 查询IMEI

  • 方法名: GetIMEI
  • 请求参数:

    type BaseArgs struct {
    	IMEI string
    }
    
    • 返回参数: *string

    1.3 查询ICCID

    • 方法名: GetICCID
    • 请求参数: go type BaseArgs struct { IMEI string }
  • 返回参数: *string

1.4 配置工作模式

第一个参数 0 不启用该通道; 1 TCP/UDP 透传; 2 MQTT 透传; 3 塔石 DTU 云连接; 4 塔石 IOT 云连接; 5 HTTP 传输模式; 6 阿里云直连 B 取值范围 1~4,代表 4 个不同的 SOCKET 通道,省略时仅配置通道 1 默认值:+DTUMODE:1,0,0,0 默认第一路为 TCP/UDP 透传,其他几路为默认关闭

  • 方法名: SetDTUMode
  • 请求参数:

    type SetDTUModeArgs struct {
    BaseArgs
    Mode    int // 模式
    Channel int // 通道
    }
    
    • 返回参数: *string

    1.5 设置连接服务地址

    A 取值范围 1-4,代表 4 个不同的 SOCKET 通道 B 为 TCP 或者 UDP C 为服务器地址,可填域名或 IP,长度最大 255 D 为端口号,范围 1~65535

    • 方法名:SetServerAddr
    • 请求参数: go type ServerAddrArgs struct { BaseArgs Channel int // 通道 LinkType string // 连接类型 Ip string // Ip或域名 Port int // 端口 }
  • 返回参数: EmptyResult

1.6 查询服务器连接地址

  • 方法名: GetServerAddr
  • 请求参数: BaseArgs
  • 返回参数: ```go type ServerAddrReply struct { Addrs []*Addr }

type Addr struct { Channel int // 通道 LinkType string // 连接类型 Addr string // IP或域名 Port int // 端口 }


#### 1.7 设置串口参数

格式:AT+UARTCFG=A,B,C,D
A 串口波特率,支持的波特率为 115200、57600、38400、19200、14400、9600、4800、 2400、1200
B 数据位,取值范围 0~1 0 7 位数据位 1 8 位数据位
C 校验位,取值范围 0~2 0 无校验 NONE 1 奇校验 ODD 2 偶校验 EVEN
D 停止位,取值范围 0~1 0 1 位停止位 1 2 位停止位
默认值:+UARTCFG:9600,1,0,0(9600,8,N,1)

* 方法名: `SetUARTParam`
* 请求参数:
```go
type UARTArgs struct {
	BaseArgs
	Rate int // 波特率
	DBit int // 数据位
	CBit int // 校验位
	SBit int // 停止位
}
  • 返回参数: EmptyResult

1.8 查询串口参数

返回值含义参考1.7说明

  • 方法名:GetUARTParam
  • 请求参数: BaseArgs
  • 返回参数:

    type UARTReply struct {
    	Rate int // 波特率
    	DBit int // 数据位
    	CBit int // 校验位
    	SBit int // 停止位
    }
    

    1.9 注册包设置

    • 方法名:SetDTUID
    • 请求参数: go type DTUIDArgs struct { BaseArgs Mode int IdType int Format int Content string Channel int }
  • 返回参数: EmptyResult

1.10 查询注册包设置

  • 方法名:GetDTUID
  • 请求参数: BaseArgs
  • 返回参数:
type DTUIDReply struct {
	DTUIDs []*DTUID
}

type DTUID struct {
	Mode    int
	IdType  int
	Format  int
	Content string
	Channel int
}

1.11 查询心跳包配置

  • 方法名: GetKeepAlive
  • 请求参数: BaseArgs
  • 返回参数:
type KeepAliveReply struct {
	Channels []*KeepAlive
}

type KeepAlive struct {
	Duration int    // 心跳间隔
	Format   int    // 数据格式
	Content  string // 心跳包内容
	Channel  int    // 通道
}

1.12 设置心跳包配置

  • 方法名: SetKeepAlive
  • 请求参数:

    type KeepAliveArgs struct {
    	BaseArgs
    	Duration int    // 心跳间隔
    	Format   int    // 数据格式
    	Content  string // 心跳包内容
    	Channel  int    // 通道
    }
    
    • 返回参数: EmptyResult

    1.13 设置轮询使能

    A 自定义轮询使能,取值范围 0-1 0 关闭自定义轮询功能 1 开启自定义轮询功能 B 轮询时间间隔,取值范围 1-3600,表示每条启用指令间的时间间隔,单位秒 C 轮询数据输入格式,取值范围 0-1 0 ASCII 格式,设置为 0 表示之后输入的轮询指令均为以 ASCII 形式轮询, 即输入什么字串就轮询什么字串 1 HEX 格式, 设置为 1 表示之后输入的轮询指令需要满足 HEX 格式,轮 询时会自动转成 16 进制对应的 ASCII 字串 默认值:+POLL:0,10,1

    • 方法名:SetPOLL
    • 请求参数: go type PollArgs struct { BaseArgs Sw int // 是否使能 Duration int // 轮询间隔 Format int // 内容格式 }
  • 返回参数: EmptyResult

1.14 查询轮询使能

  • 方法名:GetPOLL
  • 请求参数: BaseArgs
  • 返回参数:

    type PollReply struct {
    	Sw       int // 是否使能
    	Duration int // 轮询间隔
    	Format   int // 内容格式
    }
    

    1.15 设置轮询字符串

    • 方法名:SetPollStr
    • 请求参数: go type PollStrArgs struct { BaseArgs Index int // 轮询字串号,取值范围 1-10 Sw int // 字串轮询使能 Crc int // CRC使能 Content string // 轮询内容 }
  • 返回参数: EmptyResult

1.16 查询轮询字符串

  • 方法名:GetPollStr
  • 请求参数: BaseArgs

  • 返回参数:

type PollStrReply struct {
    Strings []*PollStr
}

type PollStr struct {
    Sw      int    // 字串轮询使能
    Crc     int    // CRC使能
    Content string // 轮询内容
}