2020-05-12 14:01:21 -07:00
|
|
|
import paho.mqtt.client as mqtt
|
|
|
|
import json
|
|
|
|
import base64
|
|
|
|
import message_pb2
|
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
# Test protobuf here
|
2020-05-12 22:36:23 -07:00
|
|
|
code = bytearray('CgoNAABIQxUAAMhCEAA=', "utf-8")
|
2020-05-12 14:01:21 -07:00
|
|
|
print(code)
|
|
|
|
bcode = base64.b64decode(code)
|
|
|
|
res = message_pb2.CollarResponse()
|
|
|
|
res.ParseFromString(bcode)
|
|
|
|
|
2020-05-12 22:36:23 -07:00
|
|
|
assert res.loc.x == 200
|
|
|
|
assert res.loc.y == 100
|
|
|
|
assert res.oob == 0
|
2020-05-12 14:01:21 -07:00
|
|
|
print("Coord {x: " + str(res.loc.x) + ", y: " + str(res.loc.y) + "}")
|