1pub const OSDP_FLAG_ENFORCE_SECURE: u32 = 65536;
4pub const OSDP_FLAG_INSTALL_MODE: u32 = 131072;
5pub const OSDP_FLAG_IGN_UNSOLICITED: u32 = 262144;
6pub const OSDP_FLAG_ENABLE_NOTIFICATION: u32 = 524288;
7pub const OSDP_FLAG_CAPTURE_PACKETS: u32 = 1048576;
8pub const OSDP_FLAG_ALLOW_EMPTY_ENCRYPTED_DATA_BLOCK: u32 = 2097152;
9pub const OSDP_STATUS_REPORT_MAX_LEN: u32 = 64;
10pub const OSDP_CMD_TEXT_MAX_LEN: u32 = 32;
11pub const OSDP_CMD_KEYSET_KEY_MAX_LEN: u32 = 32;
12pub const OSDP_CMD_MFG_MAX_DATALEN: u32 = 64;
13pub const OSDP_CMD_FILE_TX_FLAG_CANCEL: u32 = 2147483648;
14pub const OSDP_CMD_FLAG_BROADCAST: u32 = 1;
15pub const OSDP_EVENT_CARDREAD_MAX_DATALEN: u32 = 64;
16pub const OSDP_EVENT_KEYPRESS_MAX_DATALEN: u32 = 64;
17pub const OSDP_EVENT_MFGREP_MAX_DATALEN: u32 = 128;
18#[doc = " Dummy."]
19pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_UNUSED: osdp_pd_cap_function_code_e = 0;
20#[doc = " This function indicates the ability to monitor the status of a switch\n using a two-wire electrical connection between the PD and the switch.\n The on/off position of the switch indicates the state of an external\n device.\n\n The PD may simply resolve all circuit states to an open/closed\n status, or it may implement supervision of the monitoring circuit. A\n supervised circuit is able to indicate circuit fault status in\n addition to open/closed status."]
21pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_CONTACT_STATUS_MONITORING:
22 osdp_pd_cap_function_code_e = 1;
23#[doc = " This function provides a switched output, typically in the form of a\n relay. The Output has two states: active or inactive. The Control\n Panel (CP) can directly set the Output's state, or, if the PD\n supports timed operations, the CP can specify a time period for the\n activation of the Output."]
24pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_OUTPUT_CONTROL: osdp_pd_cap_function_code_e = 2;
25#[doc = " This capability indicates the form of the card data is presented to\n the Control Panel."]
26pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_CARD_DATA_FORMAT: osdp_pd_cap_function_code_e = 3;
27#[doc = " This capability indicates the presence of and type of LEDs."]
28pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_READER_LED_CONTROL: osdp_pd_cap_function_code_e =
29 4;
30#[doc = " This capability indicates the presence of and type of an Audible\n Annunciator (buzzer or similar tone generator)"]
31pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_READER_AUDIBLE_OUTPUT:
32 osdp_pd_cap_function_code_e = 5;
33#[doc = " This capability indicates that the PD supports a text display\n emulating character-based display terminals."]
34pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_READER_TEXT_OUTPUT: osdp_pd_cap_function_code_e =
35 6;
36#[doc = " This capability indicates that the type of date and time awareness\n or time keeping ability of the PD."]
37pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_TIME_KEEPING: osdp_pd_cap_function_code_e = 7;
38#[doc = " All PDs must be able to support the checksum mode. This capability\n indicates if the PD is capable of supporting CRC mode."]
39pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_CHECK_CHARACTER_SUPPORT:
40 osdp_pd_cap_function_code_e = 8;
41#[doc = " This capability indicates the extent to which the PD supports\n communication security (Secure Channel Communication)"]
42pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_COMMUNICATION_SECURITY:
43 osdp_pd_cap_function_code_e = 9;
44#[doc = " This capability indicates the maximum size single message the PD can\n receive."]
45pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_RECEIVE_BUFFERSIZE: osdp_pd_cap_function_code_e =
46 10;
47#[doc = " This capability indicates the maximum size multi-part message which\n the PD can handle."]
48pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_LARGEST_COMBINED_MESSAGE_SIZE:
49 osdp_pd_cap_function_code_e = 11;
50#[doc = " This capability indicates whether the PD supports the transparent\n mode used for communicating directly with a smart card."]
51pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_SMART_CARD_SUPPORT: osdp_pd_cap_function_code_e =
52 12;
53#[doc = " This capability indicates the number of credential reader devices\n present. Compliance levels are bit fields to be assigned as needed."]
54pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_READERS: osdp_pd_cap_function_code_e = 13;
55#[doc = " This capability indicates the ability of the reader to handle\n biometric input"]
56pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_BIOMETRICS: osdp_pd_cap_function_code_e = 14;
57#[doc = " This capability indicates if the reader is capable of supporting\n Secure Pin Entry (SPE) for smart cards"]
58pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_SECURE_PIN_ENTRY: osdp_pd_cap_function_code_e =
59 15;
60#[doc = " This capability indicates the version of OSDP the PD supports\n\n Compliance Levels:\n 0 - Unspecified\n 1 - IEC 60839-11-5\n 2 - SIA OSDP 2.2"]
61pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_OSDP_VERSION: osdp_pd_cap_function_code_e = 16;
62#[doc = " Capability Sentinel"]
63pub const osdp_pd_cap_function_code_e_OSDP_PD_CAP_SENTINEL: osdp_pd_cap_function_code_e = 17;
64#[doc = " @brief Various PD capability function codes."]
65pub type osdp_pd_cap_function_code_e = ::core::ffi::c_uchar;
66#[doc = "< No error"]
67pub const osdp_pd_nak_code_e_OSDP_PD_NAK_NONE: osdp_pd_nak_code_e = 0;
68#[doc = "< Message check character(s) error (bad cksum/crc)"]
69pub const osdp_pd_nak_code_e_OSDP_PD_NAK_MSG_CHK: osdp_pd_nak_code_e = 1;
70#[doc = "< Command length error"]
71pub const osdp_pd_nak_code_e_OSDP_PD_NAK_CMD_LEN: osdp_pd_nak_code_e = 2;
72#[doc = "< Unknown Command Code – Command not implemented by PD"]
73pub const osdp_pd_nak_code_e_OSDP_PD_NAK_CMD_UNKNOWN: osdp_pd_nak_code_e = 3;
74#[doc = "< Sequence number error"]
75pub const osdp_pd_nak_code_e_OSDP_PD_NAK_SEQ_NUM: osdp_pd_nak_code_e = 4;
76#[doc = "< Secure Channel is not supported by PD"]
77pub const osdp_pd_nak_code_e_OSDP_PD_NAK_SC_UNSUP: osdp_pd_nak_code_e = 5;
78#[doc = "< unsupported security block or security conditions not met"]
79pub const osdp_pd_nak_code_e_OSDP_PD_NAK_SC_COND: osdp_pd_nak_code_e = 6;
80#[doc = "< BIO_TYPE not supported"]
81pub const osdp_pd_nak_code_e_OSDP_PD_NAK_BIO_TYPE: osdp_pd_nak_code_e = 7;
82#[doc = "< BIO_FORMAT not supported"]
83pub const osdp_pd_nak_code_e_OSDP_PD_NAK_BIO_FMT: osdp_pd_nak_code_e = 8;
84#[doc = "< Unable to process command record"]
85pub const osdp_pd_nak_code_e_OSDP_PD_NAK_RECORD: osdp_pd_nak_code_e = 9;
86#[doc = "< NAK codes max value"]
87pub const osdp_pd_nak_code_e_OSDP_PD_NAK_SENTINEL: osdp_pd_nak_code_e = 10;
88#[doc = " @brief OSDP specified NAK codes"]
89pub type osdp_pd_nak_code_e = ::core::ffi::c_uchar;
90#[doc = " @brief PD capability structure. Each PD capability has a 3 byte\n representation."]
91#[repr(C)]
92#[derive(Debug, Copy, Clone)]
93pub struct osdp_pd_cap {
94 #[doc = " Capability function code. See @ref osdp_pd_cap_function_code_e"]
95 pub function_code: u8,
96 #[doc = " A function_code dependent number that indicates what the PD can do\n with this capability."]
97 pub compliance_level: u8,
98 #[doc = " Number of such capability entities in PD"]
99 pub num_items: u8,
100}
101#[doc = " @brief PD ID information advertised by the PD."]
102#[repr(C)]
103#[derive(Debug, Copy, Clone)]
104pub struct osdp_pd_id {
105 #[doc = "< 1-Byte Manufacturer's version number"]
106 pub version: ::core::ffi::c_int,
107 #[doc = "< 1-byte Manufacturer's model number"]
108 pub model: ::core::ffi::c_int,
109 #[doc = "< 3-bytes IEEE assigned OUI"]
110 pub vendor_code: u32,
111 #[doc = "< 4-byte serial number for the PD"]
112 pub serial_number: u32,
113 #[doc = "< 3-byte version (major, minor, build)"]
114 pub firmware_version: u32,
115}
116#[doc = " @brief pointer to function that copies received bytes into buffer. This\n function should be non-blocking.\n\n @param data for use by underlying layers. osdp_channel::data is passed\n @param buf byte array copy incoming data\n @param maxlen sizeof `buf`. Can copy utmost `maxlen` bytes into `buf`\n\n @retval +ve: number of bytes copied on to `buf`. Must be <= `len`\n @retval -ve on errors"]
117pub type osdp_read_fn_t = ::core::option::Option<
118 unsafe extern "C" fn(
119 data: *mut ::core::ffi::c_void,
120 buf: *mut u8,
121 maxlen: ::core::ffi::c_int,
122 ) -> ::core::ffi::c_int,
123>;
124#[doc = " @brief Pointer to function used to receive a full packet buffer.\n The callee returns a pointer and a max_len up to which LibOSDP may\n access the buffer. The caller must invoke release_pkt() when done.\n\n @param data for use by underlying layers. osdp_channel::data is passed\n @param buf output pointer to the packet buffer\n @param max_len output maximum length LibOSDP may touch in this buffer\n @return 0 when a complete packet is available; non-zero otherwise"]
125pub type osdp_read_pkt_fn_t = ::core::option::Option<
126 unsafe extern "C" fn(
127 data: *mut ::core::ffi::c_void,
128 buf: *mut *const u8,
129 max_len: *mut ::core::ffi::c_int,
130 ) -> ::core::ffi::c_int,
131>;
132#[doc = " @brief pointer to function that sends byte array into some channel. This\n function should be non-blocking.\n\n @param data for use by underlying layers. osdp_channel::data is passed\n @param buf byte array to be sent\n @param len number of bytes in `buf`\n\n @retval +ve: number of bytes sent. must be <= `len`\n @retval -ve on errors\n\n @note For now, LibOSDP expects method to write/queue all or no bytes over\n the channel per-invocation; ie., it does not support partial writes and is a\n known limitation. Since an OSDP packet isn't so large, and typical TX\n buffers are much larger than that, it's not as bad as it sounds and hence\n not on the priority list to be fixed."]
133pub type osdp_write_fn_t = ::core::option::Option<
134 unsafe extern "C" fn(
135 data: *mut ::core::ffi::c_void,
136 buf: *mut u8,
137 len: ::core::ffi::c_int,
138 ) -> ::core::ffi::c_int,
139>;
140#[doc = " @brief pointer to function that drops all bytes in TX/RX fifo. This\n function should be non-blocking.\n\n @param data for use by underlying layers. osdp_channel::data is passed"]
141pub type osdp_flush_fn_t =
142 ::core::option::Option<unsafe extern "C" fn(data: *mut ::core::ffi::c_void)>;
143#[doc = " @brief pointer to function that closes the underlying channel. This call is\n made when LibOSDP is terminating, once per PD.\n\n @param data for use by underlying layers. osdp_channel::data is passed"]
144pub type osdp_close_fn_t =
145 ::core::option::Option<unsafe extern "C" fn(data: *mut ::core::ffi::c_void)>;
146#[doc = " @brief Pointer to function used to release a buffer returned by recv_pkt().\n\n @param data for use by underlying layers. osdp_channel::data is passed\n @param buf pointer that was returned by recv_pkt()"]
147pub type osdp_release_pkt_fn_t =
148 ::core::option::Option<unsafe extern "C" fn(data: *mut ::core::ffi::c_void, buf: *const u8)>;
149#[doc = " @brief User defined communication channel abstraction for OSDP devices.\n The methods for read/write/flush are expected to be non-blocking."]
150#[repr(C)]
151#[derive(Debug, Copy, Clone)]
152pub struct osdp_channel {
153 #[doc = " pointer to a block of memory that will be passed to the\n send/receive/flush method. This is optional (can be set to NULL)"]
154 pub data: *mut ::core::ffi::c_void,
155 #[doc = " channel_id; On multi-drop networks, more than one PD can share the\n same channel (read/write/flush pointers). On such networks, the\n channel_id is used to lock a PD to a channel. On multi-drop\n networks, this `id` must non-zero and be unique for each bus."]
156 pub id: ::core::ffi::c_int,
157 #[doc = " Pointer to function used to receive osdp packet data"]
158 pub recv: osdp_read_fn_t,
159 #[doc = " Pointer to function used to receive a full packet buffer (optional)"]
160 pub recv_pkt: osdp_read_pkt_fn_t,
161 #[doc = " Pointer to function used to send osdp packet data"]
162 pub send: osdp_write_fn_t,
163 #[doc = " Pointer to function used to flush the channel (optional)"]
164 pub flush: osdp_flush_fn_t,
165 #[doc = " Pointer to function used to release recv_pkt() data (optional)"]
166 pub release_pkt: osdp_release_pkt_fn_t,
167 #[doc = " Pointer to function used to close the channel (optional)"]
168 pub close: osdp_close_fn_t,
169}
170#[doc = " @brief OSDP PD Information. This struct is used to describe a PD to LibOSDP."]
171#[repr(C)]
172#[derive(Debug, Copy, Clone)]
173pub struct osdp_pd_info_t {
174 #[doc = " User provided name for this PD (log messages include this name)"]
175 pub name: *const ::core::ffi::c_char,
176 #[doc = " Can be one of 9600/19200/38400/57600/115200/230400"]
177 pub baud_rate: ::core::ffi::c_int,
178 #[doc = " 7 bit PD address. the rest of the bits are ignored. The special\n address 0x7F is used for broadcast. So there can be 2^7-1 devices on\n a multi-drop channel"]
179 pub address: ::core::ffi::c_int,
180 #[doc = " Used to modify the way the context is setup. See `OSDP_FLAG_*`\n macros."]
181 pub flags: ::core::ffi::c_int,
182 #[doc = " Static information that the PD reports to the CP when it received a\n `CMD_ID`. These information must be populated by a PD application."]
183 pub id: osdp_pd_id,
184 #[doc = " This is a pointer to an array of structures containing the PD'\n capabilities. Use { -1, 0, 0 } to terminate the array. This is used\n only PD mode of operation"]
185 pub cap: *const osdp_pd_cap,
186 #[doc = " Communication channel ops structure, containing send/recv function\n pointers"]
187 pub channel: osdp_channel,
188 #[doc = " Pointer to 16 bytes of Secure Channel Base Key for the PD. If\n non-null, this is used to set-up the secure channel."]
189 pub scbk: *const u8,
190}
191#[doc = " @brief To keep the OSDP internal data structures from polluting the exposed\n headers, they are typedefed to void before sending them to the upper layers.\n This level of abstraction looked reasonable as _technically_ no one should\n attempt to modify it outside of the LibOSDP and their definition may change\n at any time."]
192pub type osdp_t = ::core::ffi::c_void;
193#[doc = " @brief Status report of the inputs attached the PD"]
194pub const osdp_status_report_type_OSDP_STATUS_REPORT_INPUT: osdp_status_report_type = 0;
195#[doc = " @brief Status report of the output attached the PD"]
196pub const osdp_status_report_type_OSDP_STATUS_REPORT_OUTPUT: osdp_status_report_type = 1;
197#[doc = " @brief Local tamper and power status report\n\n Bit-0: tamper\n Bit-1: power"]
198pub const osdp_status_report_type_OSDP_STATUS_REPORT_LOCAL: osdp_status_report_type = 2;
199#[doc = " @brief Remote tamper and power status report\n\n Bit-0: tamper\n Bit-1: power"]
200pub const osdp_status_report_type_OSDP_STATUS_REPORT_REMOTE: osdp_status_report_type = 3;
201#[doc = " @brief OSDP Status report types"]
202pub type osdp_status_report_type = ::core::ffi::c_uchar;
203#[doc = " @brief Status report structure. Used by OSDP_CMD_STATUS and\n OSDP_EVENT_STATUS. In case of command, it is used to send a query to the PD\n while in the case of events, the PD responds back with this structure.\n\n This can is used by the PD to indicate various status change reports. Upto a\n maximum of 32 statuses can be reported using this API."]
204#[repr(C)]
205#[derive(Debug, Copy, Clone)]
206pub struct osdp_status_report {
207 #[doc = " The kind of event to report see `enum osdp_event_status_type_e`"]
208 pub type_: osdp_status_report_type,
209 #[doc = " Number of valid bits in `status`"]
210 pub nr_entries: ::core::ffi::c_int,
211 #[doc = " Status report"]
212 pub report: [u8; 64usize],
213}
214#[doc = " @brief Command sent from CP to Control digital output of PD."]
215#[repr(C)]
216#[derive(Debug, Copy, Clone)]
217pub struct osdp_cmd_output {
218 #[doc = " 0 = First Output, 1 = Second Output, etc."]
219 pub output_no: u8,
220 #[doc = " One of the following:\n 0 - NOP – do not alter this output\n 1 - set the permanent state to OFF, abort timed operation (if any)\n 2 - set the permanent state to ON, abort timed operation (if any)\n 3 - set the permanent state to OFF, allow timed operation to complete\n 4 - set the permanent state to ON, allow timed operation to complete\n 5 - set the temporary state to ON, resume perm state on timeout\n 6 - set the temporary state to OFF, resume permanent state on timeout"]
221 pub control_code: u8,
222 #[doc = " Time in units of 100 ms"]
223 pub timer_count: u16,
224}
225#[doc = "< No color"]
226pub const osdp_led_color_e_OSDP_LED_COLOR_NONE: osdp_led_color_e = 0;
227#[doc = "< Red"]
228pub const osdp_led_color_e_OSDP_LED_COLOR_RED: osdp_led_color_e = 1;
229#[doc = "< Green"]
230pub const osdp_led_color_e_OSDP_LED_COLOR_GREEN: osdp_led_color_e = 2;
231#[doc = "< Amber"]
232pub const osdp_led_color_e_OSDP_LED_COLOR_AMBER: osdp_led_color_e = 3;
233#[doc = "< Blue"]
234pub const osdp_led_color_e_OSDP_LED_COLOR_BLUE: osdp_led_color_e = 4;
235#[doc = "< Magenta"]
236pub const osdp_led_color_e_OSDP_LED_COLOR_MAGENTA: osdp_led_color_e = 5;
237#[doc = "< Cyan"]
238pub const osdp_led_color_e_OSDP_LED_COLOR_CYAN: osdp_led_color_e = 6;
239#[doc = "< White"]
240pub const osdp_led_color_e_OSDP_LED_COLOR_WHITE: osdp_led_color_e = 7;
241#[doc = "< Max value"]
242pub const osdp_led_color_e_OSDP_LED_COLOR_SENTINEL: osdp_led_color_e = 8;
243#[doc = " @brief LED Colors as specified in OSDP for the on_color/off_color\n parameters."]
244pub type osdp_led_color_e = ::core::ffi::c_uchar;
245#[doc = " @brief LED params sub-structure. Part of LED command. See @ref osdp_cmd_led."]
246#[repr(C)]
247#[derive(Debug, Copy, Clone)]
248pub struct osdp_cmd_led_params {
249 #[doc = " Control code.\n\n Temporary Control Code:\n - 0 - NOP - do not alter this LED's temporary settings.\n - 1 - Cancel any temporary operation and display this LED's\n permanent state immediately.\n - 2 - Set the temporary state as given and start timer immediately.\n\n Permanent Control Code:\n - 0 - NOP - do not alter this LED's permanent settings.\n - 1 - Set the permanent state as given."]
250 pub control_code: u8,
251 #[doc = " The ON duration of the flash, in units of 100 ms."]
252 pub on_count: u8,
253 #[doc = " The OFF duration of the flash, in units of 100 ms."]
254 pub off_count: u8,
255 #[doc = " Color to set during the ON timer (see @ref osdp_led_color_e)."]
256 pub on_color: u8,
257 #[doc = " Color to set during the OFF timer (see @ref osdp_led_color_e)."]
258 pub off_color: u8,
259 #[doc = " Time in units of 100 ms (only for temporary mode)."]
260 pub timer_count: u16,
261}
262#[doc = " @brief Sent from CP to PD to control the behaviour of it's on-board LEDs"]
263#[repr(C)]
264#[derive(Debug, Copy, Clone)]
265pub struct osdp_cmd_led {
266 #[doc = " Reader number. 0 = First Reader, 1 = Second Reader, etc."]
267 pub reader: u8,
268 #[doc = " LED number. 0 = first LED, 1 = second LED, etc."]
269 pub led_number: u8,
270 #[doc = " Ephemeral LED status descriptor."]
271 pub temporary: osdp_cmd_led_params,
272 #[doc = " Permanent LED status descriptor."]
273 pub permanent: osdp_cmd_led_params,
274}
275#[doc = " @brief Sent from CP to control the behaviour of a buzzer in the PD."]
276#[repr(C)]
277#[derive(Debug, Copy, Clone)]
278pub struct osdp_cmd_buzzer {
279 #[doc = " Reader number. 0 = First Reader, 1 = Second Reader, etc."]
280 pub reader: u8,
281 #[doc = " Control code.\n - 0 - no tone\n - 1 - off\n - 2 - default tone\n - 3+ - TBD"]
282 pub control_code: u8,
283 #[doc = " The ON duration of the sound, in units of 100 ms."]
284 pub on_count: u8,
285 #[doc = " The OFF duration of the sound, in units of 100 ms."]
286 pub off_count: u8,
287 #[doc = " The number of times to repeat the ON/OFF cycle; 0: forever."]
288 pub rep_count: u8,
289}
290#[doc = " @brief Command to manipulate any display units that the PD supports."]
291#[repr(C)]
292#[derive(Debug, Copy, Clone)]
293pub struct osdp_cmd_text {
294 #[doc = " Reader number. 0 = First Reader, 1 = Second Reader, etc."]
295 pub reader: u8,
296 #[doc = " Control code.\n - 1 - permanent text, no wrap\n - 2 - permanent text, with wrap\n - 3 - temp text, no wrap\n - 4 - temp text, with wrap"]
297 pub control_code: u8,
298 #[doc = " Duration to display temporary text, in seconds"]
299 pub temp_time: u8,
300 #[doc = " Row to display the first character (1-indexed)"]
301 pub offset_row: u8,
302 #[doc = " Column to display the first character (1-indexed)"]
303 pub offset_col: u8,
304 #[doc = " Number of characters in the string"]
305 pub length: u8,
306 #[doc = " The string to display"]
307 pub data: [u8; 32usize],
308}
309#[doc = " @brief Sent in response to a COMSET command. Set communication parameters to\n PD. Must be stored in PD non-volatile memory."]
310#[repr(C)]
311#[derive(Debug, Copy, Clone)]
312pub struct osdp_cmd_comset {
313 #[doc = " Unit ID to which this PD will respond after the change takes effect."]
314 pub address: u8,
315 #[doc = " Baud rate.\n\n Valid values: 9600, 19200, 38400, 115200, 230400."]
316 pub baud_rate: u32,
317}
318#[doc = " @brief This command transfers an encryption key from the CP to a PD."]
319#[repr(C)]
320#[derive(Debug, Copy, Clone)]
321pub struct osdp_cmd_keyset {
322 #[doc = " Type of keys:\n - 0x01 – Secure Channel Base Key"]
323 pub type_: u8,
324 #[doc = " Number of bytes of key data - (Key Length in bits + 7) / 8"]
325 pub length: u8,
326 #[doc = " Key data"]
327 pub data: [u8; 32usize],
328}
329#[doc = " @brief Manufacturer Specific Commands"]
330#[repr(C)]
331#[derive(Debug, Copy, Clone)]
332pub struct osdp_cmd_mfg {
333 #[doc = " 3-byte IEEE assigned OUI. Most Significant 8-bits are unused"]
334 pub vendor_code: u32,
335 #[doc = " Command data"]
336 pub data: [u8; 64usize],
337 #[doc = " Length of the data (internal use)"]
338 pub length: u8,
339}
340#[doc = " @brief File transfer start command"]
341#[repr(C)]
342#[derive(Debug, Copy, Clone)]
343pub struct osdp_cmd_file_tx {
344 #[doc = " Pre-agreed file ID between CP and PD"]
345 pub id: ::core::ffi::c_int,
346 #[doc = " Reserved and set to zero by OSDP spec.\n\n @note: The upper bits are used by libosdp internally (IOW, not sent\n over the OSDP bus). Currently the following flags are defined:\n\n - @ref OSDP_CMD_FILE_TX_FLAG_CANCEL"]
347 pub flags: u32,
348}
349#[doc = "< Output control command"]
350pub const osdp_cmd_e_OSDP_CMD_OUTPUT: osdp_cmd_e = 1;
351#[doc = "< Reader LED control command"]
352pub const osdp_cmd_e_OSDP_CMD_LED: osdp_cmd_e = 2;
353#[doc = "< Reader buzzer control command"]
354pub const osdp_cmd_e_OSDP_CMD_BUZZER: osdp_cmd_e = 3;
355#[doc = "< Reader text output command"]
356pub const osdp_cmd_e_OSDP_CMD_TEXT: osdp_cmd_e = 4;
357#[doc = "< Encryption Key Set Command"]
358pub const osdp_cmd_e_OSDP_CMD_KEYSET: osdp_cmd_e = 5;
359#[doc = "< PD communication configuration command"]
360pub const osdp_cmd_e_OSDP_CMD_COMSET: osdp_cmd_e = 6;
361#[doc = "< Manufacturer specific command"]
362pub const osdp_cmd_e_OSDP_CMD_MFG: osdp_cmd_e = 7;
363#[doc = "< File transfer command"]
364pub const osdp_cmd_e_OSDP_CMD_FILE_TX: osdp_cmd_e = 8;
365#[doc = "< Status report command"]
366pub const osdp_cmd_e_OSDP_CMD_STATUS: osdp_cmd_e = 9;
367#[doc = "< Comset completed; Alias for OSDP_CMD_COMSET"]
368pub const osdp_cmd_e_OSDP_CMD_COMSET_DONE: osdp_cmd_e = 10;
369#[doc = "< Max command value"]
370pub const osdp_cmd_e_OSDP_CMD_SENTINEL: osdp_cmd_e = 11;
371#[doc = " @brief OSDP application exposed commands"]
372pub type osdp_cmd_e = ::core::ffi::c_uchar;
373#[doc = " @brief Queue linkage node; layout-compatible with node_t from list.h.\n Embedded as @c _node in osdp_cmd and osdp_event. Do not read or write this\n field — it is reserved for internal use by the library."]
374pub type osdp_queue_node_t = osdp_queue_node_s;
375#[repr(C)]
376#[derive(Debug, Copy, Clone)]
377pub struct osdp_queue_node_s {
378 pub next: *mut osdp_queue_node_t,
379 pub prev: *mut osdp_queue_node_t,
380}
381#[doc = " @brief OSDP Command Structure. This is a wrapper for all individual OSDP\n commands."]
382#[repr(C)]
383#[derive(Copy, Clone)]
384pub struct osdp_cmd {
385 #[doc = "< Reserved: internal queue linkage"]
386 pub _node: osdp_queue_node_t,
387 #[doc = "< Command ID. Used to select specific commands in union"]
388 pub id: osdp_cmd_e,
389 #[doc = "< Flags; see OSDP_CMD_FLAG_* flags for possibilities"]
390 pub flags: u32,
391 pub __bindgen_anon_1: osdp_cmd__bindgen_ty_1,
392}
393#[doc = " Command"]
394#[repr(C)]
395#[derive(Copy, Clone)]
396pub union osdp_cmd__bindgen_ty_1 {
397 #[doc = "< LED command structure"]
398 pub led: osdp_cmd_led,
399 #[doc = "< Buzzer command structure"]
400 pub buzzer: osdp_cmd_buzzer,
401 #[doc = "< Text command structure"]
402 pub text: osdp_cmd_text,
403 #[doc = "< Output command structure"]
404 pub output: osdp_cmd_output,
405 #[doc = "< Comset command structure"]
406 pub comset: osdp_cmd_comset,
407 #[doc = "< Keyset command structure"]
408 pub keyset: osdp_cmd_keyset,
409 #[doc = "< Manufacturer specific command structure"]
410 pub mfg: osdp_cmd_mfg,
411 #[doc = "< File transfer command structure"]
412 pub file_tx: osdp_cmd_file_tx,
413 #[doc = "< Status report command structure"]
414 pub status: osdp_status_report,
415}
416#[doc = "< Unspecified card format"]
417pub const osdp_event_cardread_format_e_OSDP_CARD_FMT_RAW_UNSPECIFIED: osdp_event_cardread_format_e =
418 0;
419#[doc = "< Wiegand card format"]
420pub const osdp_event_cardread_format_e_OSDP_CARD_FMT_RAW_WIEGAND: osdp_event_cardread_format_e = 1;
421#[doc = "< ASCII card format (deprecated; don't use)"]
422pub const osdp_event_cardread_format_e_OSDP_CARD_FMT_ASCII: osdp_event_cardread_format_e = 2;
423#[doc = "< Max card format value"]
424pub const osdp_event_cardread_format_e_OSDP_CARD_FMT_SENTINEL: osdp_event_cardread_format_e = 3;
425#[doc = " @brief Various card formats that a PD can support. This is sent to CP\n when a PD must report a card read."]
426pub type osdp_event_cardread_format_e = ::core::ffi::c_uchar;
427#[doc = " @brief OSDP event cardread"]
428#[repr(C)]
429#[derive(Debug, Copy, Clone)]
430pub struct osdp_event_cardread {
431 #[doc = " Reader number. 0 = First Reader, 1 = Second Reader, etc."]
432 pub reader_no: ::core::ffi::c_int,
433 #[doc = " Format of the card being read."]
434 pub format: osdp_event_cardread_format_e,
435 #[doc = " Direction of data in @a data array.\n - 0 - Forward\n - 1 - Backward"]
436 pub direction: ::core::ffi::c_int,
437 #[doc = " Length of card data in bits"]
438 pub length: ::core::ffi::c_int,
439 #[doc = " Card data of @a length bytes or bits bits depending on @a format"]
440 pub data: [u8; 64usize],
441}
442#[doc = " @brief OSDP Event Keypad"]
443#[repr(C)]
444#[derive(Debug, Copy, Clone)]
445pub struct osdp_event_keypress {
446 #[doc = " Reader number in context of sub-readers attached to current PD; this\n number indicates the number of that reader. This is not supported by\n LibOSDP."]
447 pub reader_no: ::core::ffi::c_int,
448 #[doc = " Length of keypress data in bytes"]
449 pub length: ::core::ffi::c_int,
450 #[doc = " Keypress data of @a length bytes"]
451 pub data: [u8; 64usize],
452}
453#[doc = " @brief OSDP Event Manufacturer Specific Command\n\n @note OSDP spec v2.2 makes this structure fixed at 4 bytes (3-byte vendor\n code and 1-byte data). LibOSDP allows for some additional data to be passed\n in this command using the @a data and @a length fields while using the\n 1-byte data (as specified in the specification) as @a command. To be fully\n compliant with the specification, you can set @a length to 0."]
454#[repr(C)]
455#[derive(Debug, Copy, Clone)]
456pub struct osdp_event_mfgrep {
457 #[doc = " 3-bytes IEEE assigned OUI of manufacturer"]
458 pub vendor_code: u32,
459 #[doc = " Length of manufacturer data in bytes (optional)"]
460 pub length: u8,
461 #[doc = " Manufacturer data of `length` bytes (optional)"]
462 pub data: [u8; 128usize],
463}
464#[doc = " Application command outcome report.\n\n arg0: The command ID\n arg1: outcome -- 0: success; -1: failure;"]
465pub const osdp_event_notification_type_OSDP_EVENT_NOTIFICATION_COMMAND:
466 osdp_event_notification_type = 0;
467#[doc = " Secure Channel state change\n\n arg0: status -- 0: inactive; 1: active\n arg1: scbk type -- 0: scbk; 1: scbk-d"]
468pub const osdp_event_notification_type_OSDP_EVENT_NOTIFICATION_SC_STATUS:
469 osdp_event_notification_type = 1;
470#[doc = " PD state change\n\n arg0: status -- 0: offline; 1: online"]
471pub const osdp_event_notification_type_OSDP_EVENT_NOTIFICATION_PD_STATUS:
472 osdp_event_notification_type = 2;
473#[doc = " @brief LibOSDP event notification type"]
474pub type osdp_event_notification_type = ::core::ffi::c_uchar;
475#[doc = " @brief LibOSDP event notification\n\n These are events generated by LibOSDP for the application to indicate various\n status such as external command outcomes, SC state change notifications, etc.\n The app can use these events to perform housekeeping activities as needed.\n\n Each notification event type can use the provided additional data members\n @a arg0, @a arg1, ... in custom ways. See @ref osdp_event_notification_type\n for documentation on how to use them."]
476#[repr(C)]
477#[derive(Debug, Copy, Clone)]
478pub struct osdp_event_notification {
479 #[doc = "< Notification type"]
480 pub type_: osdp_event_notification_type,
481 #[doc = "< Additional data member"]
482 pub arg0: ::core::ffi::c_int,
483 #[doc = "< Additional data member"]
484 pub arg1: ::core::ffi::c_int,
485}
486#[doc = "< Card read event"]
487pub const osdp_event_type_OSDP_EVENT_CARDREAD: osdp_event_type = 1;
488#[doc = "< Keypad press event"]
489pub const osdp_event_type_OSDP_EVENT_KEYPRESS: osdp_event_type = 2;
490#[doc = "< Manufacturer specific reply event"]
491pub const osdp_event_type_OSDP_EVENT_MFGREP: osdp_event_type = 3;
492#[doc = "< Status event"]
493pub const osdp_event_type_OSDP_EVENT_STATUS: osdp_event_type = 4;
494#[doc = "< LibOSDP notification event"]
495pub const osdp_event_type_OSDP_EVENT_NOTIFICATION: osdp_event_type = 5;
496#[doc = "< Max event value"]
497pub const osdp_event_type_OSDP_EVENT_SENTINEL: osdp_event_type = 6;
498#[doc = " @brief OSDP PD Events"]
499pub type osdp_event_type = ::core::ffi::c_uchar;
500#[doc = " @brief OSDP Event structure."]
501#[repr(C)]
502#[derive(Copy, Clone)]
503pub struct osdp_event {
504 #[doc = "< Reserved: internal queue linkage"]
505 pub _node: osdp_queue_node_t,
506 #[doc = "< Event type. Used to select specific event in union"]
507 pub type_: osdp_event_type,
508 #[doc = "< Flags; reserved, set to zero"]
509 pub flags: u32,
510 pub __bindgen_anon_1: osdp_event__bindgen_ty_1,
511}
512#[doc = " Event"]
513#[repr(C)]
514#[derive(Copy, Clone)]
515pub union osdp_event__bindgen_ty_1 {
516 #[doc = "< Keypress event structure"]
517 pub keypress: osdp_event_keypress,
518 #[doc = "< Card read event structure"]
519 pub cardread: osdp_event_cardread,
520 #[doc = "< Manufacturer specific response event struture"]
521 pub mfgrep: osdp_event_mfgrep,
522 #[doc = "< Status report event structure"]
523 pub status: osdp_status_report,
524 #[doc = "< Notification event structure"]
525 pub notif: osdp_event_notification,
526}
527#[doc = " @brief Callback for PD command notifications. After it has been registered\n with `osdp_pd_set_command_callback`, this method is invoked when the PD\n receives a command from the CP.\n\n @param arg pointer that will was passed to the arg param of\n `osdp_pd_set_command_callback`.\n @param cmd pointer to the received command.\n\n @retval 0 if LibOSDP must send a `osdp_ACK` response\n @retval -ve if LibOSDP must send a `osdp_NAK` response\n @retval +ve and modify the passed `struct osdp_cmd *cmd` if LibOSDP must\n send a specific response. This is useful for sending manufacturer specific\n reply `osdp_MFGREP`."]
528pub type pd_command_callback_t = ::core::option::Option<
529 unsafe extern "C" fn(arg: *mut ::core::ffi::c_void, cmd: *mut osdp_cmd) -> ::core::ffi::c_int,
530>;
531#[doc = " @brief Callback for CP event notifications. After it has been registered\n with `osdp_cp_set_event_callback`, this method is invoked when the CP\n receives an event from the PD.\n\n @param arg Opaque pointer provided by the application during callback\n registration.\n @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to\n osdp_cp_setup()\n @param ev pointer to osdp_event struct (filled by libosdp).\n\n @retval 0 on handling the event successfully.\n @retval -ve on errors."]
532pub type cp_event_callback_t = ::core::option::Option<
533 unsafe extern "C" fn(
534 arg: *mut ::core::ffi::c_void,
535 pd: ::core::ffi::c_int,
536 ev: *mut osdp_event,
537 ) -> ::core::ffi::c_int,
538>;
539#[doc = "< Successfully completed"]
540pub const osdp_completion_status_OSDP_COMPLETION_OK: osdp_completion_status = 0;
541#[doc = "< Transport/protocol failure"]
542pub const osdp_completion_status_OSDP_COMPLETION_FAILED: osdp_completion_status = 1;
543#[doc = "< Removed by flush API"]
544pub const osdp_completion_status_OSDP_COMPLETION_FLUSHED: osdp_completion_status = 2;
545#[doc = "< Removed during teardown"]
546pub const osdp_completion_status_OSDP_COMPLETION_ABORTED: osdp_completion_status = 3;
547#[doc = " @brief Terminal status of a submitted command/event object."]
548pub type osdp_completion_status = ::core::ffi::c_uchar;
549#[doc = " @brief Callback for CP command completion notifications."]
550pub type cp_command_completion_callback_t = ::core::option::Option<
551 unsafe extern "C" fn(
552 arg: *mut ::core::ffi::c_void,
553 pd: ::core::ffi::c_int,
554 cmd: *const osdp_cmd,
555 status: osdp_completion_status,
556 ),
557>;
558#[doc = " @brief Callback for PD event completion notifications."]
559pub type pd_event_completion_callback_t = ::core::option::Option<
560 unsafe extern "C" fn(
561 arg: *mut ::core::ffi::c_void,
562 ev: *const osdp_event,
563 status: osdp_completion_status,
564 ),
565>;
566unsafe extern "C" {
567 #[doc = " @brief This method is used to setup a device in PD mode. Application must\n store the returned context pointer and pass it back to all OSDP functions\n intact.\n\n @param info Pointer to info struct populated by application.\n\n @retval OSDP Context on success\n @retval NULL on errors"]
568 pub fn osdp_pd_setup(info: *const osdp_pd_info_t) -> *mut osdp_t;
569}
570unsafe extern "C" {
571 #[doc = " @brief Periodic refresh method. Must be called by the application at least\n once every 50ms to meet OSDP timing requirements.\n\n @param ctx OSDP context"]
572 pub fn osdp_pd_refresh(ctx: *mut osdp_t);
573}
574unsafe extern "C" {
575 #[doc = " @brief Cleanup all osdp resources. The context pointer is no longer valid\n after this call.\n\n @param ctx OSDP context"]
576 pub fn osdp_pd_teardown(ctx: *mut osdp_t);
577}
578unsafe extern "C" {
579 #[doc = " @brief Set PD's capabilities\n\n @param ctx OSDP context\n @param cap pointer to array of cap (`struct osdp_pd_cap`) terminated by a\n capability with cap->function_code set to 0."]
580 pub fn osdp_pd_set_capabilities(ctx: *mut osdp_t, cap: *const osdp_pd_cap);
581}
582unsafe extern "C" {
583 #[doc = " @brief Set callback method for PD command notification. This callback is\n invoked when the PD receives a command from the CP.\n\n @param ctx OSDP context\n @param cb The callback function's pointer\n @param arg A pointer that will be passed as the first argument of `cb`"]
584 pub fn osdp_pd_set_command_callback(
585 ctx: *mut osdp_t,
586 cb: pd_command_callback_t,
587 arg: *mut ::core::ffi::c_void,
588 );
589}
590unsafe extern "C" {
591 #[doc = " @brief API to notify PD events to CP. These events are sent to the CP as an\n alternate response to a POLL command.\n\n @param ctx OSDP context\n @param event pointer to event struct. Must be filled by application.\n\n @retval 0 on success\n @retval -1 on failure"]
592 pub fn osdp_pd_notify_event(ctx: *mut osdp_t, event: *const osdp_event) -> ::core::ffi::c_int;
593}
594unsafe extern "C" {
595 #[doc = " @brief Submit PD events to CP. These events are delivered to the CP as a\n response to a future POLL command. A successful return does not mean CP\n received it, it only means LibOSDP accepted this submission.\n\n @param ctx OSDP context\n @param event pointer to event struct. Must be filled by application.\n\n @retval 0 on success\n @retval -1 on failure"]
596 pub fn osdp_pd_submit_event(ctx: *mut osdp_t, event: *const osdp_event) -> ::core::ffi::c_int;
597}
598unsafe extern "C" {
599 #[doc = " @brief Deletes all events from the PD's event queue.\n\n @param ctx OSDP context\n @return int Count of events dequeued."]
600 pub fn osdp_pd_flush_events(ctx: *mut osdp_t) -> ::core::ffi::c_int;
601}
602unsafe extern "C" {
603 #[doc = " @brief This method is used to setup a device in CP mode. Application must\n store the returned context pointer and pass it back to all OSDP functions\n intact.\n\n @param num_pd Number of PDs connected to this CP. The `osdp_pd_info_t *` is\n treated as an array of length num_pd.\n @param info Pointer to info struct populated by application.\n\n @retval OSDP Context on success\n @retval NULL on errors"]
604 pub fn osdp_cp_setup(num_pd: ::core::ffi::c_int, info: *const osdp_pd_info_t) -> *mut osdp_t;
605}
606unsafe extern "C" {
607 #[doc = " @brief Adds more PD devices in the CP control list.\n\n @param ctx OSDP context\n @param num_pd Number of PDs connected to this CP. The `osdp_pd_info_t *` is\n treated as an array of length num_pd.\n @param info Pointer to info struct populated by application.\n\n @retval 0 on success\n @retval -1 on failure"]
608 pub fn osdp_cp_add_pd(
609 ctx: *mut osdp_t,
610 num_pd: ::core::ffi::c_int,
611 info: *const osdp_pd_info_t,
612 ) -> ::core::ffi::c_int;
613}
614unsafe extern "C" {
615 #[doc = " @brief Periodic refresh method. Must be called by the application at least\n once every 50ms to meet OSDP timing requirements.\n\n @param ctx OSDP context"]
616 pub fn osdp_cp_refresh(ctx: *mut osdp_t);
617}
618unsafe extern "C" {
619 #[doc = " @brief Cleanup all osdp resources. The context pointer is no longer valid\n after this call.\n\n @param ctx OSDP context"]
620 pub fn osdp_cp_teardown(ctx: *mut osdp_t);
621}
622unsafe extern "C" {
623 #[doc = " @brief Generic command enqueue API.\n\n @param ctx OSDP context\n @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to\n osdp_cp_setup()\n @param cmd command pointer. Must be filled by application.\n\n @retval 0 on success\n @retval -1 on failure\n\n @note This method only adds the command on to a particular PD's command\n queue. The command itself can fail due to various reasons."]
624 pub fn osdp_cp_send_command(
625 ctx: *mut osdp_t,
626 pd: ::core::ffi::c_int,
627 cmd: *const osdp_cmd,
628 ) -> ::core::ffi::c_int;
629}
630unsafe extern "C" {
631 #[doc = " @brief Submit CP commands to PD. These commands are queued to be sent to the\n PD at the next available opportunity. A successful return does not mean PD\n received it, it only means LibOSDP accepted this submission.\n\n @param ctx OSDP context\n @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to\n osdp_cp_setup()\n @param cmd command pointer. Must be filled by application.\n\n @retval 0 on success\n @retval -1 on failure\n\n @note This method only adds the command on to a particular PD's command\n queue. The command itself can fail due to various reasons."]
632 pub fn osdp_cp_submit_command(
633 ctx: *mut osdp_t,
634 pd: ::core::ffi::c_int,
635 cmd: *const osdp_cmd,
636 ) -> ::core::ffi::c_int;
637}
638unsafe extern "C" {
639 #[doc = " @brief Deletes all commands queued for a give PD\n\n @param ctx OSDP context\n @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to\n osdp_cp_setup()\n @return int Count of events dequeued"]
640 pub fn osdp_cp_flush_commands(ctx: *mut osdp_t, pd: ::core::ffi::c_int) -> ::core::ffi::c_int;
641}
642unsafe extern "C" {
643 #[doc = " @brief Get PD ID information as reported by the PD. Calling this method\n before the CP has had a the chance to get this information will return\n invalid/stale results.\n\n @param ctx OSDP context\n @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to\n osdp_cp_setup()\n @param id A pointer to struct osdp_pd_id that will be filled with the\n PD ID information that the PD last returned.\n\n @retval 0 on success\n @retval -1 on failure"]
644 pub fn osdp_cp_get_pd_id(
645 ctx: *const osdp_t,
646 pd: ::core::ffi::c_int,
647 id: *mut osdp_pd_id,
648 ) -> ::core::ffi::c_int;
649}
650unsafe extern "C" {
651 #[doc = " @brief Get capability associated to a function_code that the PD reports in\n response to osdp_CAP(0x62) command. Calling this method before the CP has\n had a the chance to get this information will return invalid/stale results.\n\n @param ctx OSDP context\n @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to\n osdp_cp_setup()\n @param cap in/out; struct osdp_pd_cap pointer with osdp_pd_cap::function_code\n set to the function code to get data for.\n\n @retval 0 on success\n @retval -1 on failure"]
652 pub fn osdp_cp_get_capability(
653 ctx: *const osdp_t,
654 pd: ::core::ffi::c_int,
655 cap: *mut osdp_pd_cap,
656 ) -> ::core::ffi::c_int;
657}
658unsafe extern "C" {
659 #[doc = " @brief Set callback method for CP event notification. This callback is\n invoked when the CP receives an event from the PD.\n\n @param ctx OSDP context\n @param cb The callback function's pointer\n @param arg A pointer that will be passed as the first argument of `cb`"]
660 pub fn osdp_cp_set_event_callback(
661 ctx: *mut osdp_t,
662 cb: cp_event_callback_t,
663 arg: *mut ::core::ffi::c_void,
664 );
665}
666unsafe extern "C" {
667 #[doc = " @brief Set or clear OSDP public flags\n\n @param ctx OSDP context\n @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to\n osdp_cp_setup()\n @param flags One or more of the public flags (OSDP_FLAG_XXX) exported from\n osdp.h. Any other bits will cause this method to fail.\n @param do_set when true: set `flags` in ctx; when false: clear `flags` in ctx\n\n @retval 0 on success\n @retval -1 on failure\n\n @note It doesn't make sense to call some initialization time flags during\n runtime. This method is for dynamic flags that can be turned on/off at runtime."]
668 pub fn osdp_cp_modify_flag(
669 ctx: *mut osdp_t,
670 pd: ::core::ffi::c_int,
671 flags: u32,
672 do_set: bool,
673 ) -> ::core::ffi::c_int;
674}
675unsafe extern "C" {
676 #[doc = " @brief Disable a PD managed by the CP. Disabled PDs are brought to a safe\n state and will not process commands or generate events.\n\n @param ctx OSDP context\n @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to\n osdp_cp_setup()\n\n @retval 0 on success\n @retval -1 on failure"]
677 pub fn osdp_cp_disable_pd(ctx: *mut osdp_t, pd: ::core::ffi::c_int) -> ::core::ffi::c_int;
678}
679unsafe extern "C" {
680 #[doc = " @brief Enable a previously disabled PD. The PD will start up as it would\n during initial setup.\n\n @param ctx OSDP context\n @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to\n osdp_cp_setup()\n\n @retval 0 on success\n @retval -1 on failure"]
681 pub fn osdp_cp_enable_pd(ctx: *mut osdp_t, pd: ::core::ffi::c_int) -> ::core::ffi::c_int;
682}
683unsafe extern "C" {
684 #[doc = " @brief Check if a PD is currently enabled.\n\n @param ctx OSDP context\n @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to\n osdp_cp_setup()\n\n @retval true if PD is enabled\n @retval false if PD is disabled or on error"]
685 pub fn osdp_cp_is_pd_enabled(ctx: *const osdp_t, pd: ::core::ffi::c_int) -> bool;
686}
687#[doc = "< Log level Emergency"]
688pub const osdp_log_level_e_OSDP_LOG_EMERG: osdp_log_level_e = 0;
689#[doc = "< Log level Alert"]
690pub const osdp_log_level_e_OSDP_LOG_ALERT: osdp_log_level_e = 1;
691#[doc = "< Log level Critical"]
692pub const osdp_log_level_e_OSDP_LOG_CRIT: osdp_log_level_e = 2;
693#[doc = "< Log level Error"]
694pub const osdp_log_level_e_OSDP_LOG_ERROR: osdp_log_level_e = 3;
695#[doc = "< Log level Warning"]
696pub const osdp_log_level_e_OSDP_LOG_WARNING: osdp_log_level_e = 4;
697#[doc = "< Log level Notice"]
698pub const osdp_log_level_e_OSDP_LOG_NOTICE: osdp_log_level_e = 5;
699#[doc = "< Log level Info"]
700pub const osdp_log_level_e_OSDP_LOG_INFO: osdp_log_level_e = 6;
701#[doc = "< Log level Debug"]
702pub const osdp_log_level_e_OSDP_LOG_DEBUG: osdp_log_level_e = 7;
703#[doc = "< Log level max value"]
704pub const osdp_log_level_e_OSDP_LOG_MAX_LEVEL: osdp_log_level_e = 8;
705#[doc = " @brief Different levels of log messages; based on importance of the message\n with LOG_EMERG being most critical to LOG_DEBUG being the least."]
706pub type osdp_log_level_e = ::core::ffi::c_uchar;
707#[doc = " @brief Puts a string to the logging medium\n\n @param msg a null-terminated char buffer.\n\n @retval 0 on success; -ve on errors"]
708pub type osdp_log_puts_fn_t = ::core::option::Option<
709 unsafe extern "C" fn(msg: *const ::core::ffi::c_char) -> ::core::ffi::c_int,
710>;
711#[doc = " @brief A callback function to be used with external loggers\n\n @param log_level A syslog style log level. See `enum osdp_log_level_e`\n @param file Relative path to file which produced the log message\n @param line Line number in `file` which produced the log message\n @param msg The log message"]
712pub type osdp_log_callback_fn_t = ::core::option::Option<
713 unsafe extern "C" fn(
714 log_level: ::core::ffi::c_int,
715 file: *const ::core::ffi::c_char,
716 line: ::core::ffi::c_ulong,
717 msg: *const ::core::ffi::c_char,
718 ),
719>;
720unsafe extern "C" {
721 #[doc = " @brief Configure OSDP Logging.\n\n @param name A soft name for this module; will appear in all the log lines.\n @param log_level OSDP log levels of type `enum osdp_log_level_e`. Default is\n LOG_INFO.\n @param puts_fn A puts() like function that will be invoked to write the log\n buffer. Can be handy if you want to log to file on a UART device without\n putchar redirection. See `osdp_log_puts_fn_t` definition to see the\n behavioral expectations. When this is set to NULL, LibOSDP will log to\n stderr.\n\n Note: This function has to be called before osdp_{cp,pd}_setup(). Otherwise\n it will be ignored."]
722 pub fn osdp_logger_init(
723 name: *const ::core::ffi::c_char,
724 log_level: ::core::ffi::c_int,
725 puts_fn: osdp_log_puts_fn_t,
726 );
727}
728unsafe extern "C" {
729 #[doc = " @brief A callback function that gets called when LibOSDP wants to emit a log\n line. All messages (of all log levels) are passed on to this callback\n without any log formatting. This API is for users who may already have a\n logger configured in their application.\n\n @param cb The callback function. See `osdp_log_callback_fn_t` for more\n details.\n\n @note This function has to be called before osdp_{cp,pd}_setup(). Otherwise\n it will be ignored."]
730 pub fn osdp_set_log_callback(cb: osdp_log_callback_fn_t);
731}
732unsafe extern "C" {
733 #[doc = " @brief Get LibOSDP version as a `const char *`. Used in diagnostics.\n\n @retval version string"]
734 pub fn osdp_get_version() -> *const ::core::ffi::c_char;
735}
736unsafe extern "C" {
737 #[doc = " @brief Get LibOSDP source identifier as a `const char *`. This string has\n info about the source tree from which this version of LibOSDP was built.\n Used in diagnostics.\n\n @retval source identifier string"]
738 pub fn osdp_get_source_info() -> *const ::core::ffi::c_char;
739}
740unsafe extern "C" {
741 #[doc = " @brief Get a bit mask of number of PD that are online currently.\n\n @param ctx OSDP context\n @param bitmask pointer to an array of bytes. must be as large as\n (num_pds + 7 / 8)."]
742 pub fn osdp_get_status_mask(ctx: *const osdp_t, bitmask: *mut u8);
743}
744unsafe extern "C" {
745 #[doc = " @brief Get a bit mask of number of PD that are online and have an active\n secure channel currently.\n\n @param ctx OSDP context\n @param bitmask pointer to an array of bytes. must be as large as\n (num_pds + 7 / 8)."]
746 pub fn osdp_get_sc_status_mask(ctx: *const osdp_t, bitmask: *mut u8);
747}
748#[doc = " @brief Open a pre-agreed file\n\n @param arg Opaque pointer that was provided in @ref osdp_file_ops when the\n ops struct was registered.\n @param file_id File ID of pre-agreed file between this CP and PD\n @param size Size of the file that was opened (to be populated by sender). In\n case of receiver, this value is just just input to indicate the incoming file\n size.\n\n @retval 0 on success\n @retval -1 on errors"]
749pub type osdp_file_open_fn_t = ::core::option::Option<
750 unsafe extern "C" fn(
751 arg: *mut ::core::ffi::c_void,
752 file_id: ::core::ffi::c_int,
753 size: *mut ::core::ffi::c_int,
754 ) -> ::core::ffi::c_int,
755>;
756#[doc = " @brief Read a chunk of file data into buffer\n\n @param arg Opaque pointer that was provided in @ref osdp_file_ops when the\n ops struct was registered.\n @param buf Buffer to store file data read\n @param size Number of bytes to read from file into buffer\n @param offset Number of bytes from the beginning of the file to\n start reading from.\n\n @retval Number of bytes read\n @retval 0 on EOF\n @retval -ve on errors.\n\n @note LibOSDP will guarantee that size and offset params are always\n positive and size is always greater than or equal to offset."]
757pub type osdp_file_read_fn_t = ::core::option::Option<
758 unsafe extern "C" fn(
759 arg: *mut ::core::ffi::c_void,
760 buf: *mut ::core::ffi::c_void,
761 size: ::core::ffi::c_int,
762 offset: ::core::ffi::c_int,
763 ) -> ::core::ffi::c_int,
764>;
765#[doc = " @brief Write a chunk of file data from buffer to disk.\n\n @param arg Opaque pointer that was provided in @ref osdp_file_ops when the\n ops struct was registered.\n @param buf Buffer with file data to be stored to disk\n @param size Number of bytes to write to disk\n @param offset Number of bytes from the beginning of the file to\n start writing too.\n\n @retval Number of bytes written\n @retval 0 on EOF\n @retval -ve on errors.\n\n @note LibOSDP will guarantee that size and offset params are always\n positive and size is always greater than or equal to offset."]
766pub type osdp_file_write_fn_t = ::core::option::Option<
767 unsafe extern "C" fn(
768 arg: *mut ::core::ffi::c_void,
769 buf: *const ::core::ffi::c_void,
770 size: ::core::ffi::c_int,
771 offset: ::core::ffi::c_int,
772 ) -> ::core::ffi::c_int,
773>;
774#[doc = " @brief Close file that corresponds to a given file descriptor\n\n @param arg Opaque pointer that was provided in @ref osdp_file_ops when the\n ops struct was registered.\n\n @retval 0 on success\n @retval -1 on errors."]
775pub type osdp_file_close_fn_t = ::core::option::Option<
776 unsafe extern "C" fn(arg: *mut ::core::ffi::c_void) -> ::core::ffi::c_int,
777>;
778#[doc = " @brief OSDP File operations struct that needs to be filled by the CP/PD\n application and registered with LibOSDP using osdp_file_register_ops()\n before a file transfer command can be initiated."]
779#[repr(C)]
780#[derive(Debug, Copy, Clone)]
781pub struct osdp_file_ops {
782 #[doc = " @brief A opaque pointer to private data that can be filled by the\n application which will be passed as the first argument for each of\n the below functions. Applications can keep their file context info\n such as the open file descriptors or any other private data here."]
783 pub arg: *mut ::core::ffi::c_void,
784 #[doc = "< open handler function"]
785 pub open: osdp_file_open_fn_t,
786 #[doc = "< read handler function"]
787 pub read: osdp_file_read_fn_t,
788 #[doc = "< write handler function"]
789 pub write: osdp_file_write_fn_t,
790 #[doc = "< close handler function"]
791 pub close: osdp_file_close_fn_t,
792}
793unsafe extern "C" {
794 #[doc = " @brief Register a global file operations struct with OSDP. Both CP and PD\n modes should have done so already before CP can sending a OSDP_CMD_FILE_TX.\n\n @param ctx OSDP context\n @param pd PD number in case of CP. This param is ignored in PD mode\n @param ops Populated file operations struct\n\n @retval 0 on success. -1 on errors."]
795 pub fn osdp_file_register_ops(
796 ctx: *mut osdp_t,
797 pd: ::core::ffi::c_int,
798 ops: *const osdp_file_ops,
799 ) -> ::core::ffi::c_int;
800}
801unsafe extern "C" {
802 #[doc = " @brief Query file transfer status if one is in progress. Calling this method\n when there is no file transfer progressing will return error.\n\n @param ctx OSDP context\n @param pd PD number in case of CP. This param is ignored in PD mode\n @param size Total size of the file (as obtained from file_ops->open())\n @param offset Offset into the file that has been sent/received (CP/PD)\n @retval 0 on success. -1 on errors."]
803 pub fn osdp_get_file_tx_status(
804 ctx: *const osdp_t,
805 pd: ::core::ffi::c_int,
806 size: *mut ::core::ffi::c_int,
807 offset: *mut ::core::ffi::c_int,
808 ) -> ::core::ffi::c_int;
809}