-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathedison-ssid-characteristic.js
41 lines (35 loc) · 1.17 KB
/
edison-ssid-characteristic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Edion's current SSID name
*/
var util = require('util'),
os = require('os'),
exec = require('child_process').exec,
bleno = require('bleno'),
Descriptor = bleno.Descriptor,
Characteristic = bleno.Characteristic;
/**
* Reference:
* https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.manufacturer_name_string.xml
*/
var EdisonSSIDCharacteristic = function() {
EdisonSSIDCharacteristic.super_.call(this, {
uuid: '03f70ee0-0ef6-4c84-8d23-70af94b8a4f0',
properties: ['read'],
value: new Buffer('none','utf8'),
descriptors: [
new Descriptor({
uuid: '2901',
value: 'SSID'
})]
});
};
util.inherits(EdisonSSIDCharacteristic, Characteristic);
EdisonSSIDCharacteristic.prototype.onReadRequest = function(offset, callback) {
// Fetch free space in M
exec('wpa_cli status | grep -w ssid | tr -d \'ssid=\'', function (error, stdout, stderr) {
var data = stdout.toString().replace(/(\r\n|\n|\r)/gm,"");
console.log("SSID Name: " + data);
callback(this.RESULT_SUCCESS, new Buffer(data));
});
};
module.exports = EdisonSSIDCharacteristic;