コード例 #1
0
        public void didFinishLaunching()
        {
            NetworkInterface NI = NetworkInterface.GetAllNetworkInterfaces()[0];
            NDLogger.Log("Network IP " + NI.IPAddress.ToString(), LogLevel.Verbose);

            xbeeCoordinator = new XBeeCoordinator(createSerialPortWithName(SerialPorts.COM1));

            xbeeCoordinator.BytesReadFromSerial += new BytesReadFromSerialEventHandler(BytesReadFromSerialHandler);
            xbeeCoordinator.FrameDroppedByChecksum += new FrameDroppedByChecksumEventHandler(FrameDroppedByChecksumHandler);
            xbeeCoordinator.StartListen();

            upstreamMQTT = new NDMQTT();
            try
            {
                Configuration.MQTT = NDMQTTConfiguration.ReadFromFile(@"\SD\\mqtt_configuration.csv");
                startMQTT();
            }
            catch
            {
            }

            this.LocalAccessService.DataSource = this;
            this.LocalAccessService.Start();
            this.LocalAccessService.MqttConfigurationReceived += LocalAccessService_MqttConfigurationReceived;

            // setup our interrupt port (on-board button)
            onboardButton = new InterruptPort((Cpu.Pin)0x15, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);

            // assign our interrupt handler
            onboardButton.OnInterrupt += new NativeEventHandler(button_OnInterrupt);

            discoveryService = new XBeeDiscoveryService(xbeeCoordinator);
            discoveryService.RemoteDeviceFound += new RemoteDeviceFoundEventHandler(OnRemoteXBeeFound);
            discoveryService.Discover();

            onboardLED.Write(false);
        }
コード例 #2
0
 public XBeeDiscoveryService(XBeeCoordinator coordinator)
 {
     this.coordinator = coordinator;
     knownDevices = new RemoteXBee[0];
 }