Friend Function DiscoverIp(ByVal filter As Eth32ConfigFilter, mac As eth32cfg_mac, _ ByVal product_id As Byte, ByVal serialnum_batch As Integer, ByVal serialnum_unit As Integer) As Long
This 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.
The filter parameter instructs the method which data to filter on. Although this method includes parameters for both MAC and serial number information, they 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:
ETH32CFG_FILTER_NONE - The parameters will be ignored. All devices will be discovered.
ETH32CFG_FILTER_MAC - Only devices matching the provided MAC address will be discovered.
ETH32CFG_FILTER_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.
Private Sub example() Dim devdetect As New Eth32Config Dim dev As New Eth32 ' Set up error handling for this routine On Error GoTo myerror ' 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 ETH32_PRODUCT_ID constant, ' 1 for the batch (AB), and 82 for the unit number. ' This would be serial number 105-AB082 as shown on the device. Dim tempmac As eth32cfg_mac ' For the MAC address, we just need a variable to pass in. ' It will not be considered since we don't set the flag to use it. devdetect.DiscoverIp ETH32CFG_FILTER_SERIAL, tempmac, ETH32_PRODUCT_ID, 1, 82 If devdetect.NumResults = 0 Then MsgBox "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. dev.Connect devdetect.IpConvertToString(devdetect.Result(0).active_ip) dev.Led(0) = True End If Exit Sub myerror: Dim temp As New Eth32 MsgBox "ETH32 error: " & temp.ErrorString(Err.number) End Sub