Class I2CScanner
java.lang.Object
pt.unl.fct.di.tardis.babel.iot.controlprotocols.utils.I2CScanner
-
Method Summary
Modifier and TypeMethodDescriptionvoidDetects device activity by scanning the I2C bus.voiddetectDeviceActivity(Set<pt.unl.fct.di.tardis.babel.iot.api.DeviceType> inUse) Detects device activity based on a specified set of devices in use.Gets the list of I2C addresses for connected devices.getConnectedDeviceI2CAddresses(boolean refresh) Gets the list of I2C addresses for connected devices.Set<pt.unl.fct.di.tardis.babel.iot.api.DeviceType> Gets the list of currently connected devices.Set<pt.unl.fct.di.tardis.babel.iot.api.DeviceType> getConnectedDevices(boolean refresh) Gets the list of currently connected devices.static IntegergetDeviceI2CAddress(pt.unl.fct.di.tardis.babel.iot.api.DeviceType type) Gets the I2C address for a specific device type.static StringgetDeviceI2CAddressHex(pt.unl.fct.di.tardis.babel.iot.api.DeviceType type) Gets the hexadecimal representation of a device's I2C address.static pt.unl.fct.di.tardis.babel.iot.api.DeviceTypegetI2CAddressDevice(int addr) Gets the device type associated with a specific I2C address.static I2CScannerGets the singleton instance of the I2C scanner.static Set<pt.unl.fct.di.tardis.babel.iot.api.DeviceType> scan()Performs a scan of the I2C bus to detect connected devices.
-
Method Details
-
getInstance
Gets the singleton instance of the I2C scanner.- Returns:
- The singleton
I2CScannerinstance
-
scan
Performs a scan of the I2C bus to detect connected devices. Updates the last scan timestamp.- Returns:
- A
Set<DeviceType>containing all detected I2C devices
-
detectDeviceActivity
Detects device activity based on a specified set of devices in use. Updates the internal list of connected devices.- Parameters:
inUse- ASet<DeviceType>of devices currently in use
-
detectDeviceActivity
public void detectDeviceActivity()Detects device activity by scanning the I2C bus. Updates the internal list of connected devices. -
getConnectedDevices
Gets the list of currently connected devices. May perform a new scan if the scan interval has elapsed.- Returns:
- A
Set<DeviceType>of currently connected devices
-
getConnectedDeviceI2CAddresses
Gets the list of I2C addresses for connected devices. May perform a new scan if the scan interval has elapsed.- Returns:
- A
List<Integer>of I2C addresses for connected devices
-
getConnectedDevices
Gets the list of currently connected devices.- Parameters:
refresh- Iftrue, performs a new scan before returning the result- Returns:
- A
Set<DeviceType>of currently connected devices
-
getConnectedDeviceI2CAddresses
Gets the list of I2C addresses for connected devices.- Parameters:
refresh- Iftrue, performs a new scan before returning the result- Returns:
- A
List<Integer>of I2C addresses for connected devices
-
getDeviceI2CAddress
Gets the I2C address for a specific device type.- Parameters:
type- TheDeviceTypeto get the address for- Returns:
- The I2C address as an
Integer, ornullif the device type is not supported
-
getI2CAddressDevice
public static pt.unl.fct.di.tardis.babel.iot.api.DeviceType getI2CAddressDevice(int addr) Gets the device type associated with a specific I2C address.- Parameters:
addr- The I2C address to look up- Returns:
- The corresponding
DeviceType, ornullif the address is not recognized
-
getDeviceI2CAddressHex
Gets the hexadecimal representation of a device's I2C address.- Parameters:
type- TheDeviceTypeto get the hexadecimal address for- Returns:
- The I2C address as a hexadecimal
String, ornullif the device type is not supported
-