Slide 1

Slide 1 text

Full-stack IoT Development 以 BLE 閘道器帶來的全新開發模式為例 Hedy Wang System Application Engineer [email protected]

Slide 2

Slide 2 text

About Me • 王雅慧 (Hedy, hedywings@github) • 學歷 ▪ 台北科技大學電子工程系 • 經歷 ▪ 系統應用工程師 愛文西門科技 2 沒了? WTF?

Slide 3

Slide 3 text

3 圖片來源

Slide 4

Slide 4 text

Internet of Things (IoTs) • 智慧家庭 • 智慧電網 • 智慧建築 • 農工業與醫療設備 • 市鎮級感測網路 • … 4 Internet Of Things

Slide 5

Slide 5 text

So Many Protocols… • 物聯網標準眾多 ▪ WiFi, Bluetooth, ZigBee, 6LoWPAN, Thread, Z-Wave… ▪ MQTT, CoAP, XMPP, LWM2M • 協定多又雜,卻沒有統一的標準 5

Slide 6

Slide 6 text

How Machines are Connected 6 橋接 多對多 一對多 圖片來源: 1, 2, 3, 4 閘道器 雲端伺服器 一對一

Slide 7

Slide 7 text

Bluetooth/BLE 7 Classic Dual Mode Single Mode

Slide 8

Slide 8 text

Bluetooth Low Energy (BLE) • 低功耗、低成本 • BLE Protocol Stack 8 Application Host Controller

Slide 9

Slide 9 text

Connection Roles • Central (master) ▪ 週期性地掃描可連線的廣告封包 ▪ 掃到合適封包後初始化 connection,向周邊裝置發起連線 • Peripheral (slave) ▪ 週期性地發出可連線的廣告封包,並接受接入連線 ▪ 連線後遵循 central 的 timing ,並與其交換資料 9

Slide 10

Slide 10 text

Data Model • 基於 ATT/GATT ▪ ATT Client/Server Model ▫ 資料如何在兩個裝置間流動 ▪ GATT ▫ 屬性的組織方式 - 階層式的資料結構 ▫ Attribute 是最小資料元素 ▫ Characteristic 由Attributes 組成 ▫ Service 由 Characteristics 組成 ▫ 整套 attributes 的集合就是一張 table 10 GATT Table

Slide 11

Slide 11 text

BLE Applications • 普遍的應用裝置 ▪ 穿戴式裝置 ▪ 手機/平板 11 圖片來源: 1, 2, 3

Slide 12

Slide 12 text

BLE? IoT? 12 ?

Slide 13

Slide 13 text

Development Models • 準備跟 Smart Phone 說分手?淺談 BLE 開發模式 • 從 BLE 開發模式切入,探討進入物聯網需跨越的門檻 • 開發模式 ▪ 純嵌入式 ▪ 手機 App ▪ BLE Gateway 應用 13

Slide 14

Slide 14 text

Develop with Embedded SoCs • 適用於周邊節點開發 • 點對點應用 (如 gecko switch) • 開發工具 ▪ IC vendor 提供 SDK 與 HDK 開發板 TI CC2540 Development Kit Bluetooth Smart Starter Development Kit 14 圖片來源: 1, 2, 3, 4 一對一控制

Slide 15

Slide 15 text

Develop with Smart Phones/Pads • 適用於個人型網路應用 ▪ 智慧手環、手錶、運動配件 ▪ 智慧插座、電燈 • 開發工具 ▪ 手機作業系統提供與底層藍芽晶片溝通的 Library 或 APIs ▪ Android - Bluetooth network stack ▪ iOS - Bluetooth for Developers 15 圖片來源: 1, 2, 3

Slide 16

Slide 16 text

• 適用於小型區域網路 ▪ 智慧家庭 ▪ 工廠自動化 • 開發工具 ▪ TI - Bluetooth Smart-to-Wi-Fi Gateway solution ▪ RedBear Duo - A small and powerful Wi-Fi+BLEIoT board Develop with Gateways 16 圖片來源: 1, 2

Slide 17

Slide 17 text

Compatibility 17 ? 圖片來源: 1, 2, 3

Slide 18

Slide 18 text

SIG’s Positive Response 18 “We heard the demand for gateway functionality, not just from our members, but from consumers, who want a connected home but are not satisfied with current capabilities.” - Steve Hegenderfer Director Developer programs, Bluetooth SIG

Slide 19

Slide 19 text

Bluetooth Secure Gateway • SIG 今年 2 月初發布了 BLE Gateway 解決方案 19 圖片來源: 1 Node.js 15 RESTful APIs

Slide 20

Slide 20 text

Node.js • 為 Real-time Web 應用開發而生的平台 • 非同步 I/O、事件驅動模型 ▪ 單執行緒 (userland) ▪ 非同步、非阻塞 I/O、以事件迴圈為基礎 (libuv) • Node.js 有強大靈活的套件管理員 ▪ node package manager, npm ▪ 目前已經有上萬個協力廠商模組 20

Slide 21

Slide 21 text

Node.js Web Frameworks • 前/後端皆使用 JavaScript ▪ Google V8 Engine (Client: Chrome, Server: Node.js) • 框架 – 在別人搭好的舞台上表演 ▪ 框架為開發者定義好整體架構並實作部分功能,減輕開發 者的負擔,加快開發流程 • Back-end Web Frameworks ▪ 建立大規模、real-time、可擴展 Web 應用程式 (webapps) 21

Slide 22

Slide 22 text

Web Front-end Frameworks • Web Application (網路版應用程式) • Front-end Web Frameworks / CSS / DOM / Tools ▪ 因前端技術繁多,以下只是列出其中一部分 22

Slide 23

Slide 23 text

We are Family • 仍有困難需克服 ▪ 手機開發不利於物聯網應用 ▪ 進入 BLE Gateway 開發有門檻 ▪ 傳統 BLE Gateway 無法實作應用 ▪ BLE 裝置間沒有相容性 23 是 BLE 刷存在感的時候了 BLE 裝置要能上網! 也可以漫步在雲端! 黏踢踢的手機也需要被解放!

Slide 24

Slide 24 text

BLE Shepherd Can Help • BLE 開發應用框架 • 它是驅動程式 (HCI Host) • 它是 BLE 應用程式環境,也是 BLE 網路管理器 • 可以接上 http 伺服器,很容易跟其他前端框架整合 • 也可以讓 BLE 裝置們通通上雲端 • 你能設計 RESTful 介面,從網外存取網內 BLE 裝置 24 https://github.com/bluetoother/ble-shepherd

Slide 25

Slide 25 text

No Smart Phone? Kidding Me? 25 那用什麼開發? JavaScript & HTML5 + BLE Shepherd 真的!不蓋你! 而且,複雜的底層封包處理,它全包辦了! 還免費贈送 BLE 網管功能!

Slide 26

Slide 26 text

26 BLE Shepherd 有很重要的使命 成為將 BLE 內嵌於多協定物聯網閘道器的先驅 解放阿公、阿嬤健康照護周邊小玩意兒!

Slide 27

Slide 27 text

BLE Shepherd (BShep) • BLE central device 之擴充 • 基於 Node.js • 無痛建立 BLE 機器網路 27 BShep BLE App TI CC254X BLE Network Processor BLE4.0 USB Adapter cc-bnp noble Hardware & PHY HCI Controller Driver @Node.js HCI Host Network Control and Management Layer Application Layer

Slide 28

Slide 28 text

Bluetooth Machine Network 28 Read / Write BLE Peripheral Bluetooth device User Cloud Ind / Notif App server BLE Gateway ble-shepherd Manage Control Local area Monitor BLE Central 小型/區域網路 系統化 智慧物件模型 管理介面

Slide 29

Slide 29 text

BLE Shepherd Provides… 29 自動掃描周邊裝置 自動發起連線 自由組態連線參數 裝置連線狀態通知 協助管理網路裝置 內建輕量型資料庫 自動儲存裝置資訊 輕鬆操作連線裝置 它的心願就是 幫助開發者專注於應用的業務邏輯!

Slide 30

Slide 30 text

SIG Gateway v.s. BLE Shepherd 30 BLE Secure Gateway ble-shepherd Security RESTful APIs GATT GAP noble HTTP Server peripheral central Web Application Security Management APIs peripheral Application Server (BLE Apps) GATT BIPSO GAP central cc-bnp noble Web Application

Slide 31

Slide 31 text

GATT Table on BLE Device • 如何規劃 GATT Table ▪ SIG-defined GATT Services ▪ SIG-defined GATT Characteristics ▪ User-defined Services & Characteristics • Mix Them Up ▪ 組成描述裝置所需的資料體 31 但是,這樣的彈性卻是一把雙面刃! 各家廠商定義自己的私有規範 裝置之間沒有任何相容性

Slide 32

Slide 32 text

IPSO – IP-based Smart Object • IPSO Alliance & IPSO Model ▪ 對真實世界的物件資料模型進行標準化 ▪ 已定義 51 種 Smart Objects,增加中 ▪ 採用階層化資料模型 (Object, Object Instance, Resource) 32

Slide 33

Slide 33 text

Unified Data Model for BLE • BLE 的資料模型混亂 ▪ SIG 定義的 Characteristic 不易套用至實際 IoT 裝置 ▪ 自由度高,廠商大多自訂且彼此不能相容,僅能自家使用 • BIPSO 借鏡 IPSO 模型,試圖解決相容性問題 ▪ 定義 Characteristics-SmartObject 映射,共 51 種 ▪ 曾與 IPSO 聯盟與 OCF 進行討論,BIPSO 是國際標準 組織的資料模型制定參考之一 33 BLE Shepherd 原生支援!無縫接軌!

Slide 34

Slide 34 text

IPSO Official Website 34

Slide 35

Slide 35 text

Quick Demo 35 BShep Node.js JavaScript HTTP Websocket React.js

Slide 36

Slide 36 text

Open Source IoT Gateways 36 In its early stage

Slide 37

Slide 37 text

Thank You! Hedy Wang [email protected]