ioBroker / ioBroker.discovery

This adapter tries to discover all known devices
MIT License
28 stars 48 forks source link

Support for rpi2 adapter #19

Open UncleSamSwiss opened 7 years ago

UncleSamSwiss commented 7 years ago

It would be very nice if I run the discovery on a Raspberry Pi, the list of suggested adapters would also show rpi2.

Apollon77 commented 6 years ago

How to detect a raspi?

UncleSamSwiss commented 5 years ago

My suggestions would be:

  1. Read /sys/firmware/devicetree/base/model: https://raspberrypi.stackexchange.com/questions/5100/detect-that-a-python-program-is-running-on-the-pi or
  2. grep Hardware /proc/cpuinfo: https://www.raspberrypi.org/forums/viewtopic.php?t=54413

Side note: if the detection is too narrow (i.e. it doesn't detect if the device is a RasPi), that's not too much of an issue IMHO. The other way around it would be worse (we shouldn't detect a RasPi if it isn't one).

GermanBluefox commented 5 years ago
if (require('fs').existsSync('/proc/cpuinfo')) {
    const lines = require('fs').readFileSync('/proc/cpuinfo').toString().split(/\n|\r/);
    const isRaspi = lines.find(line => line.indexOf('Hardware') !== -1 && line.indexOf('BCM2708') !== -1);
    console.log(`IS Raspi: ${!!isRaspi}`);
} else {
    console.log(`IS Raspi: ${false}`);
}