Esempio n. 1
0
        /**
         * <summary>Once a hub has been found, connect to it</summary>
         * <param name="sender">Object on which the change happened</param>
         * <param name="Address">The address of the hub</param>
         * <param name="Name">Name of the found hub</param>
         */
        private void Watcher_OnHubFound(object Sender, long Address, string Name)
        {
            wclWeDoHub Hub = new wclWeDoHub();
            int        res = Hub.Connect(Watcher.Radio, Address);

            if (res != wclErrors.WCL_E_SUCCESS)
            {
                MessageBox.Show("Can't connect to the Hub.");
            }
            else
            {
                lineTracker.AddHub(Hub);
            }
        }
Esempio n. 2
0
        private void FWatcher_OnHubFound(Object Sender, Int64 Address, String Name)
        {
            wclBluetoothRadio Radio = FWatcher.Radio;

            FWatcher.Stop();
            Int32 Res = FHub.Connect(Radio, Address);

            if (Res != wclErrors.WCL_E_SUCCESS)
            {
                MessageBox.Show("Connect failed: 0x" + Res.ToString("X8"));
                EnableConnect(false);
            }
            else
            {
                laStatus.Text = "Connecting";
            }
        }
Esempio n. 3
0
        private void FWatcher_OnHubFound(Object Sender, Int64 Address, String Name)
        {
            wclWeDoHub Hub = new wclWeDoHub();

            Hub.OnConnected          += Hub_OnConnected;
            Hub.OnDisconnected       += Hub_OnDisconnected;
            Hub.OnButtonStateChanged += Hub_OnButtonStateChanged;
            Hub.OnLowVoltageAlert    += Hub_OnLowVoltageAlert;
            Hub.BatteryLevel.OnBatteryLevelChanged += BatteryLevel_OnBatteryLevelChanged;

            Int32 Res = Hub.Connect(FWatcher.Radio, Address);

            if (Res == wclErrors.WCL_E_SUCCESS)
            {
                ListViewItem Item = lvHubs.Items.Add(Address.ToString("X12"));
                Item.SubItems.Add(Name);
                Item.SubItems.Add("Connecting");
                Item.SubItems.Add("");
                Item.SubItems.Add("");
                Item.SubItems.Add("");
                FHubs.Add(Hub);
            }
        }
Esempio n. 4
0
        private void FmDevInfo_Load(Object Sender, EventArgs e)
        {
            // Create WeDo Hub instance.
            FHub = new wclWeDoHub();
            // Setup its event handlers. We are interested in batt level only for now.
            FHub.BatteryLevel.OnBatteryLevelChanged += BatteryLevel_OnBatteryLevelChanged;
            FHub.OnLowVoltageAlert += Hub_OnLowVoltageAlert;
            FHub.OnConnected       += FHub_OnConnected;
            FHub.OnDisconnected    += FHub_OnDisconnected;
            FHub.OnDeviceAttached  += FHub_OnDeviceAttached;
            FHub.OnDeviceDetached  += FHub_OnDeviceDetached;
            FHub.OnLowSignalAlert  += FHub_OnLowSignalAlert;
            // Try to connect. We will use the same Bluetooth Radio object that is used by
            // the WeDo Watcher.
            Int32 Res = FHub.Connect(FRadio, FAddress);

            if (Res != wclErrors.WCL_E_SUCCESS)
            {
                // If something went wrong show message and close the form.
                MessageBox.Show("Connect to Hub failed: 0x" + Res.ToString("X8"));
                Close();
            }
        }