88#include < osdp.hpp>
99
1010OSDP::PeripheralDevice pd;
11+ osdp_pd_info_t info_pd = {};
12+ static const struct osdp_pd_cap pd_cap[] = {
13+ { OSDP_PD_CAP_READER_LED_CONTROL, 1 , 1 },
14+ { OSDP_PD_CAP_READER_AUDIBLE_OUTPUT, 1 , 1 },
15+ { static_cast <uint8_t >(-1 ), 0 , 0 } /* Sentinel */
16+ };
1117
1218int serial1_send_func (void *data, uint8_t *buf, int len)
1319{
@@ -36,40 +42,28 @@ int serial1_recv_func(void *data, uint8_t *buf, int len)
3642 return read;
3743}
3844
39- osdp_pd_info_t info_pd = {
40- .name = " pd[101]" ,
41- .baud_rate = 9600 ,
42- .address = 101 ,
43- .flags = 0 ,
44- .id = {
45- .version = 1 ,
46- .model = 153 ,
47- .vendor_code = 31337 ,
48- .serial_number = 0x01020304 ,
49- .firmware_version = 0x0A0B0C0D ,
50- },
51- .cap = (struct osdp_pd_cap []) {
52- {
53- .function_code = OSDP_PD_CAP_READER_LED_CONTROL,
54- .compliance_level = 1 ,
55- .num_items = 1
56- },
57- {
58- .function_code = OSDP_PD_CAP_READER_AUDIBLE_OUTPUT,
59- .compliance_level = 1 ,
60- .num_items = 1
61- },
62- { static_cast <uint8_t >(-1 ), 0 , 0 } /* Sentinel */
63- },
64- .channel = {
65- .data = nullptr ,
66- .id = 0 ,
67- .recv = serial1_recv_func,
68- .send = serial1_send_func,
69- .flush = nullptr
70- },
71- .scbk = nullptr ,
72- };
45+ void init_pd_info ()
46+ {
47+ info_pd.name = " pd[101]" ;
48+ info_pd.baud_rate = 9600 ;
49+ info_pd.address = 101 ;
50+ info_pd.flags = 0 ;
51+ info_pd.id .version = 1 ;
52+ info_pd.id .model = 153 ;
53+ info_pd.id .vendor_code = 31337 ;
54+ info_pd.id .serial_number = 0x01020304 ;
55+ info_pd.id .firmware_version = 0x0A0B0C0D ;
56+ info_pd.cap = pd_cap;
57+ info_pd.channel .data = nullptr ;
58+ info_pd.channel .id = 0 ;
59+ info_pd.channel .recv = serial1_recv_func;
60+ info_pd.channel .recv_pkt = nullptr ;
61+ info_pd.channel .send = serial1_send_func;
62+ info_pd.channel .flush = nullptr ;
63+ info_pd.channel .release_pkt = nullptr ;
64+ info_pd.channel .close = nullptr ;
65+ info_pd.scbk = nullptr ;
66+ }
7367
7468int pd_command_handler (void *data, struct osdp_cmd *cmd)
7569{
@@ -86,6 +80,7 @@ void setup()
8680
8781 pd.logger_init (" osdp::pd" , OSDP_LOG_DEBUG, NULL );
8882
83+ init_pd_info ();
8984 pd.setup (&info_pd);
9085
9186 pd.set_command_callback (pd_command_handler, nullptr );
@@ -95,4 +90,4 @@ void loop()
9590{
9691 pd.refresh ();
9792 delay (1000 );
98- }
93+ }
0 commit comments