bytedreamer / OSDP.Net

A .NET Core control panel implementation of the Open Supervised Device Protocol(OSDP)
Apache License 2.0
47 stars 19 forks source link

Function to get the connection status of one of the device among set of devices sharing same connection ID #126

Closed DeepaGRao closed 1 year ago

DeepaGRao commented 1 year ago

Hi, We are using 3 devices connected to the same IP address and Port. But they are having different address and using the same connection ID. If one of the intermediate device is down, will the ControlPanel.IsOnline() function provide us the connection status of that particular device which is down? Is there any other way to know that one out of the 3 device is down/Communication is offline? They are all using the same connection ID and other 2 devices status is online.

Regards, Deepa

bytedreamer commented 1 year ago

There are two methods of getting the online status

For ad-hoc query, call IsOnline method from the ControlPanel object

        /// <summary>
        /// Is the PD online
        /// </summary>
        /// <param name="connectionId">Identify the connection for communicating to the device</param>
        /// <param name="address">Address assigned to the device</param>
        /// <returns>Returns true if the PD is online</returns>
        public bool IsOnline(Guid connectionId, byte address)`

To get real-time status updates, subscribe to the ConnectionStatusChange event. An example of this is in the Test Console project

     _controlPanel.ConnectionStatusChanged += (_, args) =>
            {
                DisplayReceivedReply(
                    $"Device '{_settings.Devices.SingleOrDefault(device => device.Address == args.Address, new DeviceSetting() { Name="[Unknown]"}).Name}' " +
                    $"at address {args.Address} is now " +
                    $"{(args.IsConnected ? (args.IsSecureChannelEstablished ? "connected with secure channel" : "connected with clear text") : "disconnected")}",
                    string.Empty);
            };

Let me know if there are any issues with either of these methods.

DeepaGRao commented 1 year ago

Thanks for this information. I used both these methods to get the status of the device. But when one device is down, IsOnline function is returning false for all the devices(with other address) which are using the same connection ID. Please find the sample code and the screenshot of the output attached. CommunicationStatus SampleProgram.txt

bytedreamer commented 1 year ago

This is the same issue as #87 that you submitted earlier. I need to find out more about your hardware in order to figure out a resolution. Please contact me directly at qubit@z-bitco.com