-
Notifications
You must be signed in to change notification settings - Fork 0
/
base64_encoder.js
30 lines (21 loc) · 909 Bytes
/
base64_encoder.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
/* README:
This utility converts a string into a base64 string.
This might be needed because homebridge 0.2.11 crashes when certain Control
Characters (which are often required in RS232 commands) are entered in config.json
See https://github.com/nfarina/homebridge/issues/441
To use this, put your string in the "command" var.
Then run `node base64_converter.js`
the base64 encoded version of your command will be outputted to your shell window
Copy this encoded string and put it in your config.json file
Make sure to set `base64 = true` for the command in config.json
*/
var command = 'PASTE YOUR COMMAND HERE'; // e.g. '\x02PON\x03' -> STXPONETX
// No need to edit below this line
var net = require('net');
var Entities = require('html-entities').AllHtmlEntities;
entities = new Entities();
console.log("\n\n");
console.log(
new Buffer(command).toString('base64')
);
console.log("\n\n");