Documentation
Control Panel
The following functions are used when OSDP is used in CP mode. The libraryreturns a single opaque pointer of type osdp_t where it maintains allinternal data. All applications consuming this library must pass this contextpointer to all API calls.
For the CP application, connected PDs are referenced by their offset number(0-indexed), corresponding to the order in which osdp_pd_info_t was populatedwhen passed to osdp_cp_setup.
Device Lifecycle Management
typedef void osdp_tTo keep the OSDP internal data structures from polluting the exposed headers, they are typedefed to void before sending them to the upper layers. This level of abstraction looked reasonable as technically no one should attempt to modify it outside of the LibOSDP and their definition may change at any time.
osdp_t * osdp_cp_setup(const struct osdp_channel *channel, int num_pd, const osdp_pd_info_t *info)This method is used to setup a device in CP mode. Application must store the returned context pointer and pass it back to all OSDP functions intact.
channelPointer to shared channel ops used for this CP context.num_pdNumber of PDs connected to this CP. The osdp_pd_info_t * is treated as an array of length num_pd.infoPointer to info struct populated by application.OSDPContext on successNULLon errorsvoid osdp_cp_refresh(osdp_t *ctx)Periodic refresh method. Must be called by the application at least once every 50ms to meet OSDP timing requirements.
ctxOSDP contextvoid osdp_cp_teardown(osdp_t *ctx)Cleanup all osdp resources. The context pointer is no longer valid after this call.
ctxOSDP contextEvents
Events are generated by the PD and sent to the CP. The CP app can register acallback using osdp_cp_set_event_callback to be notified of events.
typedef int(* cp_event_callback_t) (void *arg, int pd, struct osdp_event *ev)Callback for CP event notifications. After it has been registered with osdp_cp_set_event_callback, this method is invoked when the CP receives an event from the PD.
argOpaque pointer provided by the application during callback registration.pdPD offset (0-indexed) of this PD in osdp_pd_info_t * passed to osdp_cp_setup()evpointer to osdp_event struct (filled by libosdp).0on handling the event successfully.-veon errors.void osdp_cp_set_event_callback(osdp_t *ctx, cp_event_callback_t cb, void *arg)Set callback method for CP event notification. This callback is invoked when the CP receives an event from the PD.
ctxOSDP contextcbThe callback function's pointerargA pointer that will be passed as the first argument of cbRefer to the event structure document for moreinformation on how the event structure is framed.
Commands
Commands are sent from the CP to the PD to perform various actions. The CP appcreates a command struct and calls osdp_cp_submit_command to enqueue it to aparticular PD.
int osdp_cp_submit_command(osdp_t *ctx, int pd, const struct osdp_cmd *cmd)Submit CP commands to PD. These commands are queued to be sent to the PD at the next available opportunity. A successful return does not mean PD received it, it only means LibOSDP accepted this submission.
ctxOSDP contextpdPD offset (0-indexed) of this PD in osdp_pd_info_t * passed to osdp_cp_setup()cmdcommand pointer. Must be filled by application.0on success-1on failureint osdp_cp_flush_commands(osdp_t *ctx, int pd)Deletes all commands queued for a give PD.
ctxOSDP contextpdPD offset (0-indexed) of this PD in osdp_pd_info_t * passed to osdp_cp_setup()intint Count of events dequeuedRefer to the command structure document for moreinformation on how to populate the cmd structure.
Get PD Capability
PD capability structure. Each PD capability has a 3 byte representation.
uint8_t function_codeuint8_t compliance_leveluint8_t num_itemsint osdp_cp_get_capability(const osdp_t *ctx, int pd, struct osdp_pd_cap *cap)Get capability associated to a function_code that the PD reports in response to osdp_CAP(0x62) command. Calling this method before the CP has had a the chance to get this information will return invalid/stale results.
ctxOSDP contextpdPD offset (0-indexed) of this PD in osdp_pd_info_t * passed to osdp_cp_setup()capin/out; struct osdp_pd_cap pointer with osdp_pd_cap::function_code set to the function code to get data for.0on success-1on failureOthers
int osdp_cp_get_pd_id(const osdp_t *ctx, int pd, struct osdp_pd_id *id)Get PD ID information as reported by the PD. Calling this method before the CP has had a the chance to get this information will return invalid/stale results.
ctxOSDP contextpdPD offset (0-indexed) of this PD in osdp_pd_info_t * passed to osdp_cp_setup()idA pointer to struct osdp_pd_id that will be filled with the PD ID information that the PD last returned.0on success-1on failureint osdp_cp_modify_flag(osdp_t *ctx, int pd, uint32_t flags, bool do_set)Set or clear OSDP public flags.
ctxOSDP contextpdPD offset (0-indexed) of this PD in osdp_pd_info_t * passed to osdp_cp_setup()flagsOne or more of the public flags (OSDP_FLAG_XXX) exported from osdp.h. Any other bits will cause this method to fail.do_setwhen true: set flags in ctx; when false: clear flags in ctx0on success-1on failure