libosdp 3.0.8__tar.gz → 3.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {libosdp-3.0.8 → libosdp-3.1.2}/PKG-INFO +10 -2
- {libosdp-3.0.8 → libosdp-3.1.2}/libosdp.egg-info/PKG-INFO +10 -2
- {libosdp-3.0.8 → libosdp-3.1.2}/libosdp.egg-info/SOURCES.txt +3 -1
- {libosdp-3.0.8 → libosdp-3.1.2}/osdp/constants.py +1 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/osdp/control_panel.py +53 -9
- {libosdp-3.0.8 → libosdp-3.1.2}/osdp/peripheral_device.py +24 -11
- {libosdp-3.0.8 → libosdp-3.1.2}/setup.py +9 -9
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/include/osdp.h +154 -36
- libosdp-3.1.2/vendor/include/osdp_export.h +86 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/python/osdp_sys/base.c +7 -5
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/python/osdp_sys/cp.c +114 -29
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/python/osdp_sys/data.c +37 -38
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/python/osdp_sys/module.c +2 -1
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/python/osdp_sys/module.h +3 -1
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/python/osdp_sys/pd.c +17 -12
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/python/osdp_sys/utils.c +37 -5
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/crypto/tinyaes.c +1 -1
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_common.c +6 -22
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_common.h +13 -10
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_config.h +5 -4
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_cp.c +279 -119
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_diag.h +1 -1
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_file.c +2 -2
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_pd.c +118 -62
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_phy.c +99 -42
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/include/utils/assert.h +8 -0
- libosdp-3.1.2/vendor/utils/include/utils/crc16.h +25 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/include/utils/utils.h +14 -0
- libosdp-3.1.2/vendor/utils/src/crc16.c +21 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/src/logger.c +6 -1
- libosdp-3.0.8/vendor/src/osdp_export.h +0 -1
- {libosdp-3.0.8 → libosdp-3.1.2}/MANIFEST.in +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/README.md +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/libosdp.egg-info/dependency_links.txt +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/libosdp.egg-info/top_level.txt +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/osdp/__init__.py +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/osdp/channel.py +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/osdp/helpers.py +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/osdp/key_store.py +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/pyproject.toml +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/setup.cfg +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/crypto/tinyaes_src.c +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/crypto/tinyaes_src.h +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_diag.c +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_file.h +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/src/osdp_sc.c +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/include/utils/disjoint_set.h +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/include/utils/list.h +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/include/utils/logger.h +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/include/utils/pcap_gen.h +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/include/utils/queue.h +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/include/utils/slab.h +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/src/disjoint_set.c +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/src/list.c +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/src/pcap_gen.c +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/src/queue.c +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/src/slab.c +0 -0
- {libosdp-3.0.8 → libosdp-3.1.2}/vendor/utils/src/utils.c +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: libosdp
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.1.2
|
|
4
4
|
Summary: Library implementation of IEC 60839-11-5 OSDP (Open Supervised Device Protocol)
|
|
5
5
|
Home-page: https://github.com/goToMain/libosdp
|
|
6
6
|
Author: Siddharth Chandrasekaran
|
|
@@ -10,6 +10,14 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.8
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: author-email
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: home-page
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
Dynamic: summary
|
|
13
21
|
|
|
14
22
|
# LibOSDP for Python
|
|
15
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: libosdp
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.1.2
|
|
4
4
|
Summary: Library implementation of IEC 60839-11-5 OSDP (Open Supervised Device Protocol)
|
|
5
5
|
Home-page: https://github.com/goToMain/libosdp
|
|
6
6
|
Author: Siddharth Chandrasekaran
|
|
@@ -10,6 +10,14 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.8
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
+
Dynamic: author
|
|
14
|
+
Dynamic: author-email
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: home-page
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
Dynamic: summary
|
|
13
21
|
|
|
14
22
|
# LibOSDP for Python
|
|
15
23
|
|
|
@@ -14,6 +14,7 @@ osdp/helpers.py
|
|
|
14
14
|
osdp/key_store.py
|
|
15
15
|
osdp/peripheral_device.py
|
|
16
16
|
vendor/include/osdp.h
|
|
17
|
+
vendor/include/osdp_export.h
|
|
17
18
|
vendor/python/osdp_sys/base.c
|
|
18
19
|
vendor/python/osdp_sys/cp.c
|
|
19
20
|
vendor/python/osdp_sys/data.c
|
|
@@ -27,7 +28,6 @@ vendor/src/osdp_config.h
|
|
|
27
28
|
vendor/src/osdp_cp.c
|
|
28
29
|
vendor/src/osdp_diag.c
|
|
29
30
|
vendor/src/osdp_diag.h
|
|
30
|
-
vendor/src/osdp_export.h
|
|
31
31
|
vendor/src/osdp_file.c
|
|
32
32
|
vendor/src/osdp_file.h
|
|
33
33
|
vendor/src/osdp_pd.c
|
|
@@ -37,6 +37,7 @@ vendor/src/crypto/tinyaes.c
|
|
|
37
37
|
vendor/src/crypto/tinyaes_src.c
|
|
38
38
|
vendor/src/crypto/tinyaes_src.h
|
|
39
39
|
vendor/utils/include/utils/assert.h
|
|
40
|
+
vendor/utils/include/utils/crc16.h
|
|
40
41
|
vendor/utils/include/utils/disjoint_set.h
|
|
41
42
|
vendor/utils/include/utils/list.h
|
|
42
43
|
vendor/utils/include/utils/logger.h
|
|
@@ -44,6 +45,7 @@ vendor/utils/include/utils/pcap_gen.h
|
|
|
44
45
|
vendor/utils/include/utils/queue.h
|
|
45
46
|
vendor/utils/include/utils/slab.h
|
|
46
47
|
vendor/utils/include/utils/utils.h
|
|
48
|
+
vendor/utils/src/crc16.c
|
|
47
49
|
vendor/utils/src/disjoint_set.c
|
|
48
50
|
vendor/utils/src/list.c
|
|
49
51
|
vendor/utils/src/logger.c
|
|
@@ -26,8 +26,11 @@ class ControlPanel():
|
|
|
26
26
|
self.pd_addr.append(pd_info.address)
|
|
27
27
|
info_list.append(pd_info.get())
|
|
28
28
|
self.event_queue = [ queue.Queue() for i in self.pd_addr ]
|
|
29
|
+
self.user_event_handler = None
|
|
29
30
|
osdp_sys.set_loglevel(log_level)
|
|
30
31
|
self.ctx = osdp_sys.ControlPanel(info_list)
|
|
32
|
+
# Always use our internal handler to ensure queue functionality
|
|
33
|
+
self.ctx.set_event_callback(self._internal_event_handler)
|
|
31
34
|
self.set_event_handler(event_handler)
|
|
32
35
|
self.event = None
|
|
33
36
|
self.lock = None
|
|
@@ -42,13 +45,22 @@ class ControlPanel():
|
|
|
42
45
|
time.sleep(0.020) #sleep for 20ms
|
|
43
46
|
|
|
44
47
|
def set_event_handler(self, handler: Callable[[int, dict], int]):
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
else:
|
|
48
|
-
self.ctx.set_event_callback(self.event_handler)
|
|
48
|
+
"""Set user event handler while maintaining queue functionality"""
|
|
49
|
+
self.user_event_handler = handler
|
|
49
50
|
|
|
50
|
-
def
|
|
51
|
+
def _internal_event_handler(self, pd, event) -> int:
|
|
52
|
+
"""Internal handler that manages both queue and user callback"""
|
|
53
|
+
# Always put event in queue for get_event() compatibility
|
|
51
54
|
self.event_queue[pd].put(event)
|
|
55
|
+
|
|
56
|
+
# If user has set a custom handler, call it too
|
|
57
|
+
if self.user_event_handler:
|
|
58
|
+
try:
|
|
59
|
+
return self.user_event_handler(pd, event)
|
|
60
|
+
except Exception as e:
|
|
61
|
+
print(f"Error in user event handler: {e}")
|
|
62
|
+
return -1
|
|
63
|
+
|
|
52
64
|
return 0
|
|
53
65
|
|
|
54
66
|
def get_event(self, address, timeout: int=5):
|
|
@@ -119,13 +131,18 @@ class ControlPanel():
|
|
|
119
131
|
sc_active += 1
|
|
120
132
|
return sc_active
|
|
121
133
|
|
|
122
|
-
def
|
|
134
|
+
def submit_command(self, address, cmd):
|
|
123
135
|
pd = self.pd_addr.index(address)
|
|
124
136
|
self.lock.acquire()
|
|
125
|
-
ret = self.ctx.
|
|
137
|
+
ret = self.ctx.submit_command(pd, cmd)
|
|
126
138
|
self.lock.release()
|
|
127
139
|
return ret
|
|
128
140
|
|
|
141
|
+
def send_command(self, address, cmd):
|
|
142
|
+
from warnings import warn
|
|
143
|
+
warn("This method has been renamed to submit_command", DeprecationWarning, 2)
|
|
144
|
+
return self.submit_command(address, cmd)
|
|
145
|
+
|
|
129
146
|
def set_flag(self, address, flag: LibFlag):
|
|
130
147
|
pd = self.pd_addr.index(address)
|
|
131
148
|
self.lock.acquire()
|
|
@@ -140,6 +157,27 @@ class ControlPanel():
|
|
|
140
157
|
self.lock.release()
|
|
141
158
|
return ret
|
|
142
159
|
|
|
160
|
+
def disable_pd(self, address: int) -> bool:
|
|
161
|
+
pd = self.pd_addr.index(address)
|
|
162
|
+
self.lock.acquire()
|
|
163
|
+
ret = self.ctx.disable_pd(pd)
|
|
164
|
+
self.lock.release()
|
|
165
|
+
return ret
|
|
166
|
+
|
|
167
|
+
def enable_pd(self, address: int) -> bool:
|
|
168
|
+
pd = self.pd_addr.index(address)
|
|
169
|
+
self.lock.acquire()
|
|
170
|
+
ret = self.ctx.enable_pd(pd)
|
|
171
|
+
self.lock.release()
|
|
172
|
+
return ret
|
|
173
|
+
|
|
174
|
+
def is_pd_enabled(self, address: int) -> bool:
|
|
175
|
+
pd = self.pd_addr.index(address)
|
|
176
|
+
self.lock.acquire()
|
|
177
|
+
ret = self.ctx.is_pd_enabled(pd)
|
|
178
|
+
self.lock.release()
|
|
179
|
+
return ret
|
|
180
|
+
|
|
143
181
|
def register_file_ops(self, address, fops):
|
|
144
182
|
pd = self.pd_addr.index(address)
|
|
145
183
|
self.lock.acquire()
|
|
@@ -197,8 +235,14 @@ class ControlPanel():
|
|
|
197
235
|
|
|
198
236
|
def offline_wait(self, address, timeout=8):
|
|
199
237
|
count = 0
|
|
200
|
-
|
|
201
|
-
|
|
238
|
+
res = False
|
|
239
|
+
while count < timeout * 2:
|
|
240
|
+
time.sleep(0.5)
|
|
241
|
+
if not self.is_online(address):
|
|
242
|
+
res = True
|
|
243
|
+
break
|
|
244
|
+
count += 1
|
|
245
|
+
return res
|
|
202
246
|
|
|
203
247
|
def sc_wait(self, address, timeout=5):
|
|
204
248
|
count = 0
|
|
@@ -19,12 +19,11 @@ class PeripheralDevice():
|
|
|
19
19
|
command_handler: Callable[[dict], Tuple[int, dict]]=None):
|
|
20
20
|
self.command_queue = queue.Queue()
|
|
21
21
|
self.address = pd_info.address
|
|
22
|
+
self.user_command_handler = None
|
|
22
23
|
osdp_sys.set_loglevel(log_level)
|
|
23
24
|
self.ctx = osdp_sys.PeripheralDevice(pd_info.get(), capabilities=pd_cap.get())
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
else:
|
|
27
|
-
self.ctx.set_command_callback(self.command_handler)
|
|
25
|
+
# Always use our internal handler to ensure queue functionality
|
|
26
|
+
self.ctx.set_command_callback(self._internal_command_handler)
|
|
28
27
|
self.set_command_handler(command_handler)
|
|
29
28
|
self.event = None
|
|
30
29
|
self.lock = None
|
|
@@ -38,15 +37,24 @@ class PeripheralDevice():
|
|
|
38
37
|
lock.release()
|
|
39
38
|
time.sleep(0.020) #sleep for 20ms
|
|
40
39
|
|
|
41
|
-
def
|
|
40
|
+
def _internal_command_handler(self, command) -> Tuple[int, dict]:
|
|
41
|
+
"""Internal handler that manages both queue and user callback"""
|
|
42
|
+
# Always put command in queue for get_command() compatibility
|
|
42
43
|
self.command_queue.put(command)
|
|
44
|
+
|
|
45
|
+
# If user has set a custom handler, call it too
|
|
46
|
+
if self.user_command_handler:
|
|
47
|
+
try:
|
|
48
|
+
return self.user_command_handler(command)
|
|
49
|
+
except Exception as e:
|
|
50
|
+
print(f"Error in user command handler: {e}")
|
|
51
|
+
return -1, None
|
|
52
|
+
|
|
43
53
|
return 0, None
|
|
44
54
|
|
|
45
55
|
def set_command_handler(self, handler: Callable[[dict], Tuple[int, dict]]):
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
else:
|
|
49
|
-
self.ctx.set_command_callback(self.command_handler)
|
|
56
|
+
"""Set user command handler while maintaining queue functionality"""
|
|
57
|
+
self.user_command_handler = handler
|
|
50
58
|
|
|
51
59
|
def get_command(self, timeout: int=5):
|
|
52
60
|
block = timeout >= 0
|
|
@@ -56,12 +64,17 @@ class PeripheralDevice():
|
|
|
56
64
|
return None
|
|
57
65
|
return cmd
|
|
58
66
|
|
|
59
|
-
def
|
|
67
|
+
def submit_event(self, event):
|
|
60
68
|
self.lock.acquire()
|
|
61
|
-
ret = self.ctx.
|
|
69
|
+
ret = self.ctx.submit_event(event)
|
|
62
70
|
self.lock.release()
|
|
63
71
|
return ret
|
|
64
72
|
|
|
73
|
+
def notify_event(self, event):
|
|
74
|
+
from warnings import warn
|
|
75
|
+
warn("This method has been renamed to submit_event", DeprecationWarning, 2)
|
|
76
|
+
return self.submit_event(event)
|
|
77
|
+
|
|
65
78
|
def register_file_ops(self, fops):
|
|
66
79
|
self.lock.acquire()
|
|
67
80
|
ret = self.ctx.register_file_ops(0, fops)
|
|
@@ -11,7 +11,7 @@ import shutil
|
|
|
11
11
|
import subprocess
|
|
12
12
|
|
|
13
13
|
project_name = "libosdp"
|
|
14
|
-
project_version = "3.
|
|
14
|
+
project_version = "3.1.2"
|
|
15
15
|
current_dir = os.path.dirname(os.path.realpath(__file__))
|
|
16
16
|
repo_root = os.path.realpath(os.path.join(current_dir, ".."))
|
|
17
17
|
|
|
@@ -63,9 +63,6 @@ def try_vendor_sources(src_dir, src_files, vendor_dir):
|
|
|
63
63
|
|
|
64
64
|
## generate build headers into ./vendor
|
|
65
65
|
|
|
66
|
-
with open("vendor/src/osdp_export.h", "w") as f:
|
|
67
|
-
f.write("#define OSDP_EXPORT\n")
|
|
68
|
-
|
|
69
66
|
git = get_git_info()
|
|
70
67
|
shutil.move("vendor/src/osdp_config.h.in", "vendor/src/osdp_config.h")
|
|
71
68
|
configure_file("vendor/src/osdp_config.h", {
|
|
@@ -85,6 +82,7 @@ utils_sources = [
|
|
|
85
82
|
"utils/src/utils.c",
|
|
86
83
|
"utils/src/logger.c",
|
|
87
84
|
"utils/src/disjoint_set.c",
|
|
85
|
+
"utils/src/crc16.c",
|
|
88
86
|
]
|
|
89
87
|
|
|
90
88
|
utils_includes = [
|
|
@@ -95,6 +93,7 @@ utils_includes = [
|
|
|
95
93
|
"utils/include/utils/utils.h",
|
|
96
94
|
"utils/include/utils/logger.h",
|
|
97
95
|
"utils/include/utils/disjoint_set.h",
|
|
96
|
+
"utils/include/utils/crc16.h",
|
|
98
97
|
]
|
|
99
98
|
|
|
100
99
|
lib_sources = [
|
|
@@ -110,6 +109,7 @@ lib_sources = [
|
|
|
110
109
|
|
|
111
110
|
lib_includes = [
|
|
112
111
|
"include/osdp.h",
|
|
112
|
+
"include/osdp_export.h",
|
|
113
113
|
"src/osdp_common.h",
|
|
114
114
|
"src/osdp_file.h",
|
|
115
115
|
"src/crypto/tinyaes_src.h",
|
|
@@ -147,13 +147,13 @@ try_vendor_sources(
|
|
|
147
147
|
)
|
|
148
148
|
|
|
149
149
|
definitions = [
|
|
150
|
-
"
|
|
151
|
-
# "
|
|
152
|
-
# "
|
|
150
|
+
"OPT_OSDP_PACKET_TRACE",
|
|
151
|
+
# "OPT_OSDP_DATA_TRACE",
|
|
152
|
+
# "OPT_OSDP_SKIP_MARK_BYTE",
|
|
153
153
|
]
|
|
154
154
|
|
|
155
|
-
if ("
|
|
156
|
-
"
|
|
155
|
+
if ("OPT_OSDP_PACKET_TRACE" in definitions or
|
|
156
|
+
"OPT_OSDP_DATA_TRACE" in definitions):
|
|
157
157
|
source_files += [
|
|
158
158
|
"src/osdp_diag.c",
|
|
159
159
|
"utils/src/pcap_gen.c",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
#include <stdint.h>
|
|
16
16
|
#include <stdbool.h>
|
|
17
|
-
#include
|
|
17
|
+
#include "osdp_export.h"
|
|
18
18
|
|
|
19
19
|
#ifdef __cplusplus
|
|
20
20
|
extern "C" {
|
|
@@ -29,6 +29,7 @@ extern "C" {
|
|
|
29
29
|
* possible. Fail where these assumptions don't hold.
|
|
30
30
|
* - Don't allow use of SCBK-D.
|
|
31
31
|
* - Assume that a KEYSET was successful at an earlier time.
|
|
32
|
+
* - CP does not allow user requested broadcast commands (see OSDP_CMD_FLAG_BROADCAST)
|
|
32
33
|
*
|
|
33
34
|
* @note This flag is recommended in production use.
|
|
34
35
|
*/
|
|
@@ -64,7 +65,7 @@ extern "C" {
|
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* @brief Capture raw osdp packets as seen by this device to a pcap file.
|
|
67
|
-
* LibOSDP must be built with
|
|
68
|
+
* LibOSDP must be built with OPT_OSDP_PACKET_TRACE or OPT_OSDP_DATA_TRACE
|
|
68
69
|
* for this flag to be in effect.
|
|
69
70
|
*
|
|
70
71
|
* @note The app must call osdp_{cp,pd}_teardown() before existing for the
|
|
@@ -185,6 +186,22 @@ enum osdp_pd_cap_function_code_e {
|
|
|
185
186
|
*/
|
|
186
187
|
OSDP_PD_CAP_BIOMETRICS,
|
|
187
188
|
|
|
189
|
+
/**
|
|
190
|
+
* This capability indicates if the reader is capable of supporting
|
|
191
|
+
* Secure Pin Entry (SPE) for smart cards
|
|
192
|
+
*/
|
|
193
|
+
OSDP_PD_CAP_SECURE_PIN_ENTRY,
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* This capability indicates the version of OSDP the PD supports
|
|
197
|
+
*
|
|
198
|
+
* Compliance Levels:
|
|
199
|
+
* 0 - Unspecified
|
|
200
|
+
* 1 - IEC 60839-11-5
|
|
201
|
+
* 2 - SIA OSDP 2.2
|
|
202
|
+
*/
|
|
203
|
+
OSDP_PD_CAP_OSDP_VERSION,
|
|
204
|
+
|
|
188
205
|
/**
|
|
189
206
|
* Capability Sentinel
|
|
190
207
|
*/
|
|
@@ -279,6 +296,14 @@ typedef int (*osdp_write_fn_t)(void *data, uint8_t *buf, int len);
|
|
|
279
296
|
*/
|
|
280
297
|
typedef void (*osdp_flush_fn_t)(void *data);
|
|
281
298
|
|
|
299
|
+
/**
|
|
300
|
+
* @brief pointer to function that closes the underlying channel. This call is
|
|
301
|
+
* made when LibOSDP is terminating, once per PD.
|
|
302
|
+
*
|
|
303
|
+
* @param data for use by underlying layers. osdp_channel::data is passed
|
|
304
|
+
*/
|
|
305
|
+
typedef void (*osdp_close_fn_t)(void *data);
|
|
306
|
+
|
|
282
307
|
/**
|
|
283
308
|
* @brief User defined communication channel abstraction for OSDP devices.
|
|
284
309
|
* The methods for read/write/flush are expected to be non-blocking.
|
|
@@ -308,6 +333,10 @@ struct osdp_channel {
|
|
|
308
333
|
* Pointer to function used to flush the channel (optional)
|
|
309
334
|
*/
|
|
310
335
|
osdp_flush_fn_t flush;
|
|
336
|
+
/**
|
|
337
|
+
* Pointer to function used to close the channel (optional)
|
|
338
|
+
*/
|
|
339
|
+
osdp_close_fn_t close;
|
|
311
340
|
};
|
|
312
341
|
|
|
313
342
|
/**
|
|
@@ -393,6 +422,8 @@ enum osdp_status_report_type {
|
|
|
393
422
|
OSDP_STATUS_REPORT_REMOTE,
|
|
394
423
|
};
|
|
395
424
|
|
|
425
|
+
#define OSDP_STATUS_REPORT_MAX_LEN 64
|
|
426
|
+
|
|
396
427
|
/**
|
|
397
428
|
* @brief Status report structure. Used by OSDP_CMD_STATUS and
|
|
398
429
|
* OSDP_EVENT_STATUS. In case of command, it is used to send a query to the PD
|
|
@@ -411,9 +442,9 @@ struct osdp_status_report {
|
|
|
411
442
|
*/
|
|
412
443
|
int nr_entries;
|
|
413
444
|
/**
|
|
414
|
-
* Status
|
|
445
|
+
* Status report
|
|
415
446
|
*/
|
|
416
|
-
|
|
447
|
+
uint8_t report[OSDP_STATUS_REPORT_MAX_LEN];
|
|
417
448
|
};
|
|
418
449
|
|
|
419
450
|
/* ------------------------------- */
|
|
@@ -424,8 +455,6 @@ struct osdp_status_report {
|
|
|
424
455
|
#define OSDP_CMD_KEYSET_KEY_MAX_LEN 32
|
|
425
456
|
#define OSDP_CMD_MFG_MAX_DATALEN 64
|
|
426
457
|
|
|
427
|
-
#define OSDP_CMD_FILE_TX_FLAG_CANCEL (1UL << 31)
|
|
428
|
-
|
|
429
458
|
/**
|
|
430
459
|
* @brief Command sent from CP to Control digital output of PD.
|
|
431
460
|
*/
|
|
@@ -641,19 +670,21 @@ struct osdp_cmd_mfg {
|
|
|
641
670
|
*/
|
|
642
671
|
uint32_t vendor_code;
|
|
643
672
|
/**
|
|
644
|
-
*
|
|
673
|
+
* Command data
|
|
645
674
|
*/
|
|
646
|
-
uint8_t
|
|
675
|
+
uint8_t data[OSDP_CMD_MFG_MAX_DATALEN];
|
|
647
676
|
/**
|
|
648
|
-
*
|
|
677
|
+
* Length of the data (internal use)
|
|
649
678
|
*/
|
|
650
679
|
uint8_t length;
|
|
651
|
-
/**
|
|
652
|
-
* Command data (optional)
|
|
653
|
-
*/
|
|
654
|
-
uint8_t data[OSDP_CMD_MFG_MAX_DATALEN];
|
|
655
680
|
};
|
|
656
681
|
|
|
682
|
+
/**
|
|
683
|
+
* @brief A CP only flag that can be used by the application to cancel an
|
|
684
|
+
* in-flight file transfer.
|
|
685
|
+
*/
|
|
686
|
+
#define OSDP_CMD_FILE_TX_FLAG_CANCEL (1UL << 31)
|
|
687
|
+
|
|
657
688
|
/**
|
|
658
689
|
* @brief File transfer start command
|
|
659
690
|
*/
|
|
@@ -665,8 +696,10 @@ struct osdp_cmd_file_tx {
|
|
|
665
696
|
/**
|
|
666
697
|
* Reserved and set to zero by OSDP spec.
|
|
667
698
|
*
|
|
668
|
-
* @note: The upper bits are used by libosdp
|
|
669
|
-
*
|
|
699
|
+
* @note: The upper bits are used by libosdp internally (IOW, not sent
|
|
700
|
+
* over the OSDP bus). Currently the following flags are defined:
|
|
701
|
+
*
|
|
702
|
+
* - @ref OSDP_CMD_FILE_TX_FLAG_CANCEL
|
|
670
703
|
*/
|
|
671
704
|
uint32_t flags;
|
|
672
705
|
};
|
|
@@ -684,18 +717,27 @@ enum osdp_cmd_e {
|
|
|
684
717
|
OSDP_CMD_MFG, /**< Manufacturer specific command */
|
|
685
718
|
OSDP_CMD_FILE_TX, /**< File transfer command */
|
|
686
719
|
OSDP_CMD_STATUS, /**< Status report command */
|
|
720
|
+
OSDP_CMD_COMSET_DONE, /**< Comset completed; Alias for OSDP_CMD_COMSET */
|
|
687
721
|
OSDP_CMD_SENTINEL /**< Max command value */
|
|
688
722
|
};
|
|
689
723
|
|
|
724
|
+
/**
|
|
725
|
+
* @brief When set (`struct osdp_cmd::flags`), the command is sent out with the
|
|
726
|
+
* OSDP packet broadcast flag to the PD.
|
|
727
|
+
*
|
|
728
|
+
* According to the OSDP specification: "the use of the broadcast address should
|
|
729
|
+
* be limited to controlled (single PD) configurations". So this flag will be
|
|
730
|
+
* ignored in ENFORCE_SECURE mode.
|
|
731
|
+
*/
|
|
732
|
+
#define OSDP_CMD_FLAG_BROADCAST 0x000000001
|
|
733
|
+
|
|
690
734
|
/**
|
|
691
735
|
* @brief OSDP Command Structure. This is a wrapper for all individual OSDP
|
|
692
736
|
* commands.
|
|
693
737
|
*/
|
|
694
738
|
struct osdp_cmd {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
*/
|
|
698
|
-
enum osdp_cmd_e id;
|
|
739
|
+
enum osdp_cmd_e id; /**< Command ID. Used to select specific commands in union */
|
|
740
|
+
uint32_t flags; /**< Flags; see OSDP_CMD_FLAG_* flags for possibilities */
|
|
699
741
|
/** Command */
|
|
700
742
|
union {
|
|
701
743
|
struct osdp_cmd_led led; /**< LED command structure */
|
|
@@ -725,17 +767,12 @@ struct osdp_cmd {
|
|
|
725
767
|
enum osdp_event_cardread_format_e {
|
|
726
768
|
OSDP_CARD_FMT_RAW_UNSPECIFIED, /**< Unspecified card format */
|
|
727
769
|
OSDP_CARD_FMT_RAW_WIEGAND, /**< Wiegand card format */
|
|
728
|
-
OSDP_CARD_FMT_ASCII, /**< ASCII card format */
|
|
770
|
+
OSDP_CARD_FMT_ASCII, /**< ASCII card format (deprecated; don't use) */
|
|
729
771
|
OSDP_CARD_FMT_SENTINEL /**< Max card format value */
|
|
730
772
|
};
|
|
731
773
|
|
|
732
774
|
/**
|
|
733
775
|
* @brief OSDP event cardread
|
|
734
|
-
*
|
|
735
|
-
* @note When @a format is set to OSDP_CARD_FMT_RAW_UNSPECIFIED or
|
|
736
|
-
* OSDP_CARD_FMT_RAW_WIEGAND, the length is expressed in bits. OTOH, when it is
|
|
737
|
-
* set to OSDP_CARD_FMT_ASCII, the length is in bytes. The number of bytes to
|
|
738
|
-
* read from the @a data field must be interpreted accordingly.
|
|
739
776
|
*/
|
|
740
777
|
struct osdp_event_cardread {
|
|
741
778
|
/**
|
|
@@ -753,7 +790,7 @@ struct osdp_event_cardread {
|
|
|
753
790
|
*/
|
|
754
791
|
int direction;
|
|
755
792
|
/**
|
|
756
|
-
* Length of card data in
|
|
793
|
+
* Length of card data in bits
|
|
757
794
|
*/
|
|
758
795
|
int length;
|
|
759
796
|
/**
|
|
@@ -796,10 +833,6 @@ struct osdp_event_mfgrep {
|
|
|
796
833
|
* 3-bytes IEEE assigned OUI of manufacturer
|
|
797
834
|
*/
|
|
798
835
|
uint32_t vendor_code;
|
|
799
|
-
/**
|
|
800
|
-
* 1-byte reply code
|
|
801
|
-
*/
|
|
802
|
-
uint8_t command;
|
|
803
836
|
/**
|
|
804
837
|
* Length of manufacturer data in bytes (optional)
|
|
805
838
|
*/
|
|
@@ -869,10 +902,8 @@ enum osdp_event_type {
|
|
|
869
902
|
* @brief OSDP Event structure.
|
|
870
903
|
*/
|
|
871
904
|
struct osdp_event {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
*/
|
|
875
|
-
enum osdp_event_type type;
|
|
905
|
+
enum osdp_event_type type; /**< Event type. Used to select specific event in union */
|
|
906
|
+
uint32_t flags; /**< Flags; reserved, set to zero */
|
|
876
907
|
/** Event */
|
|
877
908
|
union {
|
|
878
909
|
struct osdp_event_keypress keypress; /**< Keypress event structure */
|
|
@@ -983,9 +1014,23 @@ void osdp_pd_set_command_callback(osdp_t *ctx, pd_command_callback_t cb,
|
|
|
983
1014
|
* @retval 0 on success
|
|
984
1015
|
* @retval -1 on failure
|
|
985
1016
|
*/
|
|
986
|
-
|
|
1017
|
+
OSDP_DEPRECATED_EXPORT("Use osdp_pd_submit_event() instead!")
|
|
987
1018
|
int osdp_pd_notify_event(osdp_t *ctx, const struct osdp_event *event);
|
|
988
1019
|
|
|
1020
|
+
/**
|
|
1021
|
+
* @brief Submit PD events to CP. These events are delivered to the CP as a
|
|
1022
|
+
* response to a future POLL command. A successful return does not mean CP
|
|
1023
|
+
* received it, it only means LibOSDP accepted this submission.
|
|
1024
|
+
*
|
|
1025
|
+
* @param ctx OSDP context
|
|
1026
|
+
* @param event pointer to event struct. Must be filled by application.
|
|
1027
|
+
*
|
|
1028
|
+
* @retval 0 on success
|
|
1029
|
+
* @retval -1 on failure
|
|
1030
|
+
*/
|
|
1031
|
+
OSDP_EXPORT
|
|
1032
|
+
int osdp_pd_submit_event(osdp_t *ctx, const struct osdp_event *event);
|
|
1033
|
+
|
|
989
1034
|
/**
|
|
990
1035
|
* @brief Deletes all events from the PD's event queue.
|
|
991
1036
|
*
|
|
@@ -1014,6 +1059,19 @@ int osdp_pd_flush_events(osdp_t *ctx);
|
|
|
1014
1059
|
OSDP_EXPORT
|
|
1015
1060
|
osdp_t *osdp_cp_setup(int num_pd, const osdp_pd_info_t *info);
|
|
1016
1061
|
|
|
1062
|
+
/**
|
|
1063
|
+
* @brief Adds more PD devices in the CP control list.
|
|
1064
|
+
*
|
|
1065
|
+
* @param num_pd Number of PDs connected to this CP. The `osdp_pd_info_t *` is
|
|
1066
|
+
* treated as an array of length num_pd.
|
|
1067
|
+
* @param info Pointer to info struct populated by application.
|
|
1068
|
+
*
|
|
1069
|
+
* @retval 0 on success
|
|
1070
|
+
* @retval -1 on failure
|
|
1071
|
+
*/
|
|
1072
|
+
OSDP_EXPORT
|
|
1073
|
+
int osdp_cp_add_pd(osdp_t *ctx, int num_pd, const osdp_pd_info_t *info);
|
|
1074
|
+
|
|
1017
1075
|
/**
|
|
1018
1076
|
* @brief Periodic refresh method. Must be called by the application at least
|
|
1019
1077
|
* once every 50ms to meet OSDP timing requirements.
|
|
@@ -1046,9 +1104,28 @@ void osdp_cp_teardown(osdp_t *ctx);
|
|
|
1046
1104
|
* @note This method only adds the command on to a particular PD's command
|
|
1047
1105
|
* queue. The command itself can fail due to various reasons.
|
|
1048
1106
|
*/
|
|
1049
|
-
|
|
1107
|
+
OSDP_DEPRECATED_EXPORT("Use osdp_cp_submit_command() instead!")
|
|
1050
1108
|
int osdp_cp_send_command(osdp_t *ctx, int pd, const struct osdp_cmd *cmd);
|
|
1051
1109
|
|
|
1110
|
+
/**
|
|
1111
|
+
* @brief Submit CP commands to PD. These commands are queued to be sent to the
|
|
1112
|
+
* PD at the next available opportunity. A successful return does not mean PD
|
|
1113
|
+
* received it, it only means LibOSDP accepted this submission.
|
|
1114
|
+
*
|
|
1115
|
+
* @param ctx OSDP context
|
|
1116
|
+
* @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to
|
|
1117
|
+
* osdp_cp_setup()
|
|
1118
|
+
* @param cmd command pointer. Must be filled by application.
|
|
1119
|
+
*
|
|
1120
|
+
* @retval 0 on success
|
|
1121
|
+
* @retval -1 on failure
|
|
1122
|
+
*
|
|
1123
|
+
* @note This method only adds the command on to a particular PD's command
|
|
1124
|
+
* queue. The command itself can fail due to various reasons.
|
|
1125
|
+
*/
|
|
1126
|
+
OSDP_EXPORT
|
|
1127
|
+
int osdp_cp_submit_command(osdp_t *ctx, int pd, const struct osdp_cmd *cmd);
|
|
1128
|
+
|
|
1052
1129
|
/**
|
|
1053
1130
|
* @brief Deletes all commands queued for a give PD
|
|
1054
1131
|
*
|
|
@@ -1124,6 +1201,47 @@ void osdp_cp_set_event_callback(osdp_t *ctx, cp_event_callback_t cb, void *arg);
|
|
|
1124
1201
|
OSDP_EXPORT
|
|
1125
1202
|
int osdp_cp_modify_flag(osdp_t *ctx, int pd, uint32_t flags, bool do_set);
|
|
1126
1203
|
|
|
1204
|
+
/**
|
|
1205
|
+
* @brief Disable a PD managed by the CP. Disabled PDs are brought to a safe
|
|
1206
|
+
* state and will not process commands or generate events.
|
|
1207
|
+
*
|
|
1208
|
+
* @param ctx OSDP context
|
|
1209
|
+
* @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to
|
|
1210
|
+
* osdp_cp_setup()
|
|
1211
|
+
*
|
|
1212
|
+
* @retval 0 on success
|
|
1213
|
+
* @retval -1 on failure
|
|
1214
|
+
*/
|
|
1215
|
+
OSDP_EXPORT
|
|
1216
|
+
int osdp_cp_disable_pd(osdp_t *ctx, int pd);
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* @brief Enable a previously disabled PD. The PD will start up as it would
|
|
1220
|
+
* during initial setup.
|
|
1221
|
+
*
|
|
1222
|
+
* @param ctx OSDP context
|
|
1223
|
+
* @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to
|
|
1224
|
+
* osdp_cp_setup()
|
|
1225
|
+
*
|
|
1226
|
+
* @retval 0 on success
|
|
1227
|
+
* @retval -1 on failure
|
|
1228
|
+
*/
|
|
1229
|
+
OSDP_EXPORT
|
|
1230
|
+
int osdp_cp_enable_pd(osdp_t *ctx, int pd);
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* @brief Check if a PD is currently enabled.
|
|
1234
|
+
*
|
|
1235
|
+
* @param ctx OSDP context
|
|
1236
|
+
* @param pd PD offset (0-indexed) of this PD in `osdp_pd_info_t *` passed to
|
|
1237
|
+
* osdp_cp_setup()
|
|
1238
|
+
*
|
|
1239
|
+
* @retval true if PD is enabled
|
|
1240
|
+
* @retval false if PD is disabled or on error
|
|
1241
|
+
*/
|
|
1242
|
+
OSDP_EXPORT
|
|
1243
|
+
bool osdp_cp_is_pd_enabled(const osdp_t *ctx, int pd);
|
|
1244
|
+
|
|
1127
1245
|
/* ------------------------------- */
|
|
1128
1246
|
/* Common Methods */
|
|
1129
1247
|
/* ------------------------------- */
|