Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
energy
bmon
Commits
61588537
Commit
61588537
authored
Feb 19, 2021
by
Alan Mitchell
Browse files
Added decoder for Dragino distance measuring sensors.
parent
86ef6a41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
bmsapp/lora/decode_dragino.py
bmsapp/lora/decode_dragino.py
+21
-0
bmsapp/lora/decoder.py
bmsapp/lora/decoder.py
+2
-0
No files found.
bmsapp/lora/decode_dragino.py
View file @
61588537
...
...
@@ -168,6 +168,27 @@ def decode_lwl01(data: bytes) -> Dict[str, Any]:
return
res
def
decode_ldds
(
data
:
bytes
)
->
Dict
[
str
,
Any
]:
"""Returns a dictionary of engineering values decoded from a Dragino distance measuring
sensor, including the LDDS20 and the LDDS75.
The payload 'data' is a byte array.
"""
# holds the dictionary of results
res
=
{}
def
int16
(
ix
:
int
)
->
int
:
"""Returns a 16-bit integer from the 2 bytes starting at index 'ix' in data byte array.
"""
return
(
data
[
ix
]
<<
8
)
|
(
data
[
ix
+
1
])
# Battery voltage
res
[
'vdd'
]
=
(
int16
(
0
)
&
0x3FFF
)
/
1000
# Distance in millimeters
res
[
'distance'
]
=
int16
(
2
)
return
res
def
test_lht65
():
cases
=
(
...
...
bmsapp/lora/decoder.py
View file @
61588537
...
...
@@ -83,6 +83,8 @@ def decode(
elif
dev_id_lwr
.
startswith
(
'boat-lt2'
):
if
integration_payload
[
'port'
]
==
2
:
fields
=
decode_dragino
.
decode_boat_lt2
(
payload
)
elif
dev_id_lwr
.
startswith
(
'ldds'
):
fields
=
decode_dragino
.
decode_ldds
(
payload
)
# some decoders will give a list of values back for one field. If requested, convert
# these into multiple fields with an underscore index at end of field name.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment