当前位置: 首页>>代码示例>>Python>>正文


Python Packet.print_link_transfer方法代码示例

本文整理汇总了Python中Packet.print_link_transfer方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.print_link_transfer方法的具体用法?Python Packet.print_link_transfer怎么用?Python Packet.print_link_transfer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Packet的用法示例。


在下文中一共展示了Packet.print_link_transfer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_message

# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import print_link_transfer [as 别名]
def on_message(client, userdata, msg):
	#data fromm device
	if (str(msg.topic) == "BeeeOn/data_from"):
		print(">>>>>>"+msg.topic+" "+str(msg.payload))

		split_msg = msg.payload.split(',')
		device_channel = 0

		pid_from_device = 0
		for i in range(0,4):
			pid_from_device = pid_from_device << 8 | int(split_msg[i])

		send_list = []
		groups = []
		for dev in devices:
			#finding from whom came the message
			if dev.pid == pid_from_device:
				groups = dev.group
				device_channel = dev.channel

		for dev in devices:
			if dev.pid == pid_from_device:
				continue

			#select of equipment in the same channel
			for g in groups:
				if g in dev.group:
					if (int(dev.channel) == int(device_channel)):
						send_list.append(dev.id)

		#avoiding the duplication
		send_list = list(set(send_list))

		#send message
		for device in devices:
			if device.id in send_list:
				device.reSendMsg(split_msg)

		print "-----------------------------------"
		init(autoreset=True)
		print "SNIFFER"
		print msg.payload
		split_msg = msg.payload.split(',')
		temp = split_msg[9:]
		temp.pop()
		packet = "{\"raw\": ["

		#first value
		packet += "\"0x%02X\"" % int(split_msg[8])

		for item in temp:
			packet += ",\"0x%02X\"" % int(item)
		packet += "]}\n"

		p = Packet()

		try:
			# Convert JSON string into Python nested dictionary/list.
			data = json.loads(packet)
		except Exception, e:
			print("Error")
		p.decode(data['raw'])
		p.print_link_transfer()
		print "-----------------------------------"
开发者ID:BeeeOn,项目名称:sensors,代码行数:66,代码来源:simulator.py


注:本文中的Packet.print_link_transfer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。