Skip to main content
Connecting takes three steps: scan the local network and local USB bus for a device list, locate the target by serial number, address, or handedness, and let the SDK hold the connection until you close it explicitly. Python and C share the same semantics. They differ in error reporting and handle lifetime.

Device Discovery

Scan for Wuji devices connected via Ethernet on the local network or over USB:
Each discovered record carries the serial number, address, and device type, so you can tell what a device is before connecting. In Python, DiscoveredDevice.device_type is a DeviceType enum (WujiGlove / WujiHand2 / WujiHand). In C, WujiDiscovered.device_id is a WujiDeviceType enum (WUJI_DEVICE_TYPE_WUJI_GLOVE / _WUJI_HAND_2 / _WUJI_HAND). Unknown and WUJI_DEVICE_TYPE_UNKNOWN mean the type was not available at scan time or isn’t recognized by this SDK build.
Network prerequisite: Ethernet devices use static IPs, not DHCP. Before scanning or connecting, set your host NIC to the same subnet (for example 192.168.1.50, avoiding the device default addresses), or the devices can’t be discovered or reached.

Connecting to a Device

device_name in all connect APIs is a local alias, used only to look up the device later and to namespace resource paths. It does not select a device and does not determine the returned handle type. The returned type is determined by the actual connected device. The name must be non-empty and must not contain / or ..

Choose a Connection Method

Pick by how many devices are currently discovered. See Auto Connect, Connect by SN, Connect by Address, Connect by USB, and Connect by Handedness:
Any method can take Connection Options to configure timeout, retries, and device sharing.

Auto Connect

auto_connect() connects to the single device currently discovered. If multiple devices are present, the call fails because the target is ambiguous. Use connect() to disambiguate in that case:
C has no equivalent. Call wuji_scan(), confirm the list holds exactly one record, then take its serial_number and follow Connect by SN.

Connect by SN

Connect to a specific device by serial number:

Connect by Address

Manually connect using IP address and port:
Include the port in the address. Use IP:port for IPv4. IPv6 addresses aren’t supported. A bare IP address returns a missing-port error instead of being treated as a USB path. Serial port paths aren’t supported either — scan first, then connect by SN.

Connect by USB

Wuji Hand attaches over USB. Filter the scan results by transport type, then connect by serial number:
wuji_hand_connect_sn() is shorthand for wuji_connect() with SN targeting. Both return the same kind of device handle. If a matching-handedness tactile glove is plugged in alongside the hand, the SDK auto-pairs it on connect. Check with hand.is_tactile_attached() in Python or wuji_hand_is_tactile_attached() in C. The value reflects the current attachment and turns false after the glove is unplugged at runtime. Once unplugged, the tactile status stream’s state becomes 0 (not present), other tactile reads and subscriptions fail with a tactile_not_present error, and the hand itself keeps working. Re-attaching the glove requires reconnecting the hand.

Connect by Handedness

Connect to a two-handed device (such as Wuji Hand 2 or Wuji Glove) by left or right hand, without looking up a serial number first. The SDK scans the local network and selects the unique device by the fourth character of its serial number (J for left, K for right):
handedness is mutually exclusive with sn and address—specify only one. C has no equivalent. In the wuji_scan() results, match serial_number[3] against 'J' or 'K' to isolate the target, then follow Connect by SN.
In Python, if no device matches the handedness, DeviceNotFound is raised. If multiple devices share the handedness, AmbiguousHandedness is raised with all candidate serial numbers. Specify sn explicitly instead.

Connection Options

Configure timeout, retries, and device sharing:
enable_bridge (on by default) controls whether multiple SDK instances (including processes on other hosts) can connect to the same device. When enabled, this process shares the connected device. Turn it off for exclusive access — other instances can’t reach the device through this process. In C, always start from wuji_connect_options_default() and override only the fields you need. Zero-initializing the whole struct also clears enable_bridge and background time sync, which changes connection behavior. Pass NULL to wuji_connect() when the defaults are fine.

Multi-device Management

The SDK supports connecting multiple devices simultaneously, each identified by a unique device_name:
Use different device_name values to keep the left and right hand in the same process. Reconnecting to an already-active device raises SessionAlreadyExists in Python and returns a failure status in C. Neither drops the existing connection — keep using the existing handle.

Disconnecting

When a device is disconnected, all subscriptions on that device are automatically closed. You’ll need to re-establish subscriptions after reconnecting.
The SDK owns the connection, and dropping a device object or handle variable doesn’t close it. In Python, deleting or replacing a device object leaves the connection active until you call disconnect() or disconnect_all(), or until the process exits, so long-running programs should disconnect explicitly in a finally block. In C, wuji_dev_release() only returns the handle, so call wuji_dev_disconnect() before releasing it. With an exclusive connection, leaving the connection open also prevents other clients from connecting to the device.

Interface List

Python reports failures as exceptions. C reports them as WujiStatus return codes, with the reason available from wuji_last_error(). For build flags, linking, memory ownership, and the full status code list, see the C Interface Reference.