webduino-bluetooth-transport
v0.0.4
Published
Bluetooth Transport Plugin for webduino-js
Downloads
3
Readme
webduino-bluetooth-transport
Bluetooth Transport Plugin for webduino-js
Prerequisite
When running in browser, you must have the following installed:
- API Proxy for Google Chrome™ (launch before opening your application)
- API Proxy Agent for Google Chrome™
to interface with Webduino/Arduino via Bluetooth.
Installation
Browser
See also: webduino-js
The webduino-base.js or webduino-all.js has bundled serial and bluetooth transports by default. If you have successfully built it or use the CDN version, you are ready to go.
Cordova
Using bower:
$ bower install webduinoio/webduino-bluetooth-transport
In project directory:
$ cordova plugin add cordova-plugin-bluetooth-serial
Insert script after webduino-base.js (or webduino-all.js):
<script src="bower_components/webduino-js/dist/webduino-base.js"></script>
<script src="bower_components/webduino-bluetooth-transport/src/CordovaBluetoothTransport.js"></script>
<script src="bower_components/webduino-js/src/module/Led.js"></script>
... (modules used)
Node.js
$ npm install webduino-bluetooth-transport
Usage
webduino-js provides isomorphic APIs:
// need to acquire 'webduino' in Node.js:
// var webduino = require('webduino-js');
var board, led;
board = new webduino.Arduino({
transport: 'bluetooth',
address: 'xx:xx:xx:xx:xx:xx'
});
// Or:
// board = new webduino.Arduino({
// transport: require('webduino-bluetooth-transport'),
// address: 'xx:xx:xx:xx:xx:xx'
// });
board.on('ready', function() {
led = new webduino.module.Led(board, board.getDigitalPin(10));
led.on();
});