Cylon.js 1.2.0 - Logging and Timing and BLE! Oh my!
We've been really busy working on our JavaScript robotics & IoT framework, and version 1.2.0 of Cylon.js is hot off the presses.
There are several important changes to the Cylon.js core. There are also some significant changes to the cylon-ble
module that provides support for various Bluetooth LE devices.
And of course, a smattering of other changes to some of the other Cylon.js modules. Let's get into the details.
Cylon.js Core Changes
We have made a few important and useful changes to the Cylon.js core:
Improved Time Helpers
We've added a couple more convenience functions for our expressive time syntax. You can now define increments of time in anything ranging from minutes to milliseconds.
Here are a few examples combined with the every
, after
, & finish
functions:
after((500).milliseconds(), function() { console.log("500 milliseconds elapsed"); }); every((30).seconds(), function() { console.log("another 30 seconds"); }); var minutely = every((1).minute(), function() { console.log("another 1 minute"); }); after((10).minutes(), function() { finish(minutely); console.log("10 minutes elapsed"); });
Dynamic Connections And Devices
You no longer need to define all of your connections and devices upfront. Now you can dynamically add connections and devices, and start them up, after your Cylon.js robot is already running. Here is an example using a dynamic device:
var Cylon = require("cylon"); Cylon.robot({ connections: { loopback: { adaptor: "loopback" } }, connectPinger: function() { this.device("pinger", {connection: "loopback", driver: "ping"}); this.startDevice(this.devices.pinger, function() { console.log("Get ready to ping..."); }); }, work: function(my) { my.connectPinger(); every((1).second(), function() { console.log(my.pinger.ping()); }); } }).start();
This is an extremely simple example, but shows the idea. You could use external configuration files to determine which devices the user has installed, do connection discovery to decide which to use, and so many more possibilities.
Simplified Logging
We've replaced the built-in logger with a much simpler one. It still has the important options, but removes everything else. The Cylon.js logger is also pluggable, so it is very easy to replace it with your own logging capabilities should you so choose. This should not really impact developers unless they are implementing adaptor or driver modules.
cylon-ble Enhanced Features
Compatible With Noble 1.1.x
We've updated cylon-ble
to work with the latest version of noble
. Thanks to the hard work of @sandeepmistry and other contributors to noble
, cylon-ble can now run on Linux, OSX and Windows 8.1+ too!
Multiple Connections
The latest release of cylon-ble
now fully supports connections to multiple BLE peripherals at the same time. This makes it really easy to write code that coordinates activity between multiple, different kinds of Bluetooth LE devices.
Direct BLE Characteristic Driver
A new driver has been added to the cylon-ble
module called characteristic
. This is a suitably ubiquitous name, for what is a very useful driver.
The characteristic
driver provides a simple generic interface to a single BLE service/characteristic. It is to BLE development in Cylon.js what the direct-pin
driver is to GPIO development: a way to quickly connect to something, or to do exploratory development to figure out how a BLE device works.
Example usage:
var Cylon = require("cylon"); Cylon.robot({ connections: { bluetooth: { adaptor: "central", uuid: "207377654321", module: "cylon-ble" } }, devices: { wiced: { driver: "ble-characteristic", serviceId: "180f", characteristicId: "2a19", connection: "bluetooth" } }, work: function(my) { my.wiced.readCharacteristic(function(err, data) { if (err) { return console.error("Error: ", err); } console.log("Data: ", data); }); } }).start();
This example connects and then reads the characteristic ID 2a19
for the service ID 180f
. This happens to be the "Battery" information, which is a well-known BLE service/characteristic.
BLE Searching + Dynamic Peripherals
The new cylon-ble
release also adds a new way to scan for BLE devices to connect to. You can combine this with the dynamic device feature. This makes it possible to search for devices at runtime, and then connect to whichever of them based on how you want your application to work.
Example usage:
var Cylon = require("cylon"); Cylon.robot({ connections: { bluetooth: { adaptor: "central", module: "cylon-ble" } }, connectBLE: function(peripheral) { if (this.connected) { return; } this.bluetooth.connectPeripheral(peripheral.uuid, peripheral, function() { console.log(peripheral.advertisement.localName, peripheral.uuid); this.connected = true; this.device("blething", {connection: "bluetooth", driver: "ble-device-information"}); this.startDevice(this.devices.blething, function() { this.devices.blething.getManufacturerName(function(err, data) { if (err) { console.log("error: ", err); return; } console.log("data: ", data); }); }.bind(this)); }.bind(this)); }, work: function(my) { this.connected = false; my.bluetooth.on("discover", function(peripheral) { my.connectBLE(peripheral); }); } }).start();
This example scans and then automatically connects to the first BLE peripheral it can find. Then it tries to obtain the manufacturer name via the device-information
service.
A Few More Tidbits
cylon-joystick
Support For Dualshock 4
We've added support for the new Dualshock 4, which is the new joystick from the Playstation 4. This coincidentally brings the total number of different supported joysticks to 4.
cylon-gpio
Bugfixes
A couple small but important fixes to the continuous-servo
driver thanks to contributor Eric Terpstra.
cylon-mqtt
Update And Additional Options
We've updated the cylon-mqtt
adaptor to the latest mqtt.js
which is maintained by @matteocollina, well known as the JavaScript community's M2M guru. This picks up various speed enhancements and security fixes.
We also added some additional options for configuration. This allows support for authentication options for cloud-based MQTT providers such as IBM Bluemix.
Thank You, Users and Contributors
As always, we want to thank our users and contributors for their fine efforts that have led to this release. You could be the next human to join in!
For more updates, be sure to follow us on Twitter at @CylonJS.
Posts
- Cylon.js Off And Rolling In 2016
- Cylon.js 1.2.0 - Logging and Timing and BLE! Oh my!
- Cylon.js 1.1.0 - The Big Cleanup
- Hello, Node Bebop Drone
- Cylon.js featured in Wired
- Cylon.js 1.0.0 is here!
- Using Socket.io With The Cylon.js API
- Cylon 0.22.0 - A New Year's Release
- Cylon 0.21.0 is out!
- Creating Multiplatform Precompiled Binaries for Node.js Modules
- Cylon 0.20.0 is out!
- Running Robots From Your Browser With Cylon.js
- Winning the Dreamforce 500 With Cylon.js
- With The New Cylon.js 0.19.0, You Can Be Fluent Too
- Cylon.js on Intel Edison
- Cylon Takes Off on NodeBots Day
- Cylon.js Fun With The Arduino Yun
- Control Robots From Your Pebble
- Making Moves With Intel Galileo
- The Cylon Nest
- Announcing Full Tessel Support!
- Cylon 0.15.0 is Out!
- Cylon.js in Make Magazine!
- Cylon.js At JSConf 2014
- Cylon.js Takes The Stage At MakerFaire
- Cylon.js In Scotland
- Robots Are The New Normal At NextBerlin
- Thingscon - Ich Bin Ein Cylon
- National Robotics Week at the Robotics Society of Southern California
- Functional Robots With Wisp
- Release 0.12 Is For RobotOps
- Making Waves At Makerland
- This One Goes To 0.11 Of Pure JavaScript
- Tipping SCaLE12X
- Intro Robeaux- A Universal User Interface To Robotic Devices
- ng-robots! A Fun Robot Hackathon At The First ng-conf
- Number 9! The Release In Which We Add A Web UX, More Platforms, and Tools
- Release 0.8.0 Makes 10 Platforms
- RobotsConf Was Remarkable
- Dreamforce Means Connected Devices Are A Thing
- Dreamforce Is Coming!
- Welcome, Cylon.js