def on_message(client, userdata, msg):
# Called when a MQTT message is received.
print('{0}: {1}'.format(msg.topic, str(msg.payload)))
# Handle a target request.
if msg.topic == TOPIC_TARGET:
# Try to parse out two numbers from the payload. These are the
# screen x and screen y coordinates for the target command.
result = parse.parse('{:d},{:d}', msg.payload.decode('ascii'))
if result is not None:
# Got a valid pair of numbers, use the laser model to target that
# position.
model.target(result[0], result[1])
评论列表
文章目录