Bluetooth Transport Plugin for webduino-js
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.
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.
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)
$ npm install webduino-bluetooth-transport
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();
});