Skip to content

Commit 613a37c

Browse files
committed
Get in sync with libosdp API changes regarding "osdp_status_report" and make the members of "OsdpStatusReport" public so they can be accessed from the application callback
1 parent b82d254 commit 613a37c

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

libosdp/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ embedded-io = { version = "0.6.1", features = ["alloc"] }
1818
libosdp-sys = { version = "3.1.0", path = "../libosdp-sys" }
1919
log = { version = "0.4.20", optional = true }
2020
serde = { version = "1.0.192", features = ["derive", "alloc"], default-features = false }
21+
serde_arrays = "0.2.0"
2122
thiserror = { version = "1.0.50", optional = true }
2223
defmt = { version = "0.3", optional = true, features = ["alloc"] }
2324
itoa = "1.0.11"

libosdp/src/events.rs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -287,45 +287,29 @@ impl From<OsdpStatusReportType> for libosdp_sys::osdp_status_report_type {
287287
/// Event to describe various status changes on PD
288288
///
289289
/// This event is used by the PD to indicate status such as input, output,
290-
/// tamper, etc.,. up to a maximum of 32 status bits can be reported. The values
290+
/// tamper, etc.,. up to a maximum of 64 status bits can be reported. The values
291291
/// of the least significant N bit of status are considered, where N is the
292292
/// number of items as described in the corresponding capability codes,
293293
/// - PdCapability::OutputControl
294294
/// - PdCapability::ContactStatusMonitoring
295295
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
296296
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
297297
pub struct OsdpStatusReport {
298-
type_: OsdpStatusReportType,
299-
nr_entries: usize,
300-
mask: u32,
301-
}
302-
303-
impl OsdpStatusReport {
304-
/// Create an input event with given bit mask
305-
pub fn new_input(nr_entries: usize, mask: u32) -> Self {
306-
Self {
307-
type_: OsdpStatusReportType::Input,
308-
nr_entries,
309-
mask,
310-
}
311-
}
312-
313-
/// Create an output event with given bit mask
314-
pub fn new_output(nr_entries: usize, mask: u32) -> Self {
315-
Self {
316-
type_: OsdpStatusReportType::Output,
317-
nr_entries,
318-
mask,
319-
}
320-
}
298+
/// The kind of event to report see `enum osdp_event_status_type_e`
299+
pub type_: OsdpStatusReportType,
300+
/// Number of valid entries in `report`
301+
pub nr_entries: usize,
302+
/// Status report
303+
#[serde(with = "serde_arrays")]
304+
pub report: [u8; 64],
321305
}
322306

323307
impl From<libosdp_sys::osdp_status_report> for OsdpStatusReport {
324308
fn from(value: libosdp_sys::osdp_status_report) -> Self {
325309
OsdpStatusReport {
326310
type_: value.type_.into(),
327311
nr_entries: value.nr_entries as usize,
328-
mask: value.mask,
312+
report: value.report,
329313
}
330314
}
331315
}
@@ -335,7 +319,7 @@ impl From<OsdpStatusReport> for libosdp_sys::osdp_status_report {
335319
libosdp_sys::osdp_status_report {
336320
type_: value.type_.into(),
337321
nr_entries: value.nr_entries as i32,
338-
mask: value.mask,
322+
report: value.report,
339323
}
340324
}
341325
}

0 commit comments

Comments
 (0)