tr069 消息类型 (message type)

更新日期: 2023-04-26 阅读次数: 1443 字数: 439 分类: 物联网

tr069 是基于 SOAP 的 RPC 协议。

message type 可以理解为每个 RPC 的方法名。

这里有趣的地方是,既然是远程调用,那么就存在两种情况:

  • ACS 调用 CPE 的方法
  • CPE 调用 ACS 的方法

ACS 调用 CPE 的方法列表

  • GetPRCMethods: 获取 CPE 所支持的方法集合
  • GetParameterNames: Retrieve list of supported parameters from the device.
  • GetParameterValues: Retrieve current value of the parameter(s) identified by keys. A variation of this call takes an object as its key. It retrieves all of the object's parameters
  • SetParameterValues: Set the value of one or more parameters
  • GetParameterAttributes: Retrieve attributes of one or more parameters
  • SetParameterAttributes: Set attributes of one or more parameters
  • Download: Order CPE to download and use a file, specified by URL. File types include Firmware Image, Configuration File, Ringer file, etc.
  • Upload: Order CPE to upload a file to a specified destination. File types include the current configuration file, log files, etc.
  • AddObject: Add new instance to an object
  • DeleteObject: Remove instance from an object

CPE 调用 ACS 的方法列表

  • GetPRCMethods: 获取 ACS 所支持的方法集合
  • Inform: 任何时刻,CPE 要与 ACS 建立连接,CPE 都需要调用 Inform 方法,来初始化一个传输序列。例如,用 CPE 模拟器 向 ACS 发起第一个请求,就是 Inform 消息,body 里面包含了 Event 类型。
  • TransferComplete: 通知 ACS 之前的 Download / Upload 任务已结束。

TeamsACS 中打印当前收到的 Message 的 Type

tr069/handlers.go

func (s *Tr069Server) Tr069Index(c echo.Context) error {
	...

	// 打印 message type
	// [2023-04-26T20:20:28+08:00]     DEBUG   tr069/handlers.go:166   msg name: Inform
	log.Debugf("msg name: %s", msg.GetName())

	switch msg.GetName() {
	case "Inform":
		log.Info2("recv inform message",
			zap.String("namespace", "tr069"),
			zap.String("msgid", msg.GetID()),
			zap.String("msgtype", msg.GetName()),
			zap.String("ipaddr", c.RealIP()),
			zap.String("metrics", app.MetricsTr069Inform),
		)
		return s.processInform(c, lastInform, msg)
	case "TransferComplete":
		return s.processTransferComplete(c, msg)
	case ...

TeamsACS 中 Message 的实现

以 Inform 类型为例:

common/cwmp/Inform.go

里面定义了 Inform 的 Struct 及各种方法 (CreateXML, Parse, GetName 等)。

参考

  • https://en.wikipedia.org/wiki/TR-069
  • https://www.cnblogs.com/smillepro/articles/10573720.html

tags: tr069

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式