OptrisOptrisDocumentation

Documentation/OTC SDK/optris_sdk — Python API referencev12.0

network_setting — functions

What a network camera says about itself, and setting its address by broadcast.

Every Optris network camera answers the discovery broadcast with one record about itself. get_network_discovery_info returns the whole of the last one this process heard, including the camera's MAC address and whether it can be configured by broadcast. configure_network_by_broadcast sets the address of the camera with a given MAC address without knowing the address it has now::

import optris_sdk

options = optris_sdk.EnumerationOptions(include_network=True)
for device in optris_sdk.enumerate_devices(options):
    info = optris_sdk.get_network_discovery_info(device.serial)
    if info and info.accepts_broadcast_config:
        reply = optris_sdk.configure_network_by_broadcast(
            info.mac_address, '10.0.2.213', '255.255.240.0')
        print(reply.status.name)

Mirrors GetNetworkDiscoveryInfo() and ConfigureNetworkByBroadcast() in C++ and optris_sdk_get_network_discovery_info() / optris_sdk_configure_network_by_broadcast() in C.

get_network_discovery_info(serial)

What the camera with this serial said the last time it answered discovery in this process, or None if it has not been heard.

Any discovery fills it in: optris_sdk.enumerate_devices with the network included, a device monitor watching the network, optris_sdk.probe_network. Nothing is sent by this call.

configure_network_by_broadcast(mac_address, ip_address, subnet_mask, gateway = '', immediately = False, timeout_s = None, attempts = 3)

Set the network address of the camera with this MAC address, by broadcast, without knowing the address it has now.

The request reaches every camera on this network segment (it does not cross a router); only the camera with that MAC address acts on it, and it answers by broadcast, so the answer arrives whatever subnet the camera is in. Only cameras whose protocol_version is 1001 or later understand it. No camera is opened or claimed.

  • Parameter mac_address — '9C:43:1E:70:40:3E', '9c-43-1e-70-40-3e' or '9C431E70403E'.
  • Parameter ip_address — the camera's new address.
  • Parameter subnet_mask — the mask for it.
  • Parameter gateway — '' or '0.0.0.0' for none.
  • Parameter immediately — apply at once rather than at the camera's next start. The default, False, is the recommended one.
  • Parameter timeout_s — how long to wait for the answer, in all. None uses the SDK's default of 3 s.
  • Parameter attempts — how many times to send while no answer has come.
  • Raises ConfigurationError — the MAC address, an address, the mask or the gateway is not one, or attempts is 0. Nothing was sent.
  • Raises DeviceError — the request could not be sent, or OTC_SDK_NO_HARDWARE is set.