homebridge-lib 5.1.18 → 5.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/SystemInfo.js +10 -32
  2. package/package.json +1 -1
package/lib/SystemInfo.js CHANGED
@@ -113,25 +113,16 @@ class SystemInfo extends events.EventEmitter {
113
113
  */
114
114
  static parseRpiCpuInfo (cpuInfo) {
115
115
  const id = /Serial\s*: ([0-9a-f]{16})/.exec(cpuInfo)[1].toUpperCase()
116
- const revision = parseInt(/Revision\s*: ([0-9a-f]{4,})/.exec(cpuInfo)[1], 16)
117
- const rpi = SystemInfo.parseRpiRevision(revision & 0x00FFFFFF)
118
- return Object.assign({ id: id }, rpi)
119
- }
120
-
121
- /** Parse the revision of a Raspberry Pi.
122
- *
123
- * @see https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-revision-codes
124
- * @param {int} revision - The Raspberry Pi revision.
125
- * @return {object} - The parsed revision.
126
- */
127
- static parseRpiRevision (revision) {
116
+ const revision = parseInt(
117
+ /Revision\s*: ([0-9a-f]{4,})/.exec(cpuInfo)[1], 16
118
+ ) & 0x00FFFFFF
128
119
  let gpioMask, manufacturer, memory, model, modelRevision, processor
129
120
  if ((revision & 0x00800000) !== 0) { // New revision scheme.
130
- manufacturer = rpiInfo.manufacturers[(revision & 0x000f0000) >> 16]
121
+ manufacturer = rpiInfo.manufacturers[(revision & 0x000F0000) >> 16]
131
122
  memory = rpiInfo.memorySizes[(revision & 0x00700000) >> 20]
132
- model = rpiInfo.models[(revision & 0x00000ff0) >> 4]
133
- modelRevision = '1.' + ((revision & 0x0000000f) >> 0).toString()
134
- processor = rpiInfo.processors[(revision & 0x0000f000) >> 12]
123
+ model = rpiInfo.models[(revision & 0x00000FF0) >> 4]
124
+ modelRevision = '1.' + ((revision & 0x0000000F) >> 0).toString()
125
+ processor = rpiInfo.processors[(revision & 0x0000F000) >> 12]
135
126
  } else if (rpiInfo.oldRevisions[revision] != null) { // Old incremental revisions.
136
127
  manufacturer = rpiInfo.oldRevisions[revision].manufacturer
137
128
  memory = rpiInfo.oldRevisions[revision].memory
@@ -155,6 +146,8 @@ class SystemInfo extends events.EventEmitter {
155
146
  return {
156
147
  gpioMask: gpioMask,
157
148
  gpioMaskSerial: (1 << 15) | (1 << 14),
149
+ id: id,
150
+ isRpi: true,
158
151
  manufacturer: manufacturer,
159
152
  memory: memory,
160
153
  model: model,
@@ -216,22 +209,7 @@ class SystemInfo extends events.EventEmitter {
216
209
  */
217
210
  async getRpiInfo () {
218
211
  const cpuInfo = await this.readTextFile('/proc/cpuinfo')
219
- const rpi = SystemInfo.parseRpiCpuInfo(cpuInfo)
220
- return {
221
- gpioMask: rpi.gpioMask,
222
- gpioMaskSerial: rpi.gpioMaskSerial,
223
- id: rpi.id,
224
- isRpi: true,
225
- manufacturer: rpi.manufacturer,
226
- memory: rpi.memory,
227
- model: rpi.model,
228
- modelRevision: rpi.modelRevision,
229
- nCores: os.cpus().length,
230
- powerLed: rpi.powerLed,
231
- prettyName: rpi.prettyName,
232
- processor: rpi.processor,
233
- revision: rpi.revision
234
- }
212
+ return SystemInfo.parseRpiCpuInfo(cpuInfo)
235
213
  }
236
214
 
237
215
  /** Extract OS info from /etc/os-release.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Library for homebridge plugins",
4
4
  "author": "Erik Baauw",
5
5
  "license": "Apache-2.0",
6
- "version": "5.1.18",
6
+ "version": "5.1.19",
7
7
  "keywords": [
8
8
  "homekit",
9
9
  "homebridge"