Skip to content

Commit c69cdd8

Browse files
Update index.js
1 parent 04d35bf commit c69cdd8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module.exports = function(homebridge) {
1111

1212
function getSerial(){
1313
var fs = require('fs');
14-
var content = fs.readFileSync('/proc/cpuinfo', 'utf8').split("\n");
15-
var serial = content[content.length-2].split(":");
16-
return serial[1].slice(9);
14+
var cpuinfo = fs.readFileSync('/proc/cpuinfo', 'utf8');
15+
var match = cpuinfo.match(/Serial\s*:\s*([a-f0-9]+)/i);
16+
return match ? match[1] : null;
1717
}
1818

1919
function ElecticRimLockAccessory(log, config) {

0 commit comments

Comments
 (0)