Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

[Denon] Send commands over telnet connection + several other improvements #5342

Merged
merged 8 commits into from
Dec 6, 2017

Conversation

idserda
Copy link
Contributor

@idserda idserda commented Oct 23, 2017

This PR has several improvements for the 1.x Denon binding. It fixes issues found in #5175

  • When connection method 'telnet' is used , commands to the receiver are now also send over the telnet connection. Before, http calls were used for this, but since not all receivers support http commands this change makes the binding support a lot more (older) receivers. Initial state is also queried over the telnet connnection. For this to work the binding had to stop using the Apache TelnetClient since the (not replaceable) TelnetOutputStream it uses adds a '\n' to every command send to the receiver, which practically 'hangs' the connection after the second command is send.
  • Configured instances without a hostname are ignored (fixes Connecting to null in the logs)
  • Some small tweaks to the starting and stopping of the binding to better support OH2.

Copy link
Contributor

@9037568 9037568 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good aside from the thread issue.

Please also address the compiler warnings and run the code through the Eclipse formatter.

*/
private void requestState() {
// Run in new thread to not delay the set up of the binding. Handling responses is done in the listener thread.
new Thread(new Runnable() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dev guidelines say creation of threads must be avoided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to fix this. Could you tell me where those existing schedulers are defined?

I have made a little change, the thread is now scheduled by an single threadExecutorService (which is defined in the DenonConnector) which is a bit more neat and guarantees that only 1 instance of the thread is being executed at a time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. There's not a lot of reference in the docs about how this should be done, but what you have looks like some of the other code I see in the repo.

@@ -22,7 +22,6 @@ Import-Package: javax.xml.bind,
org.apache.commons.io,
org.apache.commons.lang,
org.apache.commons.net,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eclipse complains that "No available bundle exports package 'org.apache.commons.net'"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the org.apache.commons.net.telnet import was removed the general .net import was no longer necessary so I've also removed it.

@9037568 9037568 added this to the 1.11.0 milestone Nov 22, 2017
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/denon-binding-for-new-avr-models/36188/2

@idserda
Copy link
Contributor Author

idserda commented Dec 5, 2017

@9037568 Can you merge this PR?

@9037568
Copy link
Contributor

9037568 commented Dec 6, 2017

Yes, I meant to get to this sooner.

@9037568 9037568 merged commit fb2fcbb into openhab:master Dec 6, 2017
@idserda
Copy link
Contributor Author

idserda commented Dec 6, 2017

Thanks!

@idserda idserda deleted the fix-denon branch December 6, 2017 06:59
@9037568 9037568 changed the title [denon] Send commands over telnet connection + several other improvements [Denon] Send commands over telnet connection + several other improvements Dec 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants