Simple extraction out of Connection/Device initialization code inside
Robot.
This yields an interesting boon, however - this is now a valid Cylon
program:
var Cylon = require('cylon');
Cylon
.robot()
.connection({ name: 'loopback', adaptor: 'loopback' })
.device({ name: 'ping', driver: 'ping' })
.on('ready', function(bot) {
console.log("Bot working!");
every(1000, function() {
console.log(bot.ping.ping());
})
});
Cylon.start();
For those that prefer imperative programs with Cylon, this is a nice
syntax addition.
* dev:
Remove Adaptor#_noop function
Move Cylon API config to the Cylon.configure block
Fixup interval in driver
Add all new platforms to README
Add default interval in Driver class
Switch to single Cylon#config function
Conflicts:
test/specs/cylon.spec.js
* dev:
Remove `self` references in favor of #bind
Stop using #fetch here for now, it just breaks tests
Just use arguments directly instead of array
Remove Utils#bind in preference of built-in fn
Consolidate logstring generation into private fn
Experiment with Utils.fetch in Driver class
Add #fetch Utility function
Fix JSHint errors
Fix an edge case and improve tests for API
This change gives adaptors/drivers more flexibility in halting. Additionally,
now, by default, all Adaptors/Drivers will remove all their event listeners
before halting, which should prevent some additional commands from being sent to
the adaptor during shutdown.
Also removes the find{Robot,RobotConnection,RobotDevice} methods. Additionally,
stops passing the Master through to the Robot constructor, we can just
require('./cylon') if we need to access anything in there.
This commit reframes the Utils module to be more self-contained, and now only
the Number prototype methods and the every/after/constantly methods are exposed
globally.
I'm unsure about whether these methods can be more scoped such that people can
turn them off if they want, but that's potentially something to look into in the
future.
This commit also updates most of the other source files in Cylon, requiring the
Utils module rather than assuming the methods are in the global namespace.
A similar batch of commits will need to be made for all other Cylon modules to
make sure they don't explode when they can't find #subclass or something like
that.
To make the previously-global methods available, both in submodules and for
people looking for them, all the utility functions are exported in Cylon.Utils.
Acts exactly the same with much, much less code complexity.
This also introduces a pattern for providing core modules to external libraries.
Whereas previously Cylon modules were able to rely on Cylon.Adaptor or
Cylon.Driver being present in the namespace (due to being required in
./lib/cylon), they will now need to require Cylon first, like this:
var Cylon = require('cylon');
var Driver = Cylon.Driver,
Adaptor = Cylon.Adaptor,
DigitalPin = Cylon.IO.DigitalPin;
Expected configuration:
{
ssl: {
key: "/path/to/key",
cert: "/path/to/cert"
}
}
If ssl is false, use plain HTTP. If it's an empty object (the default)
use our self-signed certs. If it's set up like above, use the provided
certs.