From ccb500841e6c43256db4ee6bf09d8415d1c7ae20 Mon Sep 17 00:00:00 2001 From: Vikas Date: Mon, 16 Dec 2024 17:32:43 +0530 Subject: [PATCH] Added python binding methods for device_discovery and set_temp_ip_address --- ChangeLog.md | 1 + modules/pybind11/src/bindings/device.h | 50 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 49d5a921..a36b6004 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- Added missing Python binding methods - Added support for Python 3.13 and dropped support for Python 3.8.10 - Added support for Ubuntu `24.04` and dropped support for Ubuntu `18.04` diff --git a/modules/pybind11/src/bindings/device.h b/modules/pybind11/src/bindings/device.h index f25150fd..00cc4a5d 100644 --- a/modules/pybind11/src/bindings/device.h +++ b/modules/pybind11/src/bindings/device.h @@ -8,9 +8,34 @@ #include +void +bind_ifmnetworkdevice(pybind11::module_& m) +{ + py::class_(m, "IFMNetworkDevice") + .def(py::init&, const std::string&>(), + py::arg("data"), + py::arg("ip_address_via_interface")) + + .def_property_readonly("ip_address", + &ifm3d::IFMNetworkDevice::GetIPAddress) + .def_property_readonly("mac_address", + &ifm3d::IFMNetworkDevice::GetMACAddress) + .def_property_readonly("netmask", &ifm3d::IFMNetworkDevice::GetNetmask) + .def_property_readonly("gateway", &ifm3d::IFMNetworkDevice::GetGateway) + .def_property_readonly("port", &ifm3d::IFMNetworkDevice::GetPort) + .def_property_readonly("flag", &ifm3d::IFMNetworkDevice::GetFlag) + .def_property_readonly("host_name", &ifm3d::IFMNetworkDevice::GetHostName) + .def_property_readonly("device_name", + &ifm3d::IFMNetworkDevice::GetDeviceName) + .def_property_readonly("vendor_id", &ifm3d::IFMNetworkDevice::GetVendorId) + .def_property_readonly("device_id", &ifm3d::IFMNetworkDevice::GetDeviceId) + .def_property_readonly("found_via", &ifm3d::IFMNetworkDevice::GetFoundVia); +} + void bind_device(pybind11::module_& m) { + bind_ifmnetworkdevice(m); // clang-format off py::class_ device( m, "Device", @@ -329,6 +354,31 @@ bind_device(pybind11::module_& m) as descriptive as possible as to the specific error that has occured. )"); + + device.def( + "device_discovery", &ifm3d::Device::DeviceDiscovery, + R"( + Discover the list of devices in the network. + + Returns: + list[dict]: A list of dictionaries, each containing the device's + IP address, MAC address and type. + )"); + + device.def( + "set_temp_ip_address", + &ifm3d::Device::SetTempIPAddress, + R"( + Set temporary IP address + + Parameters + ---------- + mac : string + MAC address of the device + + temp_ip : string + Temporary IP addres of the device + )"); // clang-format on }