Skip to Content
Node.js物聯網裝置開發
book

Node.js物聯網裝置開發

by Patrick Mulder, Kelsey Breseman
August 2017
Intermediate to advanced
272 pages
5h 32m
Chinese
GoTop Information, Inc.
Content preview from Node.js物聯網裝置開發
150
|
第九章 網路協定
client.on('message', function() {
console.log('push');
});
});
WebSocket 也可用於嵌入式裝置與網頁瀏覽器之間的傳輸溝通,非常便利。關於與瀏覽
器的連線,將於下一章介紹。
WebSocket 之上進行遠端程序呼叫
基於 WebSocket 協定,你可建構出用於 RPC
Remote Procedure Call
遠端程序呼叫
的媒介,靠著 RPC,我們就能執行來自於其他裝置的物件的方法,請看圖 9-6,說明這
是多麼有用的一項功能。
客戶端
dnode 進行 RPC
伺服器
輸入
輸出
9-6  若有 RPC 的話,你就能執行來自遠端伺服器的函式,該伺服器連接著各種輸出裝置
LED、顯示器)和輸入裝置(感測器)
首先,開發板先連接好 LED,非常簡單,此時並沒有 RPC,你只能控制腳本程式範圍內
的物件。初始設置大致如下所示:
// led_control.js
var port = 4000;
// set up board
var five = require('johnny-five');
// 選擇板子轉接器
// var Edison = require('edison-io');
// var Galileo = require('galileo-io');
// var BeagleBone = require('beaglebone-io');
var board = new five.Board({ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

金融人工智能:用Python实现AI量化交易

金融人工智能:用Python实现AI量化交易

Yves Hilpisch
快学熟用D3

快学熟用D3

Philipp K. Janert

Publisher Resources

ISBN: 9789864764594