Skip to content

Commit

Permalink
platform: Refactor ADC module as class (WebThingsIO#104)
Browse files Browse the repository at this point in the history
There was a bug when using multiple instances.
It was tested on ARTIK1020

Relate-to: WebThingsIO#46
Forwarded: WebThingsIO#104
Change-Id: Idbb9d0f53fc1534407657c9b63a29db50297ae88
Signed-off-by: Philippe Coval <p.coval@samsung.com>
  • Loading branch information
rzr authored and mrstegeman committed Jul 4, 2019
1 parent 697f67d commit 85581e5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions example/platform/adc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@

const fs = require('fs');

function Adc() {
this.open = function(config, callback) {
class Adc {
constructor(config, callback) {
this.config = config;
fs.access(config.device, fs.R_OK, callback);
return this;
};
}

this.readSync = function() {
readSync() {
const contents = fs.readFileSync(this.config.device, 'ascii');
return contents;
};
}

closeSync() {
}

this.closeSync = function() {
};
}

module.exports = new Adc();

module.exports.open = function(config, callback) {
return new Adc(config, callback);
};

0 comments on commit 85581e5

Please sign in to comment.