int DiscoverIp(eth32cfg_mac mac) int DiscoverIp(byte product_id, ushort serialnum_batch, ushort serialnum_unit) int DiscoverIp(eth32cfg_mac mac, byte product_id, ushort serialnum_batch, ushort serialnum_unit) int DiscoverIp(Eth32ConfigFilter filter, eth32cfg_mac mac, byte product_id, ushort serialnum_batch, ushort serialnum_unit)
This overloaded method is used to detect ETH32 devices and their currently-active IP configuration settings. This method allows you to specify a filter so that only the information for the specific ETH32 device that you are interested in will be returned (in case there are multiple ETH32s on the network). This is intended for applications that need to discover the IP of a device that is using DHCP to get its IP address. This method uses a new command to the ETH32 device that is only supported by devices with firmware v3.000 and on. Any older devices on the network will not be detected. The eth32cfg_data structure for devices detected with this method will not have all fields filled in, since the response from the ETH32 does not include all available information. Only the product_id, mac, serialnum_batch, serialnum_unit, active_ip, active_gateway, active_netmask, and dhcp fields will be filled in and valid.
There are four different overloaded variants of this method. If only a MAC address is provided, devices will be discovered based only on MAC address. If the product_id, serialnum_batch, and serialnum_unit parameters are provided, the device will be discovered based only on the serial number (those three items make up the serial number). If MAC and serial number information is provided, only a device that matches both will be discovered. Finally, the last variant includes a filter parameter, that instructs the method which data to filter on. Although this variant includes parameters for both MAC and serial number information, it will only be considered if the appropriate flag is present in the filter parameter.
Once this method returns, the configuration data for any devices that have been found will be available through the Result Property.
filter - Specifies which parameters should be considered in discovering the device. If more than one flag is specified, then the device must match BOTH. This parameter is a Eth32ConfigFilter enumerator type, which has the following valid values:
Eth32ConfigFilter.None - The parameters will be ignored. All devices will be discovered.
Eth32ConfigFilter.Mac - Only devices matching the provided MAC address will be discovered.
Eth32ConfigFilter.Serial - Only devices matching the provided serial number information (id, batch, unit) will be discovered.
mac - The MAC address of the device you are trying to discover
product_id - The product ID code (part of the serial number) of the device you are trying to discover. For ETH32 devices, this is 105.
serialnum_batch - The batch number portion of the serial number for the device you are trying to discover.
serialnum_unit - The unit number portion of the serial number for the device you are trying to discover.
The number of devices that were found is returned by the method, but also remains available from the NumResults Property. When you are finished with the results, you may free the memory associated with the results using the Free Method. This is done automatically for you if the object is destroyed, or if you call the DiscoverIp Method or the Query Method again on the same object. Note that this means each Eth32Config object holds only one active set of results at one time.
Eth32Config devdetect = new Eth32Config(); try { // Set broadcast address - this line would not // be necessary since 255.255.255.255 is the default anyway devdetect.BroadcastAddressString = "255.255.255.255"; // Find a device by serial number -- we can use the ProductId constant // 1 for the batch (AB), and 82 for the unit number. // This would be serial number 105-AB082 as shown on the device. devdetect.DiscoverIp(Eth32Config.ProductId, 1, 82); if (devdetect.NumResults == 0) MessageBox.Show("Device not found"); else { // Device was found -- here's a quick example of using the information to now // connect to the device and turn on LED 0. Eth32 dev = new Eth32(); dev.Connect(devdetect.Result[0].active_ip.ToString()); dev.Led[0] = true; } } catch (Eth32Exception err) { // Handle errors here }