public MainWindow() { InitializeComponent(); RoleComboBox.SelectedIndex = (int)SerialNetConfig.NODE_ROLE.UNKNOWN; UpdateRadioConfigHandler = radio_ConfigChanged; try { radio = new SerialNetDevice(); radio.ConfigChanged += new EventHandler<SerialNetConfigEventArgs>(radio_ConfigChangedSafe); radio.StatusChanged += new EventHandler<SerialNetDevice.DeviceStatusChangedEventArgs>(radio_StatusChanged); } catch (Exception ex) { radio = null; } }
void radio_StatusChanged(object sender, SerialNetDevice.DeviceStatusChangedEventArgs e) { switch (e.DeviceStatus) { case SerialNetDevice.SerialNetDeviceStatus.UNKNOWN: StatusLabel.Content = "Unknown status"; break; case SerialNetDevice.SerialNetDeviceStatus.NO_USB: StatusLabel.Content = "Please plug device into PC and connect"; break; case SerialNetDevice.SerialNetDeviceStatus.NO_SerialNet: StatusLabel.Content = "USB port OK, no PetPuter detected"; break; case SerialNetDevice.SerialNetDeviceStatus.NO_NETWORK: StatusLabel.Content = "PetPuter OK, not connected to network"; break; case SerialNetDevice.SerialNetDeviceStatus.OK_NETWORK: StatusLabel.Content = "PetPuter online"; break; case SerialNetDevice.SerialNetDeviceStatus.READ_CONFIG: StatusLabel.Content = "Reading device config"; break; case SerialNetDevice.SerialNetDeviceStatus.WRITE_CONFIG: StatusLabel.Content = "Writing device config"; break; } }