private void GetDeviceInfo(DeviceClient client) { string model; string fwversion; string serialno; string hwid; try { client.GetDeviceInformation(out model, out fwversion, out serialno, out hwid); string deviceInfo = string.Format("\nDevice: {0} [Firmware: {1}, Serial #: {2}, Hardware ID: {3}]\n", model, fwversion, serialno, hwid); lblModel.Text = string.Format("Model: {0}", model); lblFirmware.Text = string.Format("Firmware: {0}", fwversion); lblSerial.Text = string.Format("Serial #: {0}", serialno); lblHwID.Text = string.Format("Hardware ID: {0}", hwid); tssLbl.Text = string.Format("{0} - Device info retrieved", System.DateTime.Now); Console.WriteLine(deviceInfo); File.AppendAllText("info.txt", string.Format("\nDevice: {0} ({4}:{5}) [Firmware: {1}, Serial #: {2}, Hardware ID: {3}]\n", model, fwversion, serialno, hwid, IP.ToString(), Port)); } catch (Exception ex) when(ex.InnerException.Message == "The remote server returned an error: (401) Unauthorized.") { // Authentication required tssLbl.Text = string.Format("{0} Authentication failure. Unable to log into device.", System.DateTime.Now); // - {0}", ex.Message); throw new Exception(string.Format("Authentication failure - {0}", ex.Message), ex); } }
public DeviceViewModel() { string[] arguments = Environment.GetCommandLineArgs(); if (arguments.Length > 1) { IpAddress = arguments[1]; } if (arguments.Length > 2) { Username = arguments[2]; } if (arguments.Length > 3) { Password = arguments[3]; } Console.WriteLine("Querying " + IpAddress + " ..."); /* replace the two lines below by the following version if you want to use HTTPS * EndpointAddress DeviceServiceRemoteAddress = new EndpointAddress("http://" + IpAddress + "/onvif/device_service"); * var httpBinding = new HttpTransportBindingElement */ EndpointAddress DeviceServiceRemoteAddress = new EndpointAddress("http://" + IpAddress + "/onvif/device_service"); var httpBinding = new HttpTransportBindingElement { AuthenticationScheme = AuthenticationSchemes.Digest }; var messageElement = new TextMessageEncodingBindingElement { MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None) }; CustomBinding bind = new CustomBinding(messageElement, httpBinding); Client = new DeviceClient(bind, DeviceServiceRemoteAddress); PasswordDigestBehavior passwordDigestBehavior = new PasswordDigestBehavior(Username, Password); Client.Endpoint.Behaviors.Add(passwordDigestBehavior); string Model, FirmwareVersion, SerialNumber, HardwareId; Client.GetDeviceInformation(out Model, out FirmwareVersion, out SerialNumber, out HardwareId); Console.WriteLine("Model = " + Model); Console.WriteLine("FirmwareVersion = " + FirmwareVersion); Console.WriteLine("SerialNumber = " + SerialNumber); Console.WriteLine("HardwareId = " + HardwareId); }
public static void MuestraInfo(string uri) { System.DateTime UTCTime = System.DateTime.UtcNow; Console.Write(string.Format("Client UTC Time: {0}", UTCTime.ToString("HH:mm:ss"))); HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); var httpTransportBinding = new HttpTransportBindingElement { AuthenticationScheme = AuthenticationSchemes.Digest }; var textMessageEncodingBinding = new TextMessageEncodingBindingElement { MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None) }; var customBinding = new CustomBinding(textMessageEncodingBinding, httpTransportBinding); TextMessageEncodingBindingElement textMessageEncoding = new TextMessageEncodingBindingElement(MessageVersion.Soap12, Encoding.UTF8); EndpointAddress serviceAddress = new EndpointAddress(uri); ChannelFactory <Device> channelFactory = new ChannelFactory <Device>(customBinding, serviceAddress); var passwordDigestBehavior = new PasswordDigestBehavior("julian", "julian"); channelFactory.Endpoint.Behaviors.Remove(typeof(ClientCredentials)); channelFactory.Endpoint.Behaviors.Add(passwordDigestBehavior); var deviceClient = new DeviceClient(customBinding, serviceAddress); deviceClient.Endpoint.Behaviors.Add(passwordDigestBehavior); var unitTime = deviceClient.GetSystemDateAndTime(); Console.Write((string.Format(" Camera UTC Time: {0}:{1}:{2}", unitTime.UTCDateTime.Time.Hour, unitTime.UTCDateTime.Time.Minute, unitTime.UTCDateTime.Time.Second))); ServiceReference1.CapabilityCategory[] cc = new ServiceReference1.CapabilityCategory[100]; deviceClient.GetCapabilities(cc); Console.Write(" GetHostname: " + deviceClient.GetHostname().Name); Console.Write(" GetWsdlUrl: " + deviceClient.GetWsdlUrl()); string model, firmwareVersion, serialNumber, hardwareId; deviceClient.GetDeviceInformation(out model, out firmwareVersion, out serialNumber, out hardwareId); Console.Write(" Model: " + model); Console.Write(" firmwareVersion: " + firmwareVersion); Console.Write(" serialNumber: " + serialNumber); Console.WriteLine("hardwareId: " + hardwareId + "\n\n"); }
public static DeviceInformation GetDeviceInformation(Structures set) { var messageElement = new TextMessageEncodingBindingElement(); messageElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None); HttpTransportBindingElement httpBinding = new HttpTransportBindingElement(); httpBinding.AuthenticationScheme = AuthenticationSchemes.Basic; CustomBinding bind = new CustomBinding(messageElement, httpBinding); EndpointAddress mediaAddress = new EndpointAddress(set.GetONVIF + "/onvif/Device"); DeviceClient client = new DeviceClient(bind, mediaAddress); client.ClientCredentials.UserName.UserName = set.Login; client.ClientCredentials.UserName.Password = set.Password; DeviceInformation dv = new DeviceInformation(); dv.Other = client.GetDeviceInformation(out dv.Model, out dv.Version, out dv.SerialNumber, out dv.HardwareID); return(dv); }
public static void MuestraInfoTest(string uri) { System.DateTime UTCTime = System.DateTime.UtcNow; Console.Write(string.Format("Client UTC Time: {0}", UTCTime.ToString("HH:mm:ss"))); HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); var httpTransportBinding = new HttpTransportBindingElement { AuthenticationScheme = AuthenticationSchemes.Anonymous }; var textMessageEncodingBinding = new TextMessageEncodingBindingElement { MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None) }; var customBinding = new CustomBinding(textMessageEncodingBinding, httpTransportBinding); EndpointAddress serviceAddress = new EndpointAddress(uri); var deviceClient = new DeviceClient(customBinding, serviceAddress); Console.Write(" GetHostname: " + deviceClient.GetHostname().Name); var unitTime = deviceClient.GetSystemDateAndTime(); Console.Write((string.Format(" Camera UTC Time: {0}:{1}:{2}", unitTime.UTCDateTime.Time.Hour, unitTime.UTCDateTime.Time.Minute, unitTime.UTCDateTime.Time.Second))); CapabilityCategory[] cc = new CapabilityCategory[100]; deviceClient.GetCapabilities(cc); Console.Write(" GetHostname: " + deviceClient.GetHostname().Name); Console.Write(" GetWsdlUrl: " + deviceClient.GetWsdlUrl()); string model, firmwareVersion, serialNumber, hardwareId; deviceClient.GetDeviceInformation(out model, out firmwareVersion, out serialNumber, out hardwareId); Console.Write(" Model: " + model); Console.Write(" firmwareVersion: " + firmwareVersion); Console.Write(" serialNumber: " + serialNumber); Console.WriteLine("hardwareId: " + hardwareId + "\n\n"); }
public IDeviceInfo Get() { _manufacturer = _client.GetDeviceInformation(out _model, out _firmwareVersion, out _serialNumber, out _hardwareId); return(this); }