•IP address
•Querying the IP address and subnet mask of the connected network adapter
•Querying the current IP address and subnet mask
•Setting the temporary IP address and subnet mask
•Setting a persistent IP address and subnet mask
•Enabling DHCP
IP address
In this example, the IP address and subnet mask of an unopened GigE camera are identified and changed. 
•With the comfortSDK, the camera remains closed and is addressed via the camera ID, that can be obtained from the camera descriptor.
The camera is automatically restarted, which invalidates the ID. The camera list must be updated via peak_CameraList_Update and you must search for the camera again.
•With the genericSDK, you need the device descriptor (see Opening a camera (API)). This allows you to reconfigure a misconfigured camera so that the camera can be opened and operated again. m_deviceDescriptor is the device descriptor in the following examples.
Querying the IP address and subnet mask of the connected network adapter
| comfortC | 
| peak_status status = PEAK_STATUS_SUCCESS;peak_ethernet_info ethInfo;
 
 status = peak_EthernetConfig_GetInfo(camID, ðInfo);
 if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
 // Pull host adapter IP address and subnet mask
 peak_ip_address ipAddress = ethInfo.hostIP.address;
 peak_ip_address subnetMask = ethInfo.hostIP.subnetMask;
 | 
| genericC++ | 
| try{
 int64_t ipAddress = 0;
 int64_t subnetMask = 0;
 
 // Get the NodeMap of the parent interface
 auto nodemap = m_deviceDescriptor->ParentInterface()->NodeMaps().at(0);
 if (nodemap)
 {
 ipAddress = nodemap->FindNode<peak::core::nodes::IntegerNode>("GevInterfaceSubnetIPAddress")->Value();
 subnetMask = nodemap->FindNode<peak::core::nodes::IntegerNode>("GevInterfaceSubnetMask")->Value();
 }
 }
 catch (const std::exception& e)
 {
 // ...
 }
 | 
Querying the current IP address and subnet mask
With the comfortSDK, this information can be read out easily.
| peak_status status = PEAK_STATUS_SUCCESS;peak_ethernet_info ethInfo;
 
 status = peak_EthernetConfig_GetInfo(camID, ðInfo);
 if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
 // Pull camera IP address and subnet mask
 peak_ip_address ipAddress = ethInfo.cameraIP.address;
 peak_ip_address subnetMask = ethInfo.cameraIP.subnetMask;
 | 
Procedure for the genericSDK:
1.First determine the associated network adapter via the device descriptor: m_deviceDescriptor->ParentInterface() 
2.Get the NodeMap of the network adapter. The network adapter has a selector that can be used to select all connected cameras.
3.Iterate over all entries of the selector.
4.Check the serial numbers of the selector entries until the desired camera is found.
5.Get the IP address and subnet mask of the selector entry. This corresponds to the IP address and subnet mask of the camera you are looking for.
| try{
 int64_t ipAddress = 0;
 int64_t subnetMask = 0;
 
 // Get the NodeMap of the parent interface that contains all connected cameras
 auto nodemapInterface = m_deviceDescriptor->ParentInterface()->NodeMaps().at(0);
 
 // Get node to select the device
 auto nodeDeviceSelector = nodemapInterface->FindNode<peak::core::nodes::IntegerNode>("DeviceSelector");
 
 // Get node with the serial number
 auto nodeSerialNumber = nodemapInterface->FindNode<peak::core::nodes::StringNode>("DeviceSerialNumber");
 
 // Iterate through all selectors and find selected serial number
 for (int i = 0; i <= nodeDeviceSelector->Maximum(); i++)
 {
 nodeDeviceSelector->SetValue(i);
 
 // This is the correct camera
 if (nodeSerialNumber->Value() == m_deviceDescriptor->SerialNumber())
 {
 ipAddress = nodemapInterface->FindNode<peak::core::nodes::IntegerNode>("GevDeviceIPAddress")->Value();
 subnetMask = nodemapInterface->FindNode<peak::core::nodes::IntegerNode>("GevDeviceSubnetMask")->Value();
 break;
 }
 }
 }
 catch (const std::exception& e)
 {
 // ...
 }
 | 
| try{
 var ipAddress = (long)0;
 var subnetMask = (long)0;
 
 // Get the NodeMap of the parent interface that contains all connected cameras
 var nodemapInterface = m_deviceDescriptor.ParentInterface().NodeMaps()[0];
 
 // Get node to select the device
 var nodeDeviceSelector = nodemapInterface.FindNode<peak.core.nodes.IntegerNode>("DeviceSelector");
 
 // Get node with the serial number
 var nodeSerialNumber = nodemapInterface.FindNode<peak.core.nodes.StringNode>("DeviceSerialNumber");
 
 // Iterate through all selectors and find selected serial number
 for (int i = 0; i <= nodeDeviceSelector.Maximum(); i++)
 {
 nodeDeviceSelector.SetValue(i);
 
 // This is the correct camera
 if (nodeSerialNumber.Value() == m_deviceDescriptor.SerialNumber())
 {
 ipAddress = nodemapInterface.FindNode<peak.core.nodes.IntegerNode>("GevDeviceIPAddress").Value();
 subnetMask = nodemapInterface.FindNode<peak.core.nodes.IntegerNode>("GevDeviceSubnetMask").Value();
 break;
 }
 }
 }
 catch (Exception e)
 {
 // ...
 }
 | 
| try:ip_address = 0
 subnet_mask = 0
 
 # Get the NodeMap of the parent interface that contains all connected cameras
 nodemap_interface = m_device_descriptor.ParentInterface().NodeMaps()[0]
 
 # Get node to select the device
 node_device_selector = nodemap_interface.FindNode("DeviceSelector")
 
 # Get node with the serial number
 node_serial_number = nodemap_interface.FindNode("DeviceSerialNumber")
 
 # Iterate through all selectors and find selected serial number
 for i in range(node_device_selector.Maximum()):
 node_device_selector.SetValue(i)
 
 # This is the correct camera
 if node_serial_number.Value() == m_device_descriptor.SerialNumber():
 ip_address = nodemap_interface.FindNode("GevDeviceIPAddress").Value()
 subnet_mask = nodemap_interface.FindNode("GevDeviceSubnetMask").Value()
 break
 
 except Exception as e:
 # ...
 | 
Setting the temporary IP address and subnet mask
comfortSDK: Temporary setting is not necessary, as this is handled automatically within the comfortSDK.
genericSDK: If the camera is not on the same subnet as the network card, you will not be able to open the camera. In this case, you need to set a temporary IP address and subnet mask to open the camera. When the camera is open, you can change the persistent IP address.
| genericC++ | 
| try{
 int64_t ipAddress; // set correct value here
 int64_t subnetMask; // set correct value here
 
 // Get the NodeMap of the parent interface that contains all connected cameras
 auto nodemapInterface = m_deviceDescriptor->ParentInterface()->NodeMaps().at(0);
 
 // Get node to select the device
 auto nodeDeviceSelector = nodemapInterface->FindNode<peak::core::nodes::IntegerNode>("DeviceSelector");
 
 // Get node with the serial number
 auto nodeSerialNumber = nodemapInterface->FindNode<peak::core::nodes::StringNode>("DeviceSerialNumber");
 
 // Iterate through all selectors and find selected serial number
 for (int i = 0; i <= nodeDeviceSelector->Maximum(); i++)
 {
 nodeDeviceSelector->SetValue(i);
 
 // This is the correct camera
 if (nodeSerialNumber->Value() == m_deviceDescriptor->SerialNumber())
 {
 nodemapInterface->FindNode<peak::core::nodes::IntegerNode>("GevDeviceForceIPAddress")->SetValue(ipAddress);
 nodemapInterface->FindNode<peak::core::nodes::IntegerNode>("GevDeviceForceSubnetMask")->SetValue(subnetMask);
 nodemapInterface->FindNode<peak::core::nodes::CommandNode>("GevDeviceForceIP")->Execute();
 // Note: The "WaitUntilDone" function must not be used here, as the camera reconnects after setting the IP address.
 break;
 }
 }
 }
 catch (const std::exception& e)
 {
 // ...
 }
 | 
Setting a persistent IP address and subnet mask
Prerequisite comfortSDK: The camera is not open.
Note: The camera is automatically restarted, which invalidates the ID. The camera list must be updated via peak_CameraList_Update and you must search for the camera again.
| comfortC | 
| peak_ip_config newCameraIPConfig;
 // IP address to be set
 newCameraIPConfig.address.parts[0] = 192;
 newCameraIPConfig.address.parts[1] = 168;
 newCameraIPConfig.address.parts[2] = 10;
 newCameraIPConfig.address.parts[3] = 42;
 
 // Subnet mask to be set
 newCameraIPConfig.subnetMask.parts[0] = 255;
 newCameraIPConfig.subnetMask.parts[1] = 255;
 newCameraIPConfig.subnetMask.parts[2] = 255;
 newCameraIPConfig.subnetMask.parts[3] = 0;
 
 // Set camera to use given persistent IP address and subnet mask
 status = peak_EthernetConfig_PersistentIP_Set(camID, newCameraIPConfig);
 if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
 // Camera will now reboot with new IP settings. Camera ID is no longer valid!
 // => Call peak_CameraList_Update, wait for camera to return and get new camID.
 | 
Prerequisite genericSDK: The camera is open.
| genericC++ | 
| // Set IP address use to persistentm_nodemapRemoteDevice->FindNode<peak::core::nodes::BooleanNode>("GevCurrentIPConfigurationPersistentIP")->SetValue(true);
 
 // Set persistent IP address
 m_nodemapRemoteDevice->FindNode<peak::core::nodes::IntegerNode>("GevPersistentIPAddress")->SetValue(ipAddress);
 m_nodemapRemoteDevice->FindNode<peak::core::nodes::IntegerNode>("GevPersistentSubnetMask")->SetValue(subnetMask);
 | 
Enabling DHCP
Prerequisite comfortSDK: The camera is not open.
Note: The camera is automatically restarted, which invalidates the ID. The camera list must be updated via peak_CameraList_Update and you must search for the camera again.
| comfortC | 
| // Set IP address to use DHCPstatus = peak_EthernetConfig_DHCP_Enable(camID, PEAK_TRUE);
 if (PEAK_ERROR(status)) { /* Error handling ... */ }
 
 // Camera will now reboot with new IP settings. Camera ID is no longer valid!
 // => Call peak_CameraList_Update, wait for camera to return and get new camID.
 | 
Prerequisite genericSDK: The camera is open.
| genericC++ | 
| // Set IP address use to DHCPm_nodemapRemoteDevice->FindNode<peak::core::nodes::BooleanNode>("GevCurrentIPConfigurationDHCP")->SetValue(true);
 |