question

Gurgen Chlingaryan avatar image
Gurgen Chlingaryan asked David Marginian Deactivated commented

How to determine if connection failed

Hi, I'm developing a windows application using your SDK for .NET.

User can select either connect to device through USB or Ethernet, but before showing a user a choice to select, I want first try to connect to device using last connection method (like if last time user selected USB, try to use it again) and if it fails, show a dropdown to select another method to connect.

The problem is if let's say USB cable is not connected and connection cannot be established, no event is fired to understand that connection failed, so I could take my further steps...

Setting a timer and check if connected after that period is not a choice for me.

semi-integrations
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated commented

Have you seen our documentation? https://docs.clover.com/clover-platform/docs/windows. onDeviceDisconnected should be called when the connection drops.

3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gurgen Chlingaryan avatar image Gurgen Chlingaryan commented ·

Hello David,

Yes, I saw the documentation, and as I previously said, I don't get any event from device.

The workflow is:

Usb cable is disconnected.
I call
CloverConnector.InitializeConnection();
and wait for something to happen, but nothing happens...

If usb cable is physically connected and "USB Pay Display" app is not running on device, I get OnDeviceConnected event saying connecing... and never get OnDeviceDisconnected event.

If I run USB Pay Display app, it connects and calls OnDeviceReady.

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ Gurgen Chlingaryan commented ·

In order for onDeviceDisconnected to be called you have to have been connected. If you don't receive an onDeviceReady then the connection was never fully established. If you run USB pay display connect to the device (onDeviceReady is received) then disconnect the cable I would expect onDeviceDisconnected would be called. Is that not the case?

0 Likes 0 ·
Gurgen Chlingaryan avatar image Gurgen Chlingaryan David Marginian ♦♦ commented ·

Three cases:

1. Consider cable is not connected

2. Consider cable is connected, but "USB Pay Display" app is not running .

3. Consider any other case, when connection could not be established.

For all cases if I try to connect, connection will not be established, right?

So my question is: Since OnDeviceDisconnected is not called, how can I know that connection was not established (or failed, whatever)?


My workflow is following:

I want to connect with default connection (let's say it is USB)

if failed: try connect through Ethernet

if failed: notify user.


so I can't catch the moment when "if failed"

0 Likes 0 ·
Gurgen Chlingaryan avatar image
Gurgen Chlingaryan answered

I can't believe, 9 days passed and still no results :)

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community