Skip to content

Commit 27835d9

Browse files
committed
Merge branch 'release/1.1.5'
2 parents 23ac4fd + 280f34b commit 27835d9

File tree

14 files changed

+642
-223
lines changed

14 files changed

+642
-223
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,6 @@ ENV/
9191
.ropeproject
9292

9393
# Pycharm project settings
94-
.idea
94+
.idea
95+
96+
.pytest_cache

pypozyx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
8181
"""
8282

83-
__version__ = '1.1.4'
83+
__version__ = '1.1.5'
8484

8585
VERSION = __version__
8686
version = __version__

pypozyx/core.py

Lines changed: 165 additions & 123 deletions
Large diffs are not rendered by default.

pypozyx/definitions/bitmasks.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,47 @@
11
#!/usr/bin/env python
22
"""pypozyx.definitions.bitmasks - contains all bitmasks used in Pozyx functionality, such as interrupt flags."""
33

4+
class PozyxBitmasks:
5+
# Bit mask for POZYX_ST_RESULT
6+
POZYX_ST_RESULT_ACC = 0x01
7+
POZYX_ST_RESULT_MAGN = 0x02
8+
POZYX_ST_RESULT_GYR = 0x04
9+
POZYX_ST_RESULT_MCU = 0x08
10+
POZYX_ST_RESULT_PRES = 0x10
11+
POZYX_ST_RESULT_UWB = 0x20
12+
13+
# Bit mask for POZYX_INT_STATUS
14+
POZYX_INT_STATUS_ERR = 0x01
15+
POZYX_INT_STATUS_POS = 0x02
16+
POZYX_INT_STATUS_IMU = 0x04
17+
POZYX_INT_STATUS_RX_DATA = 0x08
18+
POZYX_INT_STATUS_FUNC = 0x10
19+
20+
# Bit mask for POZYX_INT_MASK
21+
POZYX_INT_MASK_ERR = 0x01
22+
POZYX_INT_MASK_POS = 0x02
23+
POZYX_INT_MASK_IMU = 0x04
24+
POZYX_INT_MASK_RX_DATA = 0x08
25+
POZYX_INT_MASK_FUNC = 0x10
26+
POZYX_INT_MASK_TDMA = 0x40
27+
POZYX_INT_MASK_PIN = 0x80
28+
POZYX_INT_MASK_ALL = 0x1F
29+
30+
# Bit mask for POZYX_LED_CTRL
31+
POZYX_LED_CTRL_LED1 = 0x01
32+
POZYX_LED_CTRL_LED2 = 0x02
33+
POZYX_LED_CTRL_LED3 = 0x04
34+
POZYX_LED_CTRL_LED4 = 0x08
35+
36+
# Remote operations
37+
POZYX_REMOTE_READ = 0x02
38+
POZYX_REMOTE_WRITE = 0x04
39+
POZYX_REMOTE_DATA = 0x06
40+
POZYX_REMOTE_FUNCTION = 0x08
41+
42+
# Bit mask for device type
43+
POZYX_TYPE = 0xE0
44+
445
# Bit mask for POZYX_ST_RESULT
546
POZYX_ST_RESULT_ACC = 0x01
647
POZYX_ST_RESULT_MAGN = 0x02
@@ -32,5 +73,11 @@
3273
POZYX_LED_CTRL_LED3 = 0x04
3374
POZYX_LED_CTRL_LED4 = 0x08
3475

76+
# Remote operations
77+
POZYX_REMOTE_READ = 0x02
78+
POZYX_REMOTE_WRITE = 0x04
79+
POZYX_REMOTE_DATA = 0x06
80+
POZYX_REMOTE_FUNCTION = 0x08
81+
3582
# Bit mask for device type
3683
POZYX_TYPE = 0xE0

pypozyx/definitions/constants.py

Lines changed: 219 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,144 @@
11
#!/usr/bin/env python
22
"""pypozyx.definitions.constants - contains all Pozyx constants, such as error definitions, delays, physical convertions."""
33

4+
5+
class PozyxConstants:
6+
# TODO unused in wrappers atm
7+
# Pozyx firmware identifiers
8+
POZYX_FW_MAJOR = 0xF0
9+
POZYX_FW_MINOR = 0xF
10+
11+
# Pozyx device identifier for hardware
12+
POZYX_ANCHOR = 0x00
13+
POZYX_TAG = 0x20
14+
15+
# Pozyx serial buffer sizes
16+
MAX_BUF_SIZE = 100
17+
MAX_SERIAL_SIZE = 28
18+
19+
# Pozyx delay constants
20+
POZYX_DELAY_POLLING = 0.002
21+
POZYX_DELAY_LOCAL_WRITE = 0.001
22+
POZYX_DELAY_LOCAL_FUNCTION = 0.005
23+
POZYX_DELAY_REMOTE_WRITE = 0.005
24+
POZYX_DELAY_REMOTE_FUNCTION = 0.01
25+
POZYX_DELAY_INTERRUPT = 0.1
26+
POZYX_DELAY_CALIBRATION = 1
27+
POZYX_DELAY_MODE_CHANGE = 0.02
28+
POZYX_DELAY_RANGING = 0.025
29+
POZYX_DELAY_REMOTE_RANGING = 0.1
30+
POZYX_DELAY_POSITIONING = 0.2
31+
POZYX_DELAY_REMOTE_POSITIONING = 0.4
32+
POZYX_DELAY_FLASH = 0.5
33+
34+
# Pozyx status returns
35+
POZYX_FAILURE = 0x0
36+
POZYX_SUCCESS = 0x1
37+
POZYX_TIMEOUT = 0x8
38+
39+
# Pozyx positioning dimensions
40+
POZYX_3D = 3
41+
POZYX_2D = 2
42+
POZYX_2_5D = 1
43+
44+
# Pozyx interrupt pin
45+
POZYX_INT_PIN0 = 0x0
46+
POZYX_INT_PIN1 = 0x1
47+
48+
# Pozyx led control indexes
49+
POZYX_LED_CTRL_LEDRX = 0x10
50+
POZYX_LED_CTRL_LEDTX = 0x20
51+
POZYX_LED_ON = True
52+
POZYX_LED_OFF = False
53+
54+
# Pozyx device modes
55+
POZYX_ANCHOR_MODE = 0
56+
POZYX_TAG_MODE = 1
57+
58+
# The GPIO modes
59+
POZYX_GPIO_DIGITAL_INPUT = 0
60+
POZYX_GPIO_PUSHPULL = 1
61+
POZYX_GPIO_OPENDRAIN = 1
62+
63+
# The GPIO pull resistor configuration
64+
POZYX_GPIO_NOPULL = 0
65+
POZYX_GPIO_PULLUP = 1
66+
POZYX_GPIO_PULLDOWN = 2
67+
68+
# anchor selection modes
69+
POZYX_ANCHOR_SEL_MANUAL = 0
70+
POZYX_ANCHOR_SEL_AUTO = 1
71+
72+
# discovery options
73+
POZYX_DISCOVERY_ANCHORS_ONLY = 0
74+
POZYX_DISCOVERY_TAGS_ONLY = 1
75+
POZYX_DISCOVERY_ALL_DEVICES = 2
76+
77+
# positioning algorithm options
78+
POZYX_POS_ALG_UWB_ONLY = 0
79+
POZYX_POS_ALG_TRACKING = 4
80+
81+
# ranging protocol options
82+
POZYX_RANGE_PROTOCOL_PRECISION = 0x00
83+
POZYX_RANGE_PROTOCOL_FAST = 0x01
84+
POZYX_RANGE_PROTOCOL_TEST = 0x02
85+
86+
# positioning filters
87+
FILTER_TYPE_NONE = 0
88+
FILTER_TYPE_FIR = 1
89+
FILTER_TYPE_MOVINGAVERAGE = 3
90+
FILTER_TYPE_MOVINGMEDIAN = 4
91+
92+
# how to intercept pozyx events: by polling or by interrupts
93+
MODE_POLLING = 0
94+
MODE_INTERRUPT = 1
95+
96+
# Division factors for converting the raw register values to meaningful
97+
# physical quantities
98+
POZYX_POS_DIV_MM = 1.0
99+
POZYX_PRESS_DIV_PA = 1000.0
100+
POZYX_MAX_LIN_ACCEL_DIV_MG = 1.0
101+
POZYX_ACCEL_DIV_MG = 16.0
102+
POZYX_GYRO_DIV_DPS = 16.0
103+
POZYX_MAG_DIV_UT = 16.0
104+
POZYX_EULER_DIV_DEG = 16.0
105+
POZYX_QUAT_DIV = 16384.0
106+
POZYX_TEMP_DIV_CELSIUS = 1.0
107+
108+
# flash configuration types
109+
POZYX_FLASH_REGS = 1
110+
POZYX_FLASH_ANCHOR_IDS = 2
111+
POZYX_FLASH_NETWORK = 3
112+
POZYX_FLASH_ALL = 4
113+
114+
# possible pin configuration settings
115+
POZYX_INT_CONFIG = 0x24
116+
PIN_MODE_PUSHPULL = 0
117+
PIN_MODE_OPENDRAIN = 1
118+
119+
# Possible pin activity states
120+
PIN_ACTIVE_LOW = 0
121+
PIN_ACTIVE_HIGH = 1
122+
123+
# Possible UWB settings
124+
POZYX_ALL_CHANNELS = [1, 2, 3, 4, 5, 7]
125+
POZYX_ALL_BITRATES = [0, 1, 2]
126+
POZYX_ALL_PRFS = [1, 2]
127+
POZYX_ALL_PLENS = [0x04, 0x14, 0x24, 0x34, 0x08, 0x18, 0x28, 0x0C]
128+
129+
# Pozyx firmware identifiers
130+
POZYX_FW_MAJOR = 0xF0
131+
POZYX_FW_MINOR = 0xF
132+
133+
# Pozyx device identifier for hardware
4134
POZYX_ANCHOR = 0x00
5135
POZYX_TAG = 0x20
6136

137+
# Pozyx serial buffer sizes
7138
MAX_BUF_SIZE = 100
8139
MAX_SERIAL_SIZE = 28
9140

10-
POZYX_INT_MASK_ALL = 0x1F
141+
# Pozyx delay constants
11142
POZYX_DELAY_POLLING = 0.002
12143
POZYX_DELAY_LOCAL_WRITE = 0.001
13144
POZYX_DELAY_LOCAL_FUNCTION = 0.005
@@ -21,20 +152,28 @@
21152
POZYX_DELAY_POSITIONING = 0.2
22153
POZYX_DELAY_REMOTE_POSITIONING = 0.4
23154
POZYX_DELAY_FLASH = 0.5
155+
156+
# Pozyx status returns
24157
POZYX_FAILURE = 0x0
25158
POZYX_SUCCESS = 0x1
26159
POZYX_TIMEOUT = 0x8
160+
161+
# Pozyx positioning dimensions
27162
POZYX_3D = 3
28163
POZYX_2D = 2
29164
POZYX_2_5D = 1
165+
166+
# Pozyx interrupt pin
30167
POZYX_INT_PIN0 = 0x0
31168
POZYX_INT_PIN1 = 0x1
32169

170+
# Pozyx led control indexes
33171
POZYX_LED_CTRL_LEDRX = 0x10
34172
POZYX_LED_CTRL_LEDTX = 0x20
35173
POZYX_LED_ON = True
36174
POZYX_LED_OFF = False
37175

176+
# Pozyx device modes
38177
POZYX_ANCHOR_MODE = 0
39178
POZYX_TAG_MODE = 1
40179

@@ -83,11 +222,62 @@
83222
POZYX_MAX_LIN_ACCEL_DIV_MG = 1.0
84223
POZYX_ACCEL_DIV_MG = 16.0
85224
POZYX_GYRO_DIV_DPS = 16.0
86-
POZYX_MAG_DIV_UT = 16.0
225+
POZYX_MAG_DIV_UT = 1.0
87226
POZYX_EULER_DIV_DEG = 16.0
88227
POZYX_QUAT_DIV = 16384.0
89228
POZYX_TEMP_DIV_CELSIUS = 1.0
90229

230+
# flash configuration types
231+
POZYX_FLASH_REGS = 1
232+
POZYX_FLASH_ANCHOR_IDS = 2
233+
POZYX_FLASH_NETWORK = 3
234+
POZYX_FLASH_ALL = 4
235+
236+
# possible pin configuration settings
237+
POZYX_INT_CONFIG = 0x24
238+
PIN_MODE_PUSHPULL = 0
239+
PIN_MODE_OPENDRAIN = 1
240+
241+
PIN_ACTIVE_LOW = 0
242+
PIN_ACTIVE_HIGH = 1
243+
244+
POZYX_ALL_CHANNELS = [1, 2, 3, 4, 5, 7]
245+
POZYX_ALL_BITRATES = [0, 1, 2]
246+
POZYX_ALL_PRFS = [1, 2]
247+
POZYX_ALL_PLENS = [0x04, 0x14, 0x24, 0x34, 0x08, 0x18, 0x28, 0x0C]
248+
249+
class PozyxErrorCodes:
250+
POZYX_ERROR_NONE = 0x00
251+
POZYX_ERROR_I2C_WRITE = 0x01
252+
POZYX_ERROR_I2C_CMDFULL = 0x02
253+
POZYX_ERROR_ANCHOR_ADD = 0x03
254+
POZYX_ERROR_COMM_QUEUE_FULL = 0x04
255+
POZYX_ERROR_I2C_READ = 0x05
256+
POZYX_ERROR_UWB_CONFIG = 0x06
257+
POZYX_ERROR_OPERATION_QUEUE_FULL = 0x07
258+
POZYX_ERROR_TDMA = 0xA0
259+
POZYX_ERROR_STARTUP_BUSFAULT = 0x08
260+
POZYX_ERROR_FLASH_INVALID = 0x09
261+
POZYX_ERROR_NOT_ENOUGH_ANCHORS = 0x0A
262+
POZYX_ERROR_DISCOVERY = 0X0B
263+
POZYX_ERROR_CALIBRATION = 0x0C
264+
POZYX_ERROR_FUNC_PARAM = 0x0D
265+
POZYX_ERROR_ANCHOR_NOT_FOUND = 0x0E
266+
POZYX_ERROR_FLASH = 0x0F
267+
POZYX_ERROR_MEMORY = 0x10
268+
POZYX_ERROR_RANGING = 0x11
269+
POZYX_ERROR_RTIMEOUT1 = 0x12
270+
POZYX_ERROR_RTIMEOUT2 = 0x13
271+
POZYX_ERROR_TXLATE = 0x14
272+
POZYX_ERROR_UWB_BUSY = 0x15
273+
POZYX_ERROR_POSALG = 0x16
274+
POZYX_ERROR_NOACK = 0x17
275+
POZYX_ERROR_SNIFF_OVERFLOW = 0xE0
276+
POZYX_ERROR_NO_PPS = 0xF0
277+
POZYX_ERROR_NEW_TASK = 0xF1
278+
POZYX_ERROR_UNRECDEV = 0xFE
279+
POZYX_ERROR_GENERAL = 0xFF
280+
91281
# error-code definitions
92282
POZYX_ERROR_NONE = 0x00
93283
POZYX_ERROR_I2C_WRITE = 0x01
@@ -120,52 +310,32 @@
120310
POZYX_ERROR_UNRECDEV = 0xFE
121311
POZYX_ERROR_GENERAL = 0xFF
122312

123-
# flash configuration types
124-
POZYX_FLASH_REGS = 1
125-
POZYX_FLASH_ANCHOR_IDS = 2
126-
POZYX_FLASH_NETWORK = 3
127-
POZYX_FLASH_ALL = 4
128-
129-
# possible pin configuration settings
130-
POZYX_INT_CONFIG = 0x24
131-
PIN_MODE_PUSHPULL = 0
132-
PIN_MODE_OPENDRAIN = 1
133-
134-
PIN_ACTIVE_LOW = 0
135-
PIN_ACTIVE_HIGH = 1
136-
137-
POZYX_ALL_CHANNELS = [1, 2, 3, 4, 5, 7]
138-
POZYX_ALL_BITRATES = [0, 1, 2]
139-
POZYX_ALL_PRFS = [1, 2]
140-
POZYX_ALL_PLENS = [0x04, 0x14, 0x24, 0x34, 0x08, 0x18, 0x28, 0x0C]
141-
142-
143313
ERROR_CODES = {
144-
POZYX_ERROR_NONE: "NO ERROR",
145-
POZYX_ERROR_I2C_WRITE: "ERROR 0x01: Error writing to a register through the I2C bus",
146-
POZYX_ERROR_I2C_CMDFULL: "ERROR 0x02: Pozyx cannot handle all the I2C commands at once",
147-
POZYX_ERROR_ANCHOR_ADD: "ERROR 0x03: Cannot add anchor to the internal device list",
148-
POZYX_ERROR_COMM_QUEUE_FULL: "ERROR 0x04: Communication queue is full, too many UWB messages",
149-
POZYX_ERROR_I2C_READ: "ERROR 0x05: Error reading from a register from the I2C bus",
150-
POZYX_ERROR_UWB_CONFIG: "ERROR 0x06: Cannot change the UWB configuration",
151-
POZYX_ERROR_OPERATION_QUEUE_FULL: "ERROR 0x07: Pozyx cannot handle all the operations at once",
152-
POZYX_ERROR_STARTUP_BUSFAULT: "ERROR 0x08: Internal bus error",
153-
POZYX_ERROR_FLASH_INVALID: "ERROR 0x09: Flash memory is corrupted or invalid",
154-
POZYX_ERROR_NOT_ENOUGH_ANCHORS: "ERROR 0x0A: Not enough anchors available for positioning",
155-
POZYX_ERROR_DISCOVERY: "ERROR 0x0B: Error during the Discovery process",
156-
POZYX_ERROR_CALIBRATION: "ERROR 0x0C: Error during the auto calibration process",
157-
POZYX_ERROR_FUNC_PARAM: "ERROR 0x0D: Invalid function parameters for the register function",
158-
POZYX_ERROR_ANCHOR_NOT_FOUND: "ERROR 0x0E: The coordinates of an anchor are not found",
159-
POZYX_ERROR_FLASH: "ERROR 0x0F: Flash error",
160-
POZYX_ERROR_MEMORY: "ERROR 0x10: Memory error",
161-
POZYX_ERROR_RANGING: "ERROR 0x11: Ranging failed",
162-
POZYX_ERROR_RTIMEOUT1: "ERROR 0x12: Ranging timeout",
163-
POZYX_ERROR_RTIMEOUT2: "ERROR 0x13: Ranging timeout",
164-
POZYX_ERROR_TXLATE: "ERROR 0x14: Tx was late",
165-
POZYX_ERROR_UWB_BUSY: "ERROR 0x15: UWB is busy",
166-
POZYX_ERROR_POSALG: "ERROR 0x16: Positioning failed",
167-
POZYX_ERROR_NOACK: "ERROR 0x17: No Acknowledge received",
168-
POZYX_ERROR_NEW_TASK: "ERROR 0xF1: Cannot create task",
169-
POZYX_ERROR_UNRECDEV: "ERROR 0xFE: Hardware not recognized. Please contact support@pozyx.io",
170-
POZYX_ERROR_GENERAL: "ERROR 0xFF: General error",
314+
PozyxErrorCodes.POZYX_ERROR_NONE: "NO ERROR",
315+
PozyxErrorCodes.POZYX_ERROR_I2C_WRITE: "ERROR 0x01: Error writing to a register through the I2C bus",
316+
PozyxErrorCodes.POZYX_ERROR_I2C_CMDFULL: "ERROR 0x02: Pozyx cannot handle all the I2C commands at once",
317+
PozyxErrorCodes.POZYX_ERROR_ANCHOR_ADD: "ERROR 0x03: Cannot add anchor to the internal device list",
318+
PozyxErrorCodes.POZYX_ERROR_COMM_QUEUE_FULL: "ERROR 0x04: Communication queue is full, too many UWB messages",
319+
PozyxErrorCodes.POZYX_ERROR_I2C_READ: "ERROR 0x05: Error reading from a register from the I2C bus",
320+
PozyxErrorCodes.POZYX_ERROR_UWB_CONFIG: "ERROR 0x06: Cannot change the UWB configuration",
321+
PozyxErrorCodes.POZYX_ERROR_OPERATION_QUEUE_FULL: "ERROR 0x07: Pozyx cannot handle all the operations at once",
322+
PozyxErrorCodes.POZYX_ERROR_STARTUP_BUSFAULT: "ERROR 0x08: Internal bus error",
323+
PozyxErrorCodes.POZYX_ERROR_FLASH_INVALID: "ERROR 0x09: Flash memory is corrupted or invalid",
324+
PozyxErrorCodes.POZYX_ERROR_NOT_ENOUGH_ANCHORS: "ERROR 0x0A: Not enough anchors available for positioning",
325+
PozyxErrorCodes.POZYX_ERROR_DISCOVERY: "ERROR 0x0B: Error during the Discovery process",
326+
PozyxErrorCodes.POZYX_ERROR_CALIBRATION: "ERROR 0x0C: Error during the auto calibration process",
327+
PozyxErrorCodes.POZYX_ERROR_FUNC_PARAM: "ERROR 0x0D: Invalid function parameters for the register function",
328+
PozyxErrorCodes.POZYX_ERROR_ANCHOR_NOT_FOUND: "ERROR 0x0E: The coordinates of an anchor are not found",
329+
PozyxErrorCodes.POZYX_ERROR_FLASH: "ERROR 0x0F: Flash error",
330+
PozyxErrorCodes.POZYX_ERROR_MEMORY: "ERROR 0x10: Memory error",
331+
PozyxErrorCodes.POZYX_ERROR_RANGING: "ERROR 0x11: Ranging failed",
332+
PozyxErrorCodes.POZYX_ERROR_RTIMEOUT1: "ERROR 0x12: Ranging timeout",
333+
PozyxErrorCodes.POZYX_ERROR_RTIMEOUT2: "ERROR 0x13: Ranging timeout",
334+
PozyxErrorCodes.POZYX_ERROR_TXLATE: "ERROR 0x14: Tx was late",
335+
PozyxErrorCodes.POZYX_ERROR_UWB_BUSY: "ERROR 0x15: UWB is busy",
336+
PozyxErrorCodes.POZYX_ERROR_POSALG: "ERROR 0x16: Positioning failed",
337+
PozyxErrorCodes.POZYX_ERROR_NOACK: "ERROR 0x17: No Acknowledge received",
338+
PozyxErrorCodes.POZYX_ERROR_NEW_TASK: "ERROR 0xF1: Cannot create task",
339+
PozyxErrorCodes.POZYX_ERROR_UNRECDEV: "ERROR 0xFE: Hardware not recognized. Please contact support@pozyx.io",
340+
PozyxErrorCodes.POZYX_ERROR_GENERAL: "ERROR 0xFF: General error",
171341
}

0 commit comments

Comments
 (0)