# Smart gateway for Sensor Web Plug and Play ## 動機 * 異質性: Heterogeneity * 不同生態系統的物聯網裝置間存在異質性難以互相整合,在整合物聯網系統時會導致不必要的時間及人力成本,使大規模SW-IoT的部署既耗時又費力。 > 解決方案 : > 採用標準資料模型及通訊協議。本專案使用OGC SensorThings API作為物聯網系統網路服務端實作依據。 * 硬體資源限制 * 物聯網裝置的硬體資源各不同,有些可直接聯網,有些礙於記憶體限制或電力限制僅能支援低功號傳輸協議或傳送簡單資料。 > 解決方案 : > 以閘道器作為裝置端網絡與網際網路間之溝通橋樑。 ## 目的 提出一套標準化物聯網裝置隨插即用註冊流程,並實作智慧閘道器做為裝置端與網路服務端溝通媒介。 ## 背景簡介 ### 物聯網基本架構 ![](https://i.imgur.com/KRgjc0m.png) ### 基於國際標準 SensorThings API 之裝置描述文檔 * Sensing capability data model ![](https://i.imgur.com/itIVnQ7.png) * Tasking capability data model ![](https://i.imgur.com/jVSGR9m.png) * 描述文檔範例 ```json { "name": "IoT Device", "description": "IoT Device", "properties": { "UID": "device001" }, "Locations": [ { "name": "CSRSR", "description": "CSRSR", "encodingType": "application/vnd.geo+json", "location": { "type": "Point", "coordinates": [ 24.967757, 121.187112 ] } } ], "Datastreams": [ { "name": "Temperature measurement", "description": "Temp readings", "observationType": "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement", "unitOfMeasurement": { "name": "Celsius", "symbol": "degree Celsius", "definition": "http://unitsofmeasure.org/ucum.html#para-30" }, "Sensor": { "name": "DHT22", "description": "Thermometer", "encodingType": "text/html", "metadata": "https://en.wikipedia.org/wiki/Thermometer" }, "ObservedProperty": { "name": "air_temperature", "definition": "http://mmisw.org/ont/ioos/parameter/air_temperature", "description": "Temperature of air in situ." } } ], "TaskingCapabilities": [ { "name": "buzzer_test_register_2", "description": "", "taskingParameters": { "field": [ { "name": "buzz_time", "description": "ring buzzer several times", "use": "Mandatory", "definition": { "inputType": "Integer", "unitOfMeasurement": "times", "allowedValues": [ { "Max": 10, "Min": 1 } ] } } ] }, "httpProtocol": { "httpMethod": "POST", "absoluteResourcePath": "/device/tasking/open_buzzer", "contentType": "application/json", "headers": { "Content-Type": "application/json" }, "messageBody": "device001:buzzer:{buzz_time}", "optionalParameterList": {} }, "Actuator": { "name": "Buzzer", "description": "Buzzer actuator", "encodingType": "text/plain", "metadata": "Buzzer" } } ] } ``` ## Plug and Play 流程圖 ### 感測能力 ![](https://i.imgur.com/cnrtoZc.png) ### 致動能力 ![](https://i.imgur.com/JgSsQKq.png) ## 智慧閘道器實作 https://github.com/SamChen83527/PNP_Gateway_Java 以Java開發,將電腦轉為智慧閘道器,存取COM Port上的ZigBee通訊模組以溝通物聯網裝置。 ## Reference * https://www.mdpi.com/1424-8220/19/3/495 * https://www.mdpi.com/1424-8220/16/9/1395 * https://www.opengeospatial.org/standards/sensorthings