目前已知实验成功的树莓派版本为:树莓派2和3
由于我是用Word排版的,直接复制粘贴,因此部分命令可能缺少空格,请注意!
This tutorial only works with Jessie
(此教程只适用于Jessie版本!)
STEP 1
如何安装HAP_Nodejs
(不要安装在/root文件夹下面)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get remove nodejs-legacy
sudo apt-get install python-dev python-pip
sudo apt-get install libavahi-compat-libdnssd-dev
sudo wget http://node-arm.herokuapp.com/node_latest_armhf.deb
dpkg -i node_latest_armhf.deb
node -v
npm -v
git clone https://github.com/KhaosT/HAP-NodeJS.git
cd HAP-NodeJS
sudo npm install -g node-gyp
sudo npm install node-persist
sudo npm install srp
sudo npm install mdns
sudo npm install ed25519
sudo npm install curve25519-n
sudo npm install debug
sudo npm install python-shell
cd accessories
sudo nano deskLamp_accessory.js
copy this into:
(把下面的代码复制进去)
var PythonShell = require('python-shell');
// HomeKit types required
var types = require("./types.js")
var exports = module.exports ={};
var execute = function(accessory,characteristic,value){ console.log("executed accessory:" + accessory + ", and characteristic: " + characteristic +", with value: " + value +"."); }
exports.accessory = {
displayName: "desk Lamp",
username: "1A:2B:3C:4D:1E:FF", #mac addressneeds to be unique
pincode: "031-45-154",
services: [{
sType: types.ACCESSORY_INFORMATION_STYPE,
characteristics: [{
cType:types.NAME_CTYPE,
onUpdate:null,
perms:["pr"],
format: "string",
initialValue: "desk Lamp", #initialValue needs to besame as displayName
supportEvents: false,
supportBonj