Package com.cognex.cmbsdk.discovery
Class EthernetDiscoverer
java.lang.Object
com.cognex.cmbsdk.discovery.EthernetDiscoverer
Discovers available DataMan devices on the specified network interface.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface definition for a callback to be invoked if a device is found. -
Constructor Summary
ConstructorsConstructorDescriptionEthernetDiscoverer(NetworkInterface ni, android.os.Handler handler, EthernetDiscoverer.OnDataManDeviceDetectedListener listener) Creates an EthernetDiscoverer object on the specifiedNetworkInterface -
Method Summary
Modifier and TypeMethodDescriptionintvoidSend identifier packet on the network.voidsetDeviceFilter(int deviceFilter) voidSets the optional logger which can be used for debugging purposes.voidStarts the device discovery process.voidstartDeviceDiscovery(boolean treatBootupAsHello) Starts the device discovery process.voidCancels the currently running device discovery.static EthernetDiscovererwifiInterfaceDiscoverer(android.content.Context context, android.os.Handler handler, EthernetDiscoverer.OnDataManDeviceDetectedListener listener) Discovers available DataMan devices on the WiFi network, if available.static EthernetDiscovererwifiInterfaceDiscoverer(android.content.Context context, EthernetDiscoverer.OnDataManDeviceDetectedListener listener) Discovers available DataMan devices on the WiFi network, if available, and executes the listener on the main looper Handler.
-
Constructor Details
-
EthernetDiscoverer
public EthernetDiscoverer(NetworkInterface ni, android.os.Handler handler, EthernetDiscoverer.OnDataManDeviceDetectedListener listener) throws IllegalArgumentException Creates an EthernetDiscoverer object on the specifiedNetworkInterface- Parameters:
ni- TheNetworkInterfaceobject to use for discovering the deviceshandler- TheHandlerobject to be used to execute the listeners on its thread. (specify null for main looper Handler)listener- TheEthernetDiscoverer.OnDataManDeviceDetectedListenerlistener to invoke if a device is found.- Throws:
IllegalArgumentException- if no InterfaceAddress is available on the specified NetworkInterface
-
-
Method Details
-
wifiInterfaceDiscoverer
public static EthernetDiscoverer wifiInterfaceDiscoverer(android.content.Context context, android.os.Handler handler, EthernetDiscoverer.OnDataManDeviceDetectedListener listener) Discovers available DataMan devices on the WiFi network, if available. Please specify android.permission.ACCESS_WIFI_STATE permission in manifest to use this method.- Parameters:
context- TheContextobject to use.handler- TheHandlerobject to be used to execute the listeners on its thread. (specify null for main looper Handler)listener- TheEthernetDiscoverer.OnDataManDeviceDetectedListenerlistener to invoke if a device is found.- Returns:
- an EthernetDiscoverer instance configured for the device Wifi connection, or null if the Wifi is not available.
-
wifiInterfaceDiscoverer
public static EthernetDiscoverer wifiInterfaceDiscoverer(android.content.Context context, EthernetDiscoverer.OnDataManDeviceDetectedListener listener) Discovers available DataMan devices on the WiFi network, if available, and executes the listener on the main looper Handler.- Parameters:
context- TheContextobject to use.listener- TheEthernetDiscoverer.OnDataManDeviceDetectedListenerlistener to invoke if a device is found.- Returns:
- an EthernetDiscoverer instance configured for the device Wifi connection, or null if the Wifi is not available.
-
getDeviceFilter
public int getDeviceFilter() -
setDeviceFilter
public void setDeviceFilter(int deviceFilter) -
startDeviceDiscovery
Starts the device discovery process.- Throws:
IllegalArgumentException- if the interface can not be opened.
-
startDeviceDiscovery
Starts the device discovery process.- Parameters:
treatBootupAsHello- Iftrue, the listener will treat Bootup packets as Hello packets when processing incoming cognamer packets.- Throws:
IllegalArgumentException- if the interface can not be opened.
-
sendIdentifier
public void sendIdentifier()Send identifier packet on the network. Useful to reuse existing instance. -
stopDeviceDiscovery
public void stopDeviceDiscovery()Cancels the currently running device discovery. -
setLogger
Sets the optional logger which can be used for debugging purposes.- Parameters:
logger- The logger object to be used for logging.
-