spodes-rs 0.7.1

A pure-Rust DLMS/COSEM stack: interface classes, transport, xDLMS services and security (IEC 62056 and the СТО 34.01-5.1-006-2023 / Р 1323565.1 GOST profiles).
Documentation
use spodes_rs::classes::clock::{Clock, ClockConfig};
use spodes_rs::interface::InterfaceClass;
use spodes_rs::obis::ObisCode;
use spodes_rs::serialization::{deserialize_object, serialize_object};
use spodes_rs::types::attrs::DateTime;
use spodes_rs::types::CosemDataType;

fn main() {
    let obis = ObisCode::new(0, 0, 1, 0, 0, 255);
    let time = DateTime([0x07, 0xE5, 0x05, 0x01, 0x02, 0x10, 0x25, 0x12, 0x00, 0x00, 0x00, 0x00]);
    let config = ClockConfig {
        logical_name: obis.clone(),
        time,
        time_zone: 180,
        status: 1,
        daylight_savings_begin: DateTime([0x00; 12]),
        daylight_savings_end: DateTime([0x00; 12]),
        daylight_savings_deviation: 60,
        daylight_savings_enabled: true,
        clock_base: 2,
    };
    let mut clock = Clock::new(config);

    println!("Clock object: {clock:?}");
    println!("Logical name: {}", clock.logical_name());
    println!("Class ID: {}", clock.class_id());
    println!("Version: {}", clock.version());

    let serialized = serialize_object(&clock).expect("Serialization failed");
    println!("Serialized clock: {serialized:?}");

    let config = ClockConfig {
        logical_name: obis,
        time: DateTime([0u8; 12]),
        time_zone: 0,
        status: 0,
        daylight_savings_begin: DateTime([0u8; 12]),
        daylight_savings_end: DateTime([0u8; 12]),
        daylight_savings_deviation: 0,
        daylight_savings_enabled: false,
        clock_base: 0,
    };
    let mut deserialized = Clock::new(config);
    deserialize_object(&mut deserialized, &serialized).expect("Deserialization failed");
    println!("Deserialized clock: {deserialized:?}");

    let result = clock.invoke_method(1, None).expect("Adjust to quarter failed");
    println!("Adjust to quarter result: {result:?}");
    println!("Clock after adjust to quarter: {clock:?}");

    let new_time = CosemDataType::DateTime(vec![
        0x07, 0xE5, 0x05, 0x02, // Year: 2025, Month: 5, Day: 2
        0x03, // Day of week: Wednesday
        0x12, 0x00, 0x00, // Hour: 18, Minutes: 0, Seconds: 0
        0x00, // Hundredths of a second: 0
        0x00, 0x00, 0x00, // Deviation from UTC: 0
    ]);
    let result = clock.invoke_method(4, Some(new_time)).expect("Adjust to preset time failed");
    println!("Adjust to preset time result: {result:?}");
    println!("Clock after adjust to preset time: {clock:?}");
}