Package de.justofplay.xled
Class Device
java.lang.Object
de.justofplay.xled.Device
Represents a Twinkly device and provides methods to interact with it via the Twinkly API.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGets the current brightness value.intGets bytes per led.getColor()Gets the current LED color as a raw HTTP response.Gets copyright.Gets device information (gestalt) as a JSON string.Gets device name.Gets the firmware version of the device.intGets flash size.intGets frame rate.Gets fw family.intGets hardware version.getHwId()Gets hw id.getIp()Gets ip.intGets the blue component of the current LED color.intGets the green component of the current LED color.Gets led profile.intGets the red component of the current LED color.intGets led type.getLogin()Gets login.getMac()Gets mac.intGets max movies.intGets max supported leds.floatGets measured frame rate.getMode()Gets the current operating mode of the LEDs.intGets movie capacity.Gets network config.Gets network scan results.intGets number of led.Gets product code.Gets product name.intGets the current saturation value.longGets uptime.getUuid()Gets uuid.intGets wire type.Init network scan string.login()Performs login to the device and returns the raw HTTP response.logout()Logs out from the device.Play movie string.setBrightness(int brightness) Sets the brightness of the LEDs.setColor(int red, int green, int blue) Sets the LED color using RGB values.setColorHSV(int hue, int saturation, int value) Sets the LED color using HSV color space.setCurrentMovie(int movieId) Sets the current movie by its ID.setDeviceName(String deviceName) Sets device name.voidSets the device IP address.Sets the operating mode of the LEDs.setSaturation(int saturation) Sets the saturation of the LEDs.verify()Verifies the authentication token with the device.
-
Constructor Details
-
Device
Constructs a Device object and initializes device info by logging in and querying the device.- Parameters:
ip- The IP address of the Twinkly device.
-
-
Method Details
-
getProductName
Gets product name.- Returns:
- The product name of the device.
-
getHardwareVersion
public int getHardwareVersion()Gets hardware version.- Returns:
- The hardware version.
-
getBytesPerLed
public int getBytesPerLed()Gets bytes per led.- Returns:
- The number of bytes per LED.
-
getHwId
Gets hw id.- Returns:
- The hardware ID.
-
getFlashSize
public int getFlashSize()Gets flash size.- Returns:
- The flash size.
-
getLedType
public int getLedType()Gets led type.- Returns:
- The LED type.
-
getProductCode
Gets product code.- Returns:
- The product code.
-
getFwFamily
Gets fw family.- Returns:
- The firmware family.
-
getDeviceName
Gets device name.- Returns:
- The device name.
-
getUptime
public long getUptime()Gets uptime.- Returns:
- The uptime in seconds.
-
getMac
Gets mac.- Returns:
- The MAC address.
-
getUuid
Gets uuid.- Returns:
- The UUID.
-
getMaxSupportedLeds
public int getMaxSupportedLeds()Gets max supported leds.- Returns:
- The maximum supported number of LEDs.
-
getNumberOfLed
public int getNumberOfLed()Gets number of led.- Returns:
- The number of LEDs.
-
getLedProfile
Gets led profile.- Returns:
- The LED profile.
-
getFrameRate
public int getFrameRate()Gets frame rate.- Returns:
- The frame rate.
-
getMeasuredFrameRate
public float getMeasuredFrameRate()Gets measured frame rate.- Returns:
- The measured frame rate.
-
getMovieCapacity
public int getMovieCapacity()Gets movie capacity.- Returns:
- The movie capacity.
-
getMaxMovies
public int getMaxMovies()Gets max movies.- Returns:
- The maximum number of movies.
-
getWireType
public int getWireType()Gets wire type.- Returns:
- The wire type.
-
getCopyright
Gets copyright.- Returns:
- The copyright string.
-
getLogin
Gets login.- Returns:
- The Login object containing authentication info.
-
getIp
Gets ip.- Returns:
- The device IP address.
-
setIp
Sets the device IP address.- Parameters:
ip- The new IP address.
-
login
Performs login to the device and returns the raw HTTP response.- Returns:
- The HTTP response as a string.
-
setDeviceName
Sets device name.- Parameters:
deviceName- the device name- Returns:
- the device name
-
getDeviceInfo
Gets device information (gestalt) as a JSON string.- Returns:
- The JSON body as a string.
-
getFirmwareVersion
Gets the firmware version of the device.- Returns:
- The firmware version as a string.
-
logout
Logs out from the device.- Returns:
- The HTTP response as a string.
-
setBrightness
Sets the brightness of the LEDs.- Parameters:
brightness- Brightness value (0..100)- Returns:
- The HTTP response as a string.
-
getBrightness
public int getBrightness()Gets the current brightness value.- Returns:
- The brightness value (0..100)
-
setColor
Sets the LED color using RGB values.- Parameters:
red- Red component (0..255)green- Green component (0..255)blue- Blue component (0..255)- Returns:
- The HTTP response as a string.
-
setColorHSV
Sets the LED color using HSV color space.- Parameters:
hue- Hue component (0..359)saturation- Saturation component (0..255)value- Value/Brightness component (0..255)- Returns:
- HTTP response as String
-
getColor
Gets the current LED color as a raw HTTP response.- Returns:
- The HTTP response as a string.
-
getLedRed
public int getLedRed()Gets the red component of the current LED color.- Returns:
- The red value (0..255)
-
getLedGreen
public int getLedGreen()Gets the green component of the current LED color.- Returns:
- The green value (0..255)
-
getLedBlue
public int getLedBlue()Gets the blue component of the current LED color.- Returns:
- The blue value (0..255)
-
setSaturation
Sets the saturation of the LEDs.- Parameters:
saturation- Saturation value (0..255)- Returns:
- The HTTP response as a string.
-
getSaturation
public int getSaturation()Gets the current saturation value.- Returns:
- The saturation valuec (0..255)
-
setMode
Sets the operating mode of the LEDs.- Parameters:
mode- The mode string (e.g., "movie", "color", etc.)- Returns:
- The HTTP response as a string.
-
getMode
Gets the current operating mode of the LEDs.- Returns:
- The mode string.
-
setCurrentMovie
Sets the current movie by its ID.- Parameters:
movieId- The movie ID.- Returns:
- The HTTP response as a string.
-
verify
Verifies the authentication token with the device.- Returns:
- The HTTP response as a string.
-
playMovie
Play movie string.- Parameters:
movie- the movie- Returns:
- the string
-
getNetworkConfig
Gets network config.- Returns:
- the network config
-
initNetworkScan
Init network scan string.- Returns:
- the string
-
getNetworkScanResults
Gets network scan results.- Returns:
- the network scan results
-