View Javadoc
1   package example.binarylight;
2   
3   import org.fourthline.cling.binding.annotations.*;
4   
5   @UpnpService(
6           serviceId = @UpnpServiceId("SwitchPower"),
7           serviceType = @UpnpServiceType(value = "SwitchPower", version = 1)
8   )
9   public class SwitchPower {
10  
11      @UpnpStateVariable(defaultValue = "0", sendEvents = false)
12      private boolean target = false;
13  
14      @UpnpStateVariable(defaultValue = "0")
15      private boolean status = false;
16  
17      @UpnpAction
18      public void setTarget(@UpnpInputArgument(name = "NewTargetValue")
19                            boolean newTargetValue) {
20          target = newTargetValue;
21          status = newTargetValue;
22          System.out.println("Switch is: " + status);
23      }
24  
25      @UpnpAction(out = @UpnpOutputArgument(name = "RetTargetValue"))
26      public boolean getTarget() {
27          return target;
28      }
29  
30      @UpnpAction(out = @UpnpOutputArgument(name = "ResultStatus"))
31      public boolean getStatus() {
32          // If you want to pass extra UPnP information on error:
33          // throw new ActionException(ErrorCode.ACTION_NOT_AUTHORIZED);
34          return status;
35      }
36  
37  }