Exemplo n.º 1
0
    def _setup_resources(self):
        self.add_topic(('.well-known', 'core'),
                       WKCResource(self._root.get_resources_as_linkheader))
        self.add_topic(('alldata', ), AllData(self._db_manager))

        self._setup_clients()
        self._setup_datatypes()
Exemplo n.º 2
0
def build_site_node3():
    site = Site()
    for x in 'left', 'middle', 'right':
        site.add_resource(['light', x], Light3())
    site.add_resource(['.well-known', 'core'],
                      WKCResource(site.get_resources_as_linkheader))
    return site
Exemplo n.º 3
0
    def __init__(self):
        super().__init__()

        # Not part of the test suite, but handy when running standalone
        self.add_resource(('.well-known', 'core'), WKCResource(self.get_resources_as_linkheader))

        self.subsite = ObserveTestingSite()

        self.add_resource(('deep',), self.subsite)
Exemplo n.º 4
0
    def __init__(self, config):
        self.root = Site()
        self._config = config

        self.root.add_resource([".well-known", "core"],
                               WKCResource(
                                   self.root.get_resources_as_linkheader))

        self.cluster = ClusterSite(self)
        # root.add_resource(["ciao"], Resource())
        self.root.add_resource(["lights"], self.cluster)
Exemplo n.º 5
0
def init_resource_tree():
    from resources.cluster import ClusterSite
    from aiocoap.resource import Site, WKCResource

    root = Site()
    root.add_resource([".well-known", "core"],
                      WKCResource(root.get_resources_as_linkheader))

    cluster = ClusterSite()
    root.add_resource(["lights"], cluster)

    return root
Exemplo n.º 6
0
def build_site_node2():
    site = Site()
    temp = Temp()
    site.add_resource(('temp',), temp)
    light = Light()
    site.add_resource(('light',), light)
    for x in (temp, light):
        x.ct = 0

    def get_links():
        links = site.get_resources_as_linkheader()
        links.links.append(Link("/t", anchor="sensors/temp", rel="alternate"))
        links.links.append(Link("http://www.example.com/sensors/t123", anchor="sensors/temp", rel="describedby"))
        return LinkFormat(links.links)
    site.add_resource(('.well-known', 'core'), WKCResource(get_links))

    return site
Exemplo n.º 7
0
async def start_server(args):
    hx711 = HX711(args.dout, args.pd_sck)
    hx711.tare()
    hx711.set_reference_unit(args.ref_unit)

    root = Site()
    root.add_resource(['.well-known', 'core'],
                      WKCResource(root.get_resources_as_linkheader,
                                  impl_info=None))
    root.add_resource(['weight'], LoadCellSensor(hx711, 1, args.title))

    protocol = await Context.create_server_context(root,
                                                   bind=('::', args.port))
    registration_parameters = {}
    if args.ep is not None:
        registration_parameters['ep'] = args.ep
    registration = Registerer(protocol,
                              rd=args.rd,
                              registration_parameters=registration_parameters)
Exemplo n.º 8
0
def build_site_node1():
    site = Site()
    temp = Temp()
    site.add_resource(('sensors', 'temp'), temp)
    light = Light()
    site.add_resource(('sensors', 'light'), light)
    for x in (temp, light):
        x.if_ = "sensor"
        x.ct = 41

    def get_links():
        links = site.get_resources_as_linkheader()
        for l in links.links:
            if l.href == "/sensors/light":
                l.attr_pairs.append(("anchor", "coap://spurious.example.com:5683"))
        return LinkFormat(links.links)
    site.add_resource(('.well-known', 'core'), WKCResource(get_links))

    return site
Exemplo n.º 9
0
 def __init__(self, listgenerator, common_rd, context):
     WKCResource.__init__(self, listgenerator)
     SimpleRegistration.__init__(self, common_rd, context)
     self.registration_warning = "via .well-known/core"