Skip to content
Snippets Groups Projects
Commit 359a5ef8 authored by jkerdreu's avatar jkerdreu
Browse files

First test w/ Cbor tags.

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2323 b32b6428-25c9-4566-ad07-03861ab6144f
parent ccb006c2
Branches
No related tags found
No related merge requests found
......@@ -31,7 +31,6 @@ def monitor_filter(msg):
return False
return True
def setup_xaal():
""" setup xAAL Engine & Device. And start it in a Greenlet"""
global monitor
......
......@@ -18,7 +18,7 @@ def setup_dev(dev):
dev.product_id = "OpenWeatherMap"
dev.info = "%s@%s" % (PACKAGE_NAME,platform.node())
dev.url = "https://www.openweathermap.org"
dev.version = 0.2
dev.version = 0.3
return dev
class GW:
......@@ -32,6 +32,7 @@ class GW:
cfg['config']['base_addr'] = str(tools.get_random_base_uuid())
self.cfg = cfg
self.setup()
self.update()
def setup(self):
""" create devices, register .."""
......@@ -48,7 +49,7 @@ class GW:
# gw
gw = devices.gateway(tools.str_to_uuid(cfg['addr']))
gw.attributes['embedded'] = [dev.address.bytes for dev in self.devs]
gw.attributes['embedded'] = [dev.address for dev in self.devs]
for dev in (self.devs + [gw,]):
setup_dev(dev)
......
......@@ -28,7 +28,8 @@ from . import config
from .uuids import UUID
from .exceptions import MessageError,MessageParserError
import cbor
#import cbor
import cbor2 as cbor
import datetime
import pysodium
import base64
......@@ -72,6 +73,9 @@ class MessageFactory(object):
buf.append(msg.devtype)
buf.append(msg.msgtype.value)
buf.append(msg.action)
if msg.body:
buf.append(msg.body)
"""
# for body, we need to marshall for special object, ie UUIDs
body = copy.copy(msg.body)
if body:
......@@ -79,7 +83,7 @@ class MessageFactory(object):
if hasattr(body[k],'bytes'):
body.update({k:body[k].bytes})
buf.append(body)
"""
clear = cbor.dumps(buf)
# Additionnal Data == cbor serialization of the targets array
ad = result[3]
......
......@@ -59,9 +59,11 @@ class Device:
return self.attributes.update(data)
def update_description(self, data):
"""
group_id = data.get('groupId',None)
if group_id:
data['groupId'] = tools.bytes_to_uuid(group_id)
"""
return self.description.update(data)
def update_db(self,data):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment