1#![cfg_attr(not(feature = "std"), no_std)]
9
10extern crate alloc;
11use alloc::string::String;
12use serde::{Deserialize, Serialize};
13
14pub mod coap;
16pub mod mqtt;
17
18pub mod ble;
20pub mod gpio;
21pub mod i2c;
22pub mod modbus;
23
24pub mod anomaly;
26pub mod ui;
27
28pub mod mesh;
30pub mod ota;
31
32#[cfg(feature = "experimental-simulators")]
34pub mod hsm;
35#[cfg(feature = "experimental-simulators")]
36pub mod pqc;
37
38pub mod power;
40pub mod twin;
41
42pub use anomaly::{AnomalyDetector, AnomalyState};
44pub use ble::{GattCharacteristic, GattService};
45pub use coap::{CoapCodecError, CoapMessageType, CoapMethod, CoapRequest, MAX_COAP_DATAGRAM_BYTES};
46pub use gpio::{GpioPin, PinMode, PinState};
47#[cfg(feature = "experimental-simulators")]
48pub use hsm::{SimulatedHsmDevice, SimulatedHsmProfile};
49pub use i2c::I2cHelper;
50pub use mesh::{MeshNode, MeshTopology, NodeStatus};
51pub use modbus::{ModbusFrame, ModbusFunction};
52#[cfg(feature = "experimental-simulators")]
53pub use mqtt::SimulatedMqttPayloadFormatter;
54pub use mqtt::{MAX_MQTT_PACKET_BYTES, MqttCodecError, MqttPublish, MqttQos};
55pub use ota::{
56 BootPartition, OtaCommit, OtaError, OtaManager, OtaManifest, OtaStatus, RollbackCounterError,
57 RollbackCounterStore,
58};
59pub use power::{HarvesterState, PowerGovernor, PowerMode};
60#[cfg(feature = "experimental-simulators")]
61pub use pqc::SimulatedPqcFixture;
62pub use twin::{DigitalTwin, TwinSyncError};
63pub use ui::IotDashboard;
64
65#[derive(Clone, Debug, Serialize, Deserialize)]
67pub struct SensorTelemetry {
68 pub device_id: String,
70 pub metric: String,
72 pub value: f64,
74 pub timestamp: u64,
76}
77
78impl SensorTelemetry {
79 pub fn new(
81 device_id: impl Into<String>,
82 metric: impl Into<String>,
83 value: f64,
84 timestamp: u64,
85 ) -> Self {
86 Self {
87 device_id: device_id.into(),
88 metric: metric.into(),
89 value,
90 timestamp,
91 }
92 }
93}
94
95#[cfg(test)]
96mod tests {
97 use super::*;
98
99 #[test]
100 fn test_sensor_telemetry() {
101 let t = SensorTelemetry::new("esp32-node-01", "temperature", 24.5, 1700000000);
102 assert_eq!(t.device_id, "esp32-node-01");
103 assert_eq!(t.metric, "temperature");
104 assert_eq!(t.value, 24.5);
105 }
106}