in start replaced `asyncio.Task(aiocoap.Context.create_server_context(root))` with `asyncio.Task(aiocoap.Context.create_server_context(uri, bind=('::', port))
@@ -45,7 +45,8 @@ def configure_coap() -> (str, str):
return uri, port
-
+"""
+# Original Code
def start():
"""Registers all CoAP URI handlers"""
# Retrive CoAP configs
@@ -61,3 +62,22 @@ def start():
asyncio.Task(aiocoap.Context.create_server_context(root))
+"""
+def start():
+ """Registers all CoAP URI handlers"""
+ # Retrive CoAP configs
+ uri, port = configure_coap()
+
+ root = aiocoap.resource.Site()
+
+ # Register CoAP methods
+ root.add_resource(('.well-known', 'core'),
+ aiocoap.resource.WKCResource(root.get_resources_as_linkheader))
+
+ SensorValues().register_handlers(root)
+
+ asyncio.Task(aiocoap.Context.create_server_context(uri, bind=('::', port)))
+# asyncio.Task(aiocoap.Context.create_server_context(root))
+
+
+
