Skip to content

chrismrutherford/codeSnippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

python lwm2mEncDec.py -e '[{"id": 0, "type": 4, "value": "Acme Corp"}, {"id": 3, "type": 4, "value": "v1.2.3"}, {"id": 9, "type": 6, "value": 85}]' === Encoding Input (JSON) === [ { "id": 0, "type": 4, "value": "Acme Corp" }, { "id": 3, "type": 4, "value": "v1.2.3" }, { "id": 9, "type": 6, "value": 85 } ]

=== Encoded TLV Data === Hex: c8000941636d6520436f7270c60376312e322e33c10955 Length: 23 bytes

=== Round-Trip Verification (Decoding) === === Resource Summary === Resource 0: Manufacturer Type: Resource Value: Acme Corp Raw: 41636d6520436f7270

Resource 3: Firmware Version Type: Resource Value: v1.2.3 Raw: 76312e322e33

Resource 9: Battery Level Type: Resource Value: 85 Raw: 55

(general) chris@chris-OptiPlex-5060:~/repos/cmr$ python lwm2mEncDec.py -e '[{"id": 0, "type": 4, "value": "Acme Corp"}, {"id": 3, "type": 4, "value": "v1.2.3"}, {"id": 9, "type": 6, "value": 85}]' --help usage: lwm2mEncDec.py [-h] (-d HEX_STRING | -e JSON_STRING) [-j] [-q]

Encode/Decode LWM2M TLV messages for debugging.

options: -h, --help show this help message and exit -d HEX_STRING, --decode HEX_STRING Hex string to decode. -e JSON_STRING, --encode JSON_STRING JSON string to encode into TLV. -j, --json Output decoded results as JSON. -q, --quiet Suppress verbose parsing output (show only summary). (general) chris@chris-OptiPlex-5060:~/repos/cmr$ python lwm2mEncDec.py -d "C80008000333D2BBCC3B2DC801143839383832323830363636313730303435383936C10201C10306C8040E5175656374656C5F424336364E41C8051C424336364E4144415230324130315F30312E3030322E30312E303032C206157BC10800" -j === LWM2M TLV Decoding (Wakaama-compliant) === Total data length: 95 bytes Hex: c80008000333d2bbcc3b2dc801143839383832323830363636313730303435383936c10201c10306c8040e5175656374656c5f424336364e41c8051c424336364e4144415230324130315f30312e3030322e30312e303032c206157bc10800

Offset 00: TLV Header 0xC8 (11001000) Type: Resource Resource ID: 0 Data Length: 8 bytes Manufacturer: 4.453533012974767e-309 Raw hex: 000333d2bbcc3b2d

Offset 11: TLV Header 0xC8 (11001000) Type: Resource Resource ID: 1 Data Length: 20 bytes Model Number: 89882280666170045896 Raw hex: 3839383832323830363636313730303435383936

Offset 34: TLV Header 0xC1 (11000001) Type: Resource Resource ID: 2 Data Length: 1 bytes Serial Number: 1 Raw hex: 01

Offset 37: TLV Header 0xC1 (11000001) Type: Resource Resource ID: 3 Data Length: 1 bytes Firmware Version: 6 Raw hex: 06

Offset 40: TLV Header 0xC8 (11001000) Type: Resource Resource ID: 4 Data Length: 14 bytes Reboot: Quectel_BC66NA Raw hex: 5175656374656c5f424336364e41

Offset 57: TLV Header 0xC8 (11001000) Type: Resource Resource ID: 5 Data Length: 28 bytes Factory Reset: BC66NADAR02A01_01.002.01.002 Raw hex: 424336364e4144415230324130315f30312e3030322e30312e303032

Offset 88: TLV Header 0xC2 (11000010) Type: Resource Resource ID: 6 Data Length: 2 bytes Available Power Sources: 5499 Raw hex: 157b

Offset 92: TLV Header 0xC1 (11000001) Type: Resource Resource ID: 8 Data Length: 1 bytes Power Source Current: 0 Raw hex: 00

=== JSON Output === { "lwm2m_resources": { "0": { "id": 0, "name": "Manufacturer", "type": "Resource", "data_type": 9, "value": 4.453533012974767e-309, "raw_hex": "000333d2bbcc3b2d" }, "1": { "id": 1, "name": "Model Number", "type": "Resource", "data_type": 9, "value": "89882280666170045896", "raw_hex": "3839383832323830363636313730303435383936" }, "2": { "id": 2, "name": "Serial Number", "type": "Resource", "data_type": 9, "value": 1, "raw_hex": "01" }, "3": { "id": 3, "name": "Firmware Version", "type": "Resource", "data_type": 9, "value": 6, "raw_hex": "06" }, "4": { "id": 4, "name": "Reboot", "type": "Resource", "data_type": 9, "value": "Quectel_BC66NA", "raw_hex": "5175656374656c5f424336364e41" }, "5": { "id": 5, "name": "Factory Reset", "type": "Resource", "data_type": 9, "value": "BC66NADAR02A01_01.002.01.002", "raw_hex": "424336364e4144415230324130315f30312e3030322e30312e303032" }, "6": { "id": 6, "name": "Available Power Sources", "type": "Resource", "data_type": 9, "value": 5499, "raw_hex": "157b" }, "8": { "id": 8, "name": "Power Source Current", "type": "Resource", "data_type": 9, "value": 0, "raw_hex": "00" } }, "total_resources": 8, "timestamp": "2025-09-30T14:05:15.101613" }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages