Crates.io | libosdp |
lib.rs | libosdp |
version | 0.1.9 |
source | src |
created_at | 2023-11-04 12:49:45.991712 |
updated_at | 2024-03-15 17:29:33.193583 |
description | Library implementation of IEC 60839-11-5 OSDP (Open Supervised Device Protocol) |
homepage | https://libosdp.sidcha.dev/ |
repository | https://github.com/goToMain/libosdp |
max_upload_size | |
id | 1025132 |
size | 139,387 |
This crate provides safe wrappers for accessing the C library LibOSDP. LibOSDP the most popular open source library for creating Open Supervised Device Protocol (OSDP) devices. For more information about the library or OSDP in general, see libosdp.sidcha.dev.
The documentation for this crate can be found here.
To add libosdp to your rust project, do:
cargo add libosdp
A simplified CP implementation:
let pd_info = vec! [ PdInfo::new(...), ... ];
let mut cp = ControlPanel::new(&mut pd_info)?;
cp.set_event_callback(|pd, event| {
println!("Received event from {pd}: {:?}", event);
});
loop {
cp.refresh();
cp.send_command(0, OsdpCommand::new(...));
}
See examples for a working implementation.
A simplified PD implementation:
let pd_info = PdInfo::new(...);
let mut pd = PeripheralDevice::new(&mut pd_info)?;
pd.set_command_callback(|cmd| {
println!("Received command {:?}", cmd);
});
loop {
pd.refresh();
cp.notify_event(OsdpEvent::new(...));
}
See examples for a working implementation.