-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust: Add some initial information to README.md
Signed-off-by: Siddharth Chandrasekaran <[email protected]>
- Loading branch information
Showing
1 changed file
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,59 @@ | ||
# OSDP Rust library | ||
|
||
This crate is a rust wrapper for the C library [LibOSDP][1]. | ||
This crate is a rust wrapper for [LibOSDP][1] - the most popular open source | ||
library for creating OSDP devices. See github.cobm/goToMain/liosdp for more | ||
information. | ||
|
||
## Features | ||
|
||
- Supports secure channel communication (AES-128) | ||
- Can be used to setup a PD or CP mode of operation | ||
- Most OSDP specified commands and replies are supported (see [doc][3]) | ||
|
||
## Usage | ||
|
||
TODO | ||
To add libosdp to your rust project do: | ||
|
||
``` | ||
cargo add libosdp | ||
``` | ||
|
||
### Control Panel: | ||
|
||
A simplified CP implementation: | ||
|
||
``` | ||
let pd_info = 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(...)); | ||
} | ||
``` | ||
|
||
### Control panel | ||
See [examples][2] for a working implementation. | ||
|
||
TODO | ||
### Peripheral Device: | ||
|
||
### Peripheral device | ||
A simplified PD implementation: | ||
|
||
TODO | ||
``` | ||
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][2] for a working implementation. | ||
|
||
1: https://github.cobm/goToMain/liosdp | ||
1: https://github.cobm/goToMain/liosdp | ||
2: https://github.com/goToMain/libosdp/blob/master/rust/examples | ||
3: https://libosdp.sidcha.dev/protocol/commands-and-replies |