Class MagicFirmwareUpdateThingHandler

  • All Implemented Interfaces:
    FirmwareUpdateHandler, ThingHandler

    @NonNullByDefault
    public class MagicFirmwareUpdateThingHandler
    extends BaseThingHandler
    implements FirmwareUpdateHandler
    Handler for firmware updatable magic things. Defines full progress sequence and simulates firmware update with small delays between the steps.
    Author:
    Dimitar Ivanov - Initial contribution
    • Constructor Detail

      • MagicFirmwareUpdateThingHandler

        public MagicFirmwareUpdateThingHandler​(Thing thing)
    • Method Detail

      • handleCommand

        public void handleCommand​(ChannelUID channelUID,
                                  Command command)
        Description copied from interface: ThingHandler
        Handles a command for a given channel.

        This method is only called, if the thing has been initialized (status ONLINE/OFFLINE/UNKNOWN).

        Specified by:
        handleCommand in interface ThingHandler
        Parameters:
        channelUID - the ChannelUID of the channel to which the command was sent
        command - the Command
      • initialize

        public void initialize()
        Description copied from interface: ThingHandler
        Initializes the thing handler, e.g. update thing status, allocate resources, transfer configuration.

        This method is only called, if the Thing contains all required configuration parameters.

        Only Things with status ThingStatus.UNKNOWN, ThingStatus.ONLINE or ThingStatus.OFFLINE are considered as initialized by the framework. To achieve that, the status must be reported via ThingHandlerCallback.statusUpdated(Thing, ThingStatusInfo).

        The framework expects this method to be non-blocking and return quickly. For longer running initializations, the implementation has to take care of scheduling a separate job which must guarantee to set the thing status eventually.

        Any anticipated error situations should be handled gracefully and need to result in ThingStatus.OFFLINE with the corresponding status detail (e.g. *COMMUNICATION_ERROR* or *CONFIGURATION_ERROR* including a meaningful description) instead of throwing exceptions.

        Specified by:
        initialize in interface ThingHandler
        Overrides:
        initialize in class BaseThingHandler
      • updateFirmware

        public void updateFirmware​(Firmware firmware,
                                   ProgressCallback progressCallback)
        Description copied from interface: FirmwareUpdateHandler
        Updates the firmware for the physical device of the thing that is handled by this firmware update handler.
        Specified by:
        updateFirmware in interface FirmwareUpdateHandler
        Parameters:
        firmware - the new firmware to be updated (not null)
        progressCallback - the progress callback to send progress information of the firmware update process (not null)
      • isUpdateExecutable

        public boolean isUpdateExecutable()
        Description copied from interface: FirmwareUpdateHandler
        Returns true, if this firmware update handler is in a state in which the firmware update can be executed, otherwise false (e.g. the thing is ThingStatus.OFFLINE or its status detail is already {@link ThingStatusDetail#FIRMWARE_UPDATING.)
        Specified by:
        isUpdateExecutable in interface FirmwareUpdateHandler
        Returns:
        true, if this firmware update handler is in a state in which the firmware update can be executed, otherwise false