}
public MagentaTVControl(MagentaTVDynamicConfig config, MagentaTVNetwork network, HttpClient httpClient) {
- thingId = config.getFriendlyName();
+ this.thingId = config.getFriendlyName();
this.network = network;
this.oauth = new MagentaTVOAuth(httpClient);
this.config = config;
return initialized;
}
+ public void setThingId(String thingId) {
+ this.thingId = thingId;
+ }
+
/**
* Returns the thingConfig - the Control class adds various attributes of the
* discovered device (like the MR model)
private void initializeThing() {
String errorMessage = "";
try {
+ config.setFriendlyName(getThing().getLabel().toString());
if (config.getUDN().isEmpty()) {
// get UDN from device name
String uid = this.getThing().getUID().getAsString();
protected void connectReceiver() throws MagentaTVException {
if (control.checkDev()) {
updateThingProperties();
+ control.setThingId(config.getFriendlyName());
manager.registerDevice(config.getUDN(), config.getTerminalID(), config.getIpAddress(), this);
control.subscribeEventChannel();
control.sendPairingRequest();
protected final MulticastSocket socket;
protected @Nullable NetworkInterface networkInterface;
protected byte[] buf = new byte[256];
+ private boolean started = false;
public MagentaTVPoweroffListener(MagentaTVHandlerFactory handlerFactory,
@Nullable NetworkInterface networkInterface) throws IOException {
public void start() {
if (!isStarted()) {
logger.debug("Listening to SSDP shutdown messages");
+ started = true;
super.start();
}
}
}
public boolean isStarted() {
- return socket.isBound();
+ return started;
}
/**
* Make sure the socket gets closed
*/
public void close() {
- if (isStarted()) {
+ if (started) { // if (isStarted()) {
logger.debug("No longer listening to SSDP messages");
if (!socket.isClosed()) {
socket.close();
}
+ started = false;
}
}