Exemplo n.º 1
0
        public void Setup()
        {
            Log.LogManager.Level = Log.LogLevel.Fatal;
            _root = new Resource(String.Empty);
            Resource sensors = new Resource("sensors");
            Resource temp = new Resource("temp");
            Resource light = new Resource("light");
            _root.Add(sensors);
            sensors.Add(light);
            sensors.Add(temp);

            sensors.Attributes.Title = "Sensor Index";
            temp.Attributes.AddResourceType("temperature-c");
            temp.Attributes.AddInterfaceDescription("sensor");
            temp.Attributes.Add("foo");
            temp.Attributes.Add("bar", "one");
            temp.Attributes.Add("bar", "two");
            light.Attributes.AddResourceType("light-lux");
            light.Attributes.AddInterfaceDescription("sensor");
        }
Exemplo n.º 2
0
        private void CreateServer()
        {
            CoAPEndPoint endpoint = new CoAPEndPoint(0);

            _resource = new TestResource(NAME_1, PAYLOAD);
            _server = new CoapServer();
            _server
                .Add(new Resource(RES_A)
                    .Add(new Resource(RES_AA)
                        .Add(_resource
                            .Add(new TestResource(CHILD, CHILD_PAYLOAD)))));

            _server.AddEndPoint(endpoint);
            _server.Start();
            _serverPort = ((System.Net.IPEndPoint)endpoint.LocalEndPoint).Port;
        }