Skip to content

Commit

Permalink
doc: Add info about Rust support and fix some other stuff
Browse files Browse the repository at this point in the history
Signed-off-by: Siddharth Chandrasekaran <[email protected]>
  • Loading branch information
sidcha committed Nov 4, 2023
1 parent 4c86c9b commit b4ed3a1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 41 deletions.
60 changes: 27 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,38 @@ This protocol is developed and maintained by [Security Industry Association][20]

## Salient Features of LibOSDP

- Supports secure channel communication (AES-128).
- Can be used to setup a PD or CP mode of operation.
- Exposes a well defined contract though a single header file.
- No run-time memory allocation. All memory is allocated at init-time.
- No external dependencies (for ease of cross compilation).
- Fully non-blocking, asynchronous design.
- Provides Python3 bindings for the C library for faster testing/integration.
- Supports secure channel communication (AES-128)
- Can be used to setup a PD or CP mode of operation
- Exposes a well defined contract though a single header file
- No run-time memory allocation. All memory is allocated at init-time
- No external dependencies (for ease of cross compilation)
- Fully non-blocking, asynchronous design
- Provides Python3 and Rust bindings for the C library for faster
testing/integration

## C API
## Language Support

LibOSDP exposes a [minimal set of API][26] to setup and manage the lifecycle of
OSDP devices. See `include/osdp.h` for more details.
### C API

## Python API
LibOSDP is written in C. It exposes a [minimal set of API][26] to setup and
manage the lifecycle of OSDP devices. See `include/osdp.h` for more details.

To setup a device as a Control Panel in Python, you'd do something like this:
### Rust API

```python
import osdp
LibOSDP is now available via [crates.io/crates/libosdp][32]. See
[rust/README.md][33] for more info and usage examples.

## Setup OSDP device in Control Panel mode
cp = osdp.ControlPanel(pd_info, master_key=key)
### Python API

## send a output command to PD-1
cp.send_command(1, output_cmd)
```

Similarly, for Peripheral Device,

```python
import osdp
There are currently two python implementation within this repo:

## Setup OSDP device in Peripheral Device mode
pd = osdp.PeripheralDevice(pd_info, capabilities=pd_cap)

## Set a handler for incoming commands from CP
pd.set_command_callback(command_handler_fn)
```
1. A [basic wrapper][29] around LibOSDP.
2. A more [idiomatic python module][30] that builds on top of the basic wrapper.

For more details, look at [cp_app.py][29] and [pd_app.py][30].
Although both implementations are considered fairly mature, neither have been
submitted to pypi.org due to lack of time (PRs in this direction are
appreciated). The plan at this time is to merge both of these implementation
into `python/`.

## Supported Commands and Replies

Expand Down Expand Up @@ -206,6 +198,8 @@ The OSDP specification can be obtained from SIA for a cost. Read more at our
[26]: https://libosdp.sidcha.dev/api/
[27]: https://libosdp.sidcha.dev/protocol/faq.html
[28]: https://github.com/goToMain/libosdp/issues/new/choose
[29]: https://github.com/goToMain/libosdp/blob/master/samples/python/cp_app.py
[30]: https://github.com/goToMain/libosdp/blob/master/samples/python/pd_app.py
[29]: https://github.com/goToMain/libosdp/blob/master/python
[30]: https://github.com/goToMain/libosdp/tree/master/tests/pytest/testlib
[31]: https://github.com/goToMain/libosdp/issues
[32]: https://crates.io/crates/libosdp
[33]: https://github.com/goToMain/libosdp/tree/master/rust
3 changes: 0 additions & 3 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ OSDP - Open Supervised Device Protocol
.. image:: https://img.shields.io/github/license/goToMain/libosdp
:target: https://github.com/goToMain/libosdp/
:alt: License
.. image:: https://api.codacy.com/project/badge/Grade/7b6f389d4fbf46a692b64d3e82452af9
:target: https://app.codacy.com/manual/siddharth_6/libosdp?utm_source=github.com&utm_medium=referral&utm_content=cbsiddharth/libosdp&utm_campaign=Badge_Grade_Dashboard
:alt: Code Coverage
.. image:: https://github.com/goToMain/libosdp/workflows/Build%20CI/badge.svg
:target: https://github.com/goToMain/libosdp/actions?query=workflow%3A%22Build+CI%22
:alt: Build status
Expand Down
11 changes: 6 additions & 5 deletions rust/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# OSDP Rust library
# LibOSDP for Rust

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.
library for creating Open Supervised Device Protocol (OSDP) devices. See
https://github.cobm/goToMain/liosdp for more information.

## Features

- Production ready implementation with active users and contributors
- 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])
Expand All @@ -22,7 +23,7 @@ cargo add libosdp

A simplified CP implementation:

```
```rust
let pd_info = PdInfo::new(...);
let mut cp = ControlPanel::new(&mut pd_info)?;
cp.set_event_callback(|pd, event| {
Expand All @@ -40,7 +41,7 @@ See [examples][2] for a working implementation.

A simplified PD implementation:

```
```rust
let pd_info = PdInfo::new(...);
let mut pd = PeripheralDevice::new(&mut pd_info)?;
pd.set_command_callback(|cmd| {
Expand Down

0 comments on commit b4ed3a1

Please sign in to comment.