It has been a wile but as you explicitly asked for C++…
Here is how you can set a static / persistent IP in a camera that is not in your NIC’s subnet with CVB++ (basically what you do with the GenICam Browser)
// discover all your interfaces (NICS & USB HCs)
// currently there is no way to filter out USB HCs
auto interfaceInfoList = Cvb::DeviceFactory::Discover(
Cvb::DiscoverFlags::IgnoreGevSD |
Cvb::DiscoverFlags::IgnoreVins |
Cvb::DiscoverFlags::UpToLevelInterface,
std::chrono::milliseconds(2000));
// Given you know your interface index (GenICam Browser can list them all!)
const int MY_IF = 4;
auto& interfaceInfo = interfaceInfoList[MY_IF];
// Do a broadcast discovery and allow devices from another subnet to answer.
interfaceInfo.SetGenApiFeature(CVB_LIT("TLInterface"), CVB_LIT("Cust::DisableSubnetMatch"), CVB_LIT("1"));
interfaceInfo.SetGenApiFeature(CVB_LIT("TLInterface"), CVB_LIT("Cust::AllowBroadcastDiscoveryResponse"), CVB_LIT("1"));
// Discover again only devices connected to you interface!
// Include also devices that are inaccessible (might be because they are in use or in a different subnet)
Cvb::DeviceFactory::Discover(interfaceInfo,
Cvb::DiscoverFlags::IgnoreGevSD |
Cvb::DiscoverFlags::IgnoreVins |
Cvb::DiscoverFlags::UpToLevelDevice |
Cvb::DiscoverFlags::IncludeInaccessible,
std::chrono::milliseconds(2000));
{
auto interfaceDevice = Cvb::DeviceFactory::Open(interfaceInfo.AccessToken());
auto interfaceNM = interfaceDevice->NodeMap(CVB_LIT("TLInterface"));
// get all required nodes
auto deviceUpdateListNode = interfaceNM->Node<Cvb::CommandNode>(CVB_LIT("DeviceUpdateList"));
auto deviceMacNode = interfaceNM->Node<Cvb::IntegerNode>(CVB_LIT("DeviceMAC"));
auto cfgIPNode = interfaceNM->Node<Cvb::IntegerNode>(CVB_LIT("IPCfg_IP"));
auto cfgSubnetNode = interfaceNM->Node<Cvb::IntegerNode>(CVB_LIT("IPCfg_Subnet"));
auto cfgMacNode = interfaceNM->Node<Cvb::IntegerNode>(CVB_LIT("IPCfg_MAC"));
auto cfgForceNode = interfaceNM->Node<Cvb::CommandNode>(CVB_LIT("IPCfg_SetForceIP"));
auto cfgStaticNode = interfaceNM->Node<Cvb::CommandNode>(CVB_LIT("IPCfg_SetStatIP"));
// make node map aware of the device
deviceUpdateListNode->Execute();
// we want to configure the found device
cfgMacNode->SetValue(deviceMacNode->Value());
// IP 10.0.0.1 (given that your NIC has a suitable address like 10.0.0.2)
cfgIPNode->SetValue(0x0A000001);
// Subnet 255.255.255.0
cfgSubnetNode->SetValue(0xFFFFFF00);
// Force the new IP
cfgForceNode->Execute();
// make node map aware of new IP
deviceUpdateListNode->Execute();
// permanently write the IP to the camera
cfgStaticNode->Execute();
}
// Done, now you can see in the GC Browser, that the camera is in the same subnet as the NIC