diff --git a/dingtek-do202/CHANGELOG.md b/dingtek-do202/CHANGELOG.md new file mode 100644 index 000000000..d86775c7c --- /dev/null +++ b/dingtek-do202/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 1.0.0 - 2026-06-09 + +- First version of plugin \ No newline at end of file diff --git a/dingtek-do202/LICENSE.md b/dingtek-do202/LICENSE.md new file mode 100644 index 000000000..bffeef341 --- /dev/null +++ b/dingtek-do202/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2026 Thinger.io + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/dingtek-do202/README.md b/dingtek-do202/README.md new file mode 100644 index 000000000..cd130cfb0 --- /dev/null +++ b/dingtek-do202/README.md @@ -0,0 +1,61 @@ +# DO202 - Parking Occupancy Sensor + +The CNDingtek DO202 is a surface-mounted parking occupancy sensor designed for smart parking projects. It combines microwave radar range measurement and magnetic detection to accurately identify whether a parking space is occupied. The device uploads parking status data through LoRaWAN wireless networks to cloud servers via LoRaWAN gateways, enabling real-time parking guidance, operation management, and platform integration. + +## Key Features + +- **Dual Detection Technology**: Combination of 24GHz microwave radar and magnetic measurement for reliable parking occupancy detection +- **Environmental Sensors**: Built-in temperature and humidity monitoring +- **Temperature Measurement**: -30°C to +85°C (±0.3°C accuracy) +- **Humidity Measurement**: 0-90% RH (±2% RH accuracy) +- **LoRaWAN Connectivity**: Supports multiple frequency bands including CN470, IN865, EU868, US915, AU915, AS923 +- **Rugged Design**: IP68 outdoor protection rating for harsh weather conditions +- **Surface Mounting**: Easy installation with expansion screws +- **Long Battery Life**: Powered by 25500 mAh battery (3x ER26500 batteries) +- **Bluetooth Configuration**: Built-in Bluetooth for easy on-site configuration +- **Compact Dimensions**: 183mm diameter x 38mm height + +## Use Cases + +- Real-time curbside parking occupancy detection +- Roadside parking management and enforcement +- Smart city parking guidance systems +- Parking availability monitoring for municipal parking operations +- Integration with parking management platforms + +## Thinger.io Integration + +The DO202 parking occupancy sensor transmits data via LoRaWAN protocol, enabling seamless integration with Thinger.io for real-time parking space monitoring and management. + +## Requirements + +A LoRaWAN server is required to communicate the CNDingtek DO202 into Thinger.io, some options are: + +- [The Things Stack](https://www.thethingsindustries.com/stack/) +- [LORIOT](https://loriot.io/) +- [ChirpStack](https://www.chirpstack.io/) + +Alongside, the corresponding plugin for the selected LoRaWAN server needs to be installed in your Thinger.io instance. + +## Get Started + +### Installation + +Look for the plugin in the [Thinger.io Plugin Store](https://marketplace.thinger.io/) and install it in your Thinger.io instance. Once the plugin is installed a new Product will be created for this device. + +### Configuration + +The Product is already preconfigured, check that the auto provision prefix matches the one selected in your LoRaWAN server plugin in Thinger.io, or change it to your desire. + +### Usage + +Start sending uplinks for autoprovisioning devices and buckets. +This product also provides a predefined dashboard and downlinks. + +## Additional Resources + +CNDingtek resources can be found at: + +- [Product Page](https://www.dingtek.com/smart-parking-occupancy-sensor-do202) +- [Device Repository](https://www.thethingsnetwork.org/device-repository/devices/dingtek/do202) +- [Thinger docs](https://docs.thinger.io) \ No newline at end of file diff --git a/dingtek-do202/assets/do202.png b/dingtek-do202/assets/do202.png new file mode 100644 index 000000000..b53456bb5 Binary files /dev/null and b/dingtek-do202/assets/do202.png differ diff --git a/dingtek-do202/plugin.json b/dingtek-do202/plugin.json new file mode 100644 index 000000000..17799d977 --- /dev/null +++ b/dingtek-do202/plugin.json @@ -0,0 +1,134 @@ +{ + "name": "dingtek_do202", + "version": "1.0.0", + "description": "The CNDingtek do202 is parking occupancy sensor with combination of microwave radar and magnetic detection, temperature and humidity measurement.", + "author": "Thinger.io", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/thinger-io/plugins.git", + "directory": "dingtek-do202" + }, + "metadata": { + "name": "Dingtek DO202", + "description": "The CNDingtek do202 is parking occupancy sensor with combination of microwave radar and magnetic detection, temperature and humidity measurement.", + "image": "assets/do202.png", + "category": "devices", + "vendor": "dingtek" + }, + "resources": { + "products": [ + { + "description": "The CNDingtek do202 is parking occupancy sensor with combination of microwave radar and magnetic detection, temperature and humidity measurement.", + "enabled": true, + "name": "Dingtek DO202", + "product": "dingtek_do202", + "profile": { + "api": { + "downlink": { + "enabled": true, + "handle_connectivity": false, + "request": { + "data": { + "path": "/downlink", + "payload": "{\n \"data\" : \"{{payload.data=\"\"}}\",\n \"port\" : {{payload.port=3}},\n \"priority\": {{payload.priority=3}},\n \"confirmed\" : {{payload.confirmed=false}},\n \"uplink\" : {{property.uplink}} \n}", + "payload_function": "", + "payload_type": "", + "plugin": "{{property.uplink.source}}", + "target": "plugin_endpoint" + } + } + }, + "uplink": { + "device_id_resolver": "getId", + "enabled": true, + "handle_connectivity": true, + "request": { + "data": { + "payload": "{{payload}}", + "payload_function": "", + "payload_type": "source_payload", + "resource_stream": "uplink", + "target": "resource_stream" + } + } + } + }, + "autoprovisions": { + "device_autoprovisioning": { + "config": { + "mode": "pattern", + "pattern": "do202_.*" + }, + "enabled": true + } + }, + "buckets": { + "dingtek_do202_data": { + "backend": "mongodb", + "data": { + "payload": "{{payload}}", + "payload_function": "", + "payload_type": "source_payload", + "resource_stream": "uplink_decoded", + "source": "resource_stream" + }, + "enabled": true, + "retention": { + "period": 3, + "unit": "months" + }, + "tags": [] + } + }, + "code": { + "code": "function decodeThingerUplink(thingerData) {\n // 0. If data has already been decoded, we will return it\n if (thingerData.decodedPayload) return thingerData.decodedPayload;\n \n // 1. Extract and Validate Input\n // We need 'payload' (hex string) and 'fPort' (integer)\n const hexPayload = thingerData.payload || \"\";\n const port = thingerData.fPort || 1;\n\n // 2. Convert Hex String to Byte Array\n const bytes = [];\n for (let i = 0; i < hexPayload.length; i += 2) {\n bytes.push(parseInt(hexPayload.substr(i, 2), 16));\n }\n\n // 3. Dynamic Function Detection and Execution\n \n // CASE A: (The Things Stack v3)\n if (typeof decodeUplink === 'function') {\n try {\n const input = {\n bytes: bytes,\n fPort: port\n };\n var result = decodeUplink(input);\n \n if (result.data) return result.data;\n\n return result; \n } catch (e) {\n console.error(\"Error inside decodeUplink:\", e);\n throw e;\n }\n }\n\n // CASE B: Legacy TTN (v2)\n else if (typeof Decoder === 'function') {\n try {\n return Decoder(bytes, port);\n } catch (e) {\n console.error(\"Error inside Decoder:\", e);\n throw e;\n }\n }\n\n // CASE C: No decoder found\n else {\n throw new Error(\"No compatible TTN decoder function (decodeUplink or Decoder) found in scope.\");\n }\n}\n\n\n// TTN decoder\nvar units = [' ℃', ' hours', ' minutes', ' mm', ' °', ' cm'];\n//IEEE754 hex to float convert\nfunction hex2float(num) {\n var sign = num & 0x80000000 ? -1 : 1;\n var exponent = ((num >> 23) & 0xff) - 127;\n var mantissa = 1 + (num & 0x7fffff) / 0x7fffff;\n return sign * mantissa * Math.pow(2, exponent);\n}\n\nfunction decodeUplink(input) {\n if (input.fPort != 3) {\n return {\n errors: ['unknown FPort'],\n };\n }\n\n switch (input.bytes.length) {\n case 23:\n var mag_x = (input.bytes[11] << 8) + input.bytes[12];\n var mag_y = (input.bytes[13] << 8) + input.bytes[14];\n var mag_z = (input.bytes[15] << 8) + input.bytes[16];\n var rawTemperature = input.bytes[17];\n return {\n // Decoded data\n data: {\n \n volt: ((input.bytes[9] << 8) + input.bytes[10]) / 100,\n alarmPark: Boolean(input.bytes[7] >> 4),\n alarmLevel: Boolean(input.bytes[7] & 0x0f),\n alarmMagnet: Boolean(input.bytes[8] >> 4),\n alarmBattery: Boolean(input.bytes[8] & 0x0f),\n xMagnet: mag_x > 32767 ? mag_x - 65536 :\n mag_x,\n yMagnet: mag_y > 32767 ? mag_y - 65536 :\n mag_y,\n zMagnet: mag_z > 32767 ? mag_z - 65536 :\n mag_z,\n temperature: rawTemperature > 127 ? rawTemperature - 256 : rawTemperature,\n humidity: input.bytes[18],\n frameCounter: (input.bytes[19] << 8) + input.bytes[20],\n },\n };\n\n case 16:\n var data_type = input.bytes[3];\n if (data_type === 0x03) {\n return {\n // Decoded parameter\n data: {\n firmware: input.bytes[5] + \".\" + input.bytes[6],\n uploadInterval: input.bytes[7],\n detectInterval: input.bytes[8], \n magnetThreshold: (input.bytes[10] << 8) + input.bytes[11],\n batteryThreshold: input.bytes[12],\n },\n };\n }\n default:\n return {\n errors: ['wrong length'],\n };\n }\n}\n\nfunction encodeDownlink(input) {\n if (input.data.uploadInterval !== null && !isNaN(input.data.uploadInterval)) {\n var periodic_interval = input.data.uploadInterval;\n var periodic_interval_high = periodic_interval.toString(16).padStart(2, '0').toUpperCase()[0].charCodeAt(0);\n var periodic_interval_low = periodic_interval.toString(16).padStart(2, '0').toUpperCase()[1].charCodeAt(0);\n if (periodic_interval > 168 || periodic_interval < 1) {\n return {\n errors: ['periodic upload interval range 1-168 hours.'],\n };\n } else {\n return {\n // LoRaWAN FPort used for the downlink message\n fPort: 3,\n // Encoded bytes\n bytes: [0x38, 0x30, 0x30, 0x32, 0x39, 0x39, 0x39, 0x39, 0x30, 0x31, periodic_interval_high, periodic_interval_low, 0x38, 0x31],\n };\n }\n }\n if (input.data.detectInterval !== null && !isNaN(input.data.detectInterval)) {\n var detection_interval = input.data.detectInterval;\n var detection_interval_high = detection_interval.toString(16).padStart(2, '0').toUpperCase()[0].charCodeAt(0);\n var detection_interval_low = detection_interval.toString(16).padStart(2, '0').toUpperCase()[1].charCodeAt(0);\n if (detection_interval > 60 || detection_interval < 1) {\n return {\n errors: ['ultra detection interval range 1-60 minutes.'],\n };\n } else {\n return {\n // LoRaWAN FPort used for the downlink message\n fPort: 3,\n // Encoded bytes\n bytes: [0x38, 0x30, 0x30, 0x32, 0x39, 0x39, 0x39, 0x39, 0x30, 0x38, detection_interval_high, detection_interval_low, 0x38, 0x31],\n };\n }\n }\n \n if (input.data.magnetThreshold !== null && !isNaN(input.data.magnetThreshold)) {\n var magnetThreshold = input.data.magnetThreshold;\n var magnetThreshold_1 = magnetThreshold.toString(16).padStart(4, '0').toUpperCase()[0].charCodeAt(0);\n var magnetThreshold_2 = magnetThreshold.toString(16).padStart(4, '0').toUpperCase()[1].charCodeAt(0);\n var magnetThreshold_3 = magnetThreshold.toString(16).padStart(4, '0').toUpperCase()[2].charCodeAt(0);\n var magnetThreshold_4 = magnetThreshold.toString(16).padStart(4, '0').toUpperCase()[3].charCodeAt(0);\n if (magnetThreshold > 65535 || magnetThreshold < 1) {\n return {\n errors: ['magnet threshold range 1-65535.'],\n };\n } else {\n return {\n // LoRaWAN FPort used for the downlink message\n fPort: 3,\n // Encoded bytes\n bytes: [0x38, 0x30, 0x30, 0x32, 0x39, 0x39, 0x39, 0x39, 0x30, 0x46, magnetThreshold_1, magnetThreshold_2, magnetThreshold_3, magnetThreshold_4, 0x38, 0x31],\n };\n }\n\n\n }\n\n if (input.data.batteryThreshold !== null && !isNaN(input.data.batteryThreshold)) {\n var batteryThreshold = input.data.batteryThreshold;\n var batteryThreshold_high = batteryThreshold.toString(16).padStart(2, '0').toUpperCase()[0].charCodeAt(0);\n var batteryThreshold_low = batteryThreshold.toString(16).padStart(2, '0').toUpperCase()[1].charCodeAt(0);\n if (batteryThreshold > 99 || batteryThreshold < 5) {\n return {\n errors: ['battery alarm threshold range 5-99 %.'],\n };\n } else {\n return {\n // LoRaWAN FPort used for the downlink message\n fPort: 3,\n // Encoded bytes\n bytes: [0x38, 0x30, 0x30, 0x32, 0x39, 0x39, 0x39, 0x39, 0x30, 0x35, batteryThreshold_high, batteryThreshold_low, 0x38, 0x31],\n };\n }\n }\n\n\n return {\n errors: ['invalid downlink parameter.'],\n };\n}\n\nfunction decodeDownlink(input) {\n var input_length = input.bytes.length;\n if (input.fPort != 3) {\n return {\n errors: ['invalid FPort.'],\n };\n }\n\n if (\n input_length < 12 ||\n input.bytes[0] != 0x38 ||\n input.bytes[1] != 0x30 ||\n input.bytes[2] != 0x30 ||\n input.bytes[3] != 0x32 ||\n input.bytes[4] != 0x39 ||\n input.bytes[5] != 0x39 ||\n input.bytes[6] != 0x39 ||\n input.bytes[7] != 0x39 ||\n input.bytes[input_length - 2] != 0x38 ||\n input.bytes[input_length - 1] != 0x31\n ) {\n return {\n errors: ['invalid format.'],\n };\n }\n var option = parseInt(String.fromCharCode(input.bytes[8]) + String.fromCharCode(input.bytes[9]), 16);\n var value = parseInt(String.fromCharCode(input.bytes[10]) + String.fromCharCode(input.bytes[11]), 16);\n var value2Bytes = parseInt(String.fromCharCode(input.bytes[10]) + String.fromCharCode(input.bytes[11]) + String.fromCharCode(input.bytes[12]) + String.fromCharCode(input.bytes[13]), 16);\n switch (option) {\n case 1:\n return {\n data: {\n uploadInterval: value,\n },\n };\n \n case 5:\n return {\n data: {\n batteryThreshold: value,\n },\n };\n case 8:\n return {\n data: {\n detectInterval: value,\n },\n };\n case 15:\n return {\n data: {\n magnetThreshold: value2Bytes,\n },\n };\n\n default:\n return {\n errors: ['invalid parameter key.'],\n };\n }\n}", + "environment": "javascript", + "storage": "", + "version": "1.0" + }, + "flows": { + "dingtek_do202_decoder": { + "data": { + "payload": "{{payload}}", + "payload_function": "decodeThingerUplink", + "payload_type": "source_payload", + "resource": "uplink", + "source": "resource", + "update": "events" + }, + "enabled": true, + "sink": { + "payload": "{{payload}}", + "payload_function": "", + "payload_type": "source_payload", + "resource_stream": "uplink_decoded", + "target": "resource_stream" + }, + "split_data": false + } + }, + "properties": { + "uplink": { + "data": { + "payload": "{{payload}}", + "payload_function": "", + "payload_type": "source_payload", + "resource": "uplink", + "source": "resource", + "update": "events" + }, + "default": { + "source": "value" + }, + "enabled": true + } + } + }, + "_resources": { + "properties": [] + } + } + ] + } +} \ No newline at end of file