예제 #1
0
        private void HandleGetClosestDevice(MGBTCommandData cmd)
        {
            if (cmd.Status == 0)
            {
                InvocationHelper.InvokeIfRequired(this, new Action(() =>
                {
                    List <MGBTDevice> devices = MGBTDevice.FromArray(cmd.data);
                    if (devices.Count > 0)
                    {
                        string riderName = "ILLEGAL";
                        string address   = MacBytesToString(devices[0].Address).ToUpperInvariant();
                        if (riderNames.ContainsKey(address))
                        {
                            riderName = riderNames[address];
                        }

                        closestDeviceLbl.Text = devices[0].ToString() + "; " + riderName;
                    }
                }));
            }
            else
            {
                InvocationHelper.InvokeIfRequired(this, new Action(() =>
                {
                    AddLineToStatus(String.Format("Error response: {0}", cmd.Status));
                }));
            }
        }
예제 #2
0
 private void HandleListAllowedDevices(MGBTCommandData cmd)
 {
     if ((cmd.data.Length > 2) && (cmd.Status == 1))
     {
         InvocationHelper.InvokeIfRequired(this, new Action(() =>
         {
             if (cmd.data[0] == 0)
             {
                 AllowedDevicesLbx.Items.Clear();
             }
             byte[] devicesData = new byte[cmd.data.Length - 2];
             Array.Copy(cmd.data, 2, devicesData, 0, devicesData.Length);
             List <MGBTDevice> devices = MGBTDevice.FromArray(devicesData);
             AllowedDevicesLbx.Items.AddRange(devices.ToArray());
         }));
     }
     else
     {
         InvocationHelper.InvokeIfRequired(this, new Action(() =>
         {
             AddLineToStatus(String.Format("Data length or error response: {0}", cmd.Status));
         }));
     }
 }
예제 #3
0
        private void HandleListDetectedDevicesDeviceData(byte[] devicesData)
        {
            List <MGBTDevice> devices = MGBTDevice.FromArray(devicesData);

            detectedDevicesLbx.Items.AddRange(devices.ToArray());
        }