java.lang.Object
pt.unl.fct.di.tardis.babel.iot.controlprotocols.utils.I2CScanner

public class I2CScanner extends Object
  • Method Details

    • getInstance

      public static I2CScanner getInstance()
      Gets the singleton instance of the I2C scanner.
      Returns:
      The singleton I2CScanner instance
    • scan

      public static Set<pt.unl.fct.di.tardis.babel.iot.api.DeviceType> 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

      public void detectDeviceActivity(Set<pt.unl.fct.di.tardis.babel.iot.api.DeviceType> inUse)
      Detects device activity based on a specified set of devices in use. Updates the internal list of connected devices.
      Parameters:
      inUse - A Set<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

      public Set<pt.unl.fct.di.tardis.babel.iot.api.DeviceType> 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

      public List<Integer> 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

      public Set<pt.unl.fct.di.tardis.babel.iot.api.DeviceType> getConnectedDevices(boolean refresh)
      Gets the list of currently connected devices.
      Parameters:
      refresh - If true, performs a new scan before returning the result
      Returns:
      A Set<DeviceType> of currently connected devices
    • getConnectedDeviceI2CAddresses

      public List<Integer> getConnectedDeviceI2CAddresses(boolean refresh)
      Gets the list of I2C addresses for connected devices.
      Parameters:
      refresh - If true, performs a new scan before returning the result
      Returns:
      A List<Integer> of I2C addresses for connected devices
    • getDeviceI2CAddress

      public static Integer getDeviceI2CAddress(pt.unl.fct.di.tardis.babel.iot.api.DeviceType type)
      Gets the I2C address for a specific device type.
      Parameters:
      type - The DeviceType to get the address for
      Returns:
      The I2C address as an Integer, or null if 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, or null if the address is not recognized
    • getDeviceI2CAddressHex

      public static String getDeviceI2CAddressHex(pt.unl.fct.di.tardis.babel.iot.api.DeviceType type)
      Gets the hexadecimal representation of a device's I2C address.
      Parameters:
      type - The DeviceType to get the hexadecimal address for
      Returns:
      The I2C address as a hexadecimal String, or null if the device type is not supported