-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c060cd
commit f1de9a0
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
var stream = require('stream') | ||
, util = require('util'); | ||
|
||
|
||
// Give our module a stream interface | ||
util.inherits(Device,stream); | ||
|
||
// Export it | ||
module.exports=Device; | ||
|
||
function Device(g) { | ||
|
||
var self = this; | ||
|
||
// This device will emit data | ||
this.readable = true; | ||
// This device can be actuated | ||
this.writeable = true; | ||
|
||
this.G = g; // G is a string a represents the channel | ||
this.V = 0; // 0 is Ninja Blocks' device list | ||
this.D = 9005; // 2000 is a generic Ninja Blocks sandbox device | ||
|
||
process.nextTick(this.init); | ||
}; | ||
|
||
Device.prototype.init = function() { | ||
|
||
}; | ||
|
||
/** | ||
* Called whenever there is data from the cloud | ||
* This is required if Device.writable = true | ||
* | ||
* @param {String} data The data received | ||
*/ | ||
Device.prototype.write = function(data) { | ||
|
||
// I'm being actuated with data! | ||
console.log(data); | ||
}; |