6 #ifndef IFM3D_DEVICE_O3R_H
7 #define IFM3D_DEVICE_O3R_H
9 #include <ifm3d/common/features.h>
10 #include <ifm3d/device/device.h>
12 #ifdef BUILD_MODULE_CRYPTO
13 # include <ifm3d/crypto/crypto.h>
15 #include <ifm3d/device/pcic_command.h>
19 static const int NET_WAIT_O3R_SET =
20 std::getenv(
"IFM3D_NET_WAIT_O3R_SET") ==
nullptr ?
22 std::stoi(std::getenv(
"IFM3D_NET_WAIT_O3R_SET"));
32 #ifdef BUILD_MODULE_CRYPTO
43 using Ptr = std::shared_ptr<O3R>;
44 O3R(
const std::string& ip = ifm3d::DEFAULT_IP,
45 std::uint16_t xmlrpc_port = ifm3d::DEFAULT_XMLRPC_PORT);
49 O3R& operator=(
O3R&&) =
delete;
51 O3R& operator=(
O3R&) =
delete;
60 virtual void FactoryReset(
bool keep_network_settings);
79 const std::vector<std::string>& path = std::vector<std::string>());
89 json ResolveConfig(
const json::json_pointer& ptr);
98 void Set(
const json& j);
109 void Remove(
const std::string& json_pointer);
120 void Reset(
const std::string& json_pointer);
138 void SaveInit(
const std::vector<std::string>& pointers = {});
147 std::string GetInitStatus();
158 void Lock(
const std::string& password);
167 void Unlock(
const std::string& password);
175 std::vector<PortInfo> Ports();
184 PortInfo Port(
const std::string& port);
191 json GetDiagnostic();
199 json GetDiagnosticFilterSchema();
208 json GetDiagnosticFiltered(
const json& filter);
211 const BootMode& mode = ifm3d::Device::BootMode::PRODUCTIVE)
override;
216 void RebootToRecovery();
218 DeviceFamily WhoAmI()
override;
219 ifm3d::Device::SWUVersion SwUpdateVersion()
override;
225 json ToJSON()
override;
231 void FromJSON(
const json& j)
override;
233 void DownloadServiceReport(
const std::string& out_file);
235 #ifdef BUILD_MODULE_CRYPTO
240 std::shared_ptr<O3RSealedBox>
SealedBox();
245 enum Parameter : uint16_t
247 ODS_OVERHANGING_LOAD = 2003,
249 ODS_MAXIMUM_HEIGHT = 2102,
250 ODS_MOTION_DATA = 2103,
251 PDS_GET_PALLET = 2200,
254 PDS_VOL_CHECK = 2203,
258 std::vector<std::uint8_t> data;
262 std::vector<std::uint8_t> parameter_data)
264 data(std::move(parameter_data))
267 std::vector<std::uint8_t>
270 std::vector<std::uint8_t> payload;
273 payload.push_back(
static_cast<uint8_t
>(
'f'));
276 std::ostringstream param;
277 param << std::setw(5) << std::setfill(
'0')
278 <<
static_cast<uint16_t
>(parameter);
279 const std::string paramStr = param.str();
280 payload.insert(payload.end(), paramStr.begin(), paramStr.end());
283 const std::string reserved =
"#00000";
284 payload.insert(payload.end(), reserved.begin(), reserved.end());
287 payload.insert(payload.end(), data.begin(), data.end());
295 std::shared_ptr<Impl> _impl;
297 #ifdef BUILD_MODULE_CRYPTO
298 friend class O3RSealedBox;
302 #ifdef BUILD_MODULE_CRYPTO
310 class IFM3D_EXPORT O3RSealedBox
313 using Ptr = std::shared_ptr<O3RSealedBox>;
315 O3RSealedBox(
const O3RSealedBox&) =
default;
316 O3RSealedBox(O3RSealedBox&&) =
delete;
317 O3RSealedBox& operator=(
const O3RSealedBox&) =
default;
318 O3RSealedBox& operator=(O3RSealedBox&&) =
delete;
319 O3RSealedBox(std::shared_ptr<O3R::Impl> p_impl);
329 void SetPassword(
const std::string& new_password,
330 std::optional<std::string> old_password = std::nullopt);
337 bool IsPasswordProtected();
344 void RemovePassword(std::string password);
353 void Set(
const std::string& password,
const json& configuration);
361 std::vector<uint8_t> GetPublicKey();
364 std::shared_ptr<O3R::Impl> _impl;
369 #endif // IFM3D_DEVICE_O3R_H