Commit 61588537 authored by Alan Mitchell's avatar Alan Mitchell
Browse files

Added decoder for Dragino distance measuring sensors.

parent 86ef6a41
......@@ -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 = (
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment