Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
osdp.h File Reference
#include <zephyr/kernel.h>
#include <stdint.h>
#include <zephyr/sys/slist.h>

Go to the source code of this file.

Data Structures

struct  osdp_cmd_output
 Command sent from CP to Control digital output of PD. More...
 
struct  osdp_cmd_led_params
 LED params sub-structure. More...
 
struct  osdp_cmd_led
 Sent from CP to PD to control the behaviour of it's on-board LEDs. More...
 
struct  osdp_cmd_buzzer
 Sent from CP to control the behaviour of a buzzer in the PD. More...
 
struct  osdp_cmd_text
 Command to manipulate any display units that the PD supports. More...
 
struct  osdp_cmd_comset
 Sent in response to a COMSET command. More...
 
struct  osdp_cmd_keyset
 This command transfers an encryption key from the CP to a PD. More...
 
struct  osdp_cmd
 OSDP Command Structure. More...
 
struct  osdp_event_cardread
 OSDP event cardread. More...
 
struct  osdp_event_keypress
 OSDP Event Keypad. More...
 
struct  osdp_event
 OSDP Event structure. More...
 

Macros

#define OSDP_CMD_TEXT_MAX_LEN   32
 
#define OSDP_CMD_KEYSET_KEY_MAX_LEN   32
 
#define OSDP_EVENT_MAX_DATALEN   64
 

Typedefs

typedef int(* pd_command_callback_t) (void *arg, struct osdp_cmd *cmd)
 Callback for PD command notifications.
 
typedef int(* cp_event_callback_t) (void *arg, int pd, struct osdp_event *ev)
 Callback for CP event notifications.
 

Enumerations

enum  osdp_led_color_e {
  OSDP_LED_COLOR_NONE , OSDP_LED_COLOR_RED , OSDP_LED_COLOR_GREEN , OSDP_LED_COLOR_AMBER ,
  OSDP_LED_COLOR_BLUE , OSDP_LED_COLOR_SENTINEL
}
 LED Colors as specified in OSDP for the on_color/off_color parameters. More...
 
enum  osdp_cmd_e {
  OSDP_CMD_OUTPUT = 1 , OSDP_CMD_LED , OSDP_CMD_BUZZER , OSDP_CMD_TEXT ,
  OSDP_CMD_KEYSET , OSDP_CMD_COMSET , OSDP_CMD_SENTINEL
}
 OSDP application exposed commands. More...
 
enum  osdp_event_cardread_format_e { OSDP_CARD_FMT_RAW_UNSPECIFIED , OSDP_CARD_FMT_RAW_WIEGAND , OSDP_CARD_FMT_ASCII , OSDP_CARD_FMT_SENTINEL }
 Various card formats that a PD can support. More...
 
enum  osdp_event_type { OSDP_EVENT_CARDREAD , OSDP_EVENT_KEYPRESS , OSDP_EVENT_SENTINEL }
 OSDP PD Events. More...
 

Functions

int osdp_cp_send_command (int pd, struct osdp_cmd *cmd)
 Generic command enqueue API.
 
void osdp_cp_set_event_callback (cp_event_callback_t cb, void *arg)
 Set callback method for CP event notification.
 

Macro Definition Documentation

◆ OSDP_CMD_KEYSET_KEY_MAX_LEN

#define OSDP_CMD_KEYSET_KEY_MAX_LEN   32

◆ OSDP_CMD_TEXT_MAX_LEN

#define OSDP_CMD_TEXT_MAX_LEN   32

◆ OSDP_EVENT_MAX_DATALEN

#define OSDP_EVENT_MAX_DATALEN   64

Typedef Documentation

◆ cp_event_callback_t

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.

Parameters
argOpaque pointer provided by the application during callback registration.
pdthe offset (0-indexed) of this PD in kconfig OSDP_PD_ADDRESS_LIST
evpointer to osdp_event struct (filled by libosdp).
Return values
0on handling the event successfully.
-veon errors.

◆ pd_command_callback_t

typedef int(* pd_command_callback_t) (void *arg, struct osdp_cmd *cmd)

Callback for PD command notifications.

After it has been registered with osdp_pd_set_command_callback, this method is invoked when the PD receives a command from the CP.

Parameters
argpointer that will was passed to the arg param of osdp_pd_set_command_callback.
cmdpointer to the received command.
Return values
0if LibOSDP must send a osdp_ACK response
-veif LibOSDP must send a osdp_NAK response
+veand modify the passed struct osdp_cmd *cmd if LibOSDP must send a specific response. This is useful for sending manufacturer specific reply osdp_MFGREP.

Enumeration Type Documentation

◆ osdp_cmd_e

enum osdp_cmd_e

OSDP application exposed commands.

Enumerator
OSDP_CMD_OUTPUT 
OSDP_CMD_LED 
OSDP_CMD_BUZZER 
OSDP_CMD_TEXT 
OSDP_CMD_KEYSET 
OSDP_CMD_COMSET 
OSDP_CMD_SENTINEL 

◆ osdp_event_cardread_format_e

Various card formats that a PD can support.

This is sent to CP when a PD must report a card read.

Enumerator
OSDP_CARD_FMT_RAW_UNSPECIFIED 
OSDP_CARD_FMT_RAW_WIEGAND 
OSDP_CARD_FMT_ASCII 
OSDP_CARD_FMT_SENTINEL 

◆ osdp_event_type

OSDP PD Events.

Enumerator
OSDP_EVENT_CARDREAD 
OSDP_EVENT_KEYPRESS 
OSDP_EVENT_SENTINEL 

◆ osdp_led_color_e

LED Colors as specified in OSDP for the on_color/off_color parameters.

Enumerator
OSDP_LED_COLOR_NONE 
OSDP_LED_COLOR_RED 
OSDP_LED_COLOR_GREEN 
OSDP_LED_COLOR_AMBER 
OSDP_LED_COLOR_BLUE 
OSDP_LED_COLOR_SENTINEL 

Function Documentation

◆ osdp_cp_send_command()

int osdp_cp_send_command ( int  pd,
struct osdp_cmd cmd 
)

Generic command enqueue API.

Parameters
pdthe offset (0-indexed) of this PD in kconfig OSDP_PD_ADDRESS_LIST
cmdcommand pointer. Must be filled by application.
Return values
0on success
-1on failure
Note
This method only adds the command on to a particular PD's command queue. The command itself can fail due to various reasons.

◆ osdp_cp_set_event_callback()

void osdp_cp_set_event_callback ( 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.

Parameters
cbThe callback function's pointer
argA pointer that will be passed as the first argument of cb