-
Notifications
You must be signed in to change notification settings - Fork 780
[Bluetooth] Added BlueGiga USB dongle support #5885
Conversation
Unfortunately karaf feature verification fails:
|
This makes me think that it might be a good idea to also adapt the code to use the new ESH serial API. Will try to do so tonight! |
Done. @maggu2810, when doing this change, I noticed that the ESH Serial API is lacking the methods |
I added the methods that are currently used. If we need that methods now it should be checked if every serial provider supports them and added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding the bluegiga dongle support.
What surprises me is the size of this PR. 15k LOC for "just another bluetooth dongle"? I see that Chris has auto-generated quite a lot of packages and responses, but are these really specific to bluegiga or can we move them over to the generic bluetooth binding and export them there?
I left a few comments in the code, which I stumbled across, please have a look.
</plugin> | ||
</plugins> | ||
</build> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over blank line
assertTrue(serviceData.containsKey(dataServiceUUID)); | ||
assertArrayEquals(new int[] { 0x74, 0x01, 0x0d, 0x01, (byte) 0xec }, serviceData.get(dataServiceUUID)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line missing at the end
@@ -0,0 +1 @@ | |||
# Ble.BlueGiga Binding Default Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no configuration, please remove this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for not removing this empty configuration file, or did you just overlook it?
import java.util.concurrent.CopyOnWriteArraySet; | ||
|
||
import org.eclipse.jdt.annotation.DefaultLocation; | ||
import org.eclipse.jdt.annotation.NonNull; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove references to @NonNull
* @author Chris Jackson - Initial contribution | ||
* @author Kai Kreuzer - Made handler implement BlueGigaHandlerListener | ||
*/ | ||
@NonNullByDefault({ DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE, DefaultLocation.ARRAY_CONTENTS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason why you restrict the annotation, instead of using it without arguments?
command.setConnection(connectionHandle); | ||
command.setStart(1); | ||
command.setEnd(65535); | ||
command.setUuid(UUID.fromString("00002800-0000-0000-0000-000000000000")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a perfect candidate for a constant so this magic string gets a human readable meaning, doesn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you see this comment?
package org.eclipse.smarthome.binding.bluetooth.bluegiga.internal; | ||
|
||
/** | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a description for this interface
* @author Chris Jackson | ||
* | ||
*/ | ||
public class BlueGigaPacket { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the size of this PR and having a packet format specific to this dongle, I am wondering whether each bluetooth dongle sends different packets? If not, can't we move these definitions into the common bluetooth binding and export them there for all dongles to use?
private boolean notifyTransactionComplete(final BlueGigaResponse response) { | ||
boolean processed = false; | ||
|
||
// logger.debug("NODE {}: notifyTransactionResponse {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left over commented out code
} | ||
} | ||
|
||
// TODO: Add a timeout mechanism |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing the TRANSACTION_TIMEOUT_PERIOD
parameter I guess this comment is now obsolete?
/** | ||
* Helper class to create BlueGiga BLE Response and Event packets (ie packets that we will receive). | ||
* <p> | ||
* Note that this code is autogenerated. Manual changes may be overwritten. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed several classes to have this note. Why do we check in autogenerated code? What was the source of this files? Wouldn't it be more future prove to add the original source and the generator to the project?
Service-Component: OSGI-INF/*.xml | ||
Export-Package: org.eclipse.smarthome.binding.bluetooth.bluegiga, | ||
org.eclipse.smarthome.binding.bluetooth.bluegiga.handler | ||
Bundle-ActivationPolicy: lazy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove that line and add Automatic-Module-Name
Thanks @maggu2810, @triller-telekom & @htreu, I have incorporated all your review comments. @triller-telekom I do not know whether this code is only applicable for BlueGiga or also to other dongles / BT support. But as long as nobody expresses the need to reuse it at some other place, I very much prefer to keep it internal here. I myself have never missed it in the generic bluetooth support. @maggu2810 I have added the additional methods in the ESH Serial API within this PR, I hope this is ok. In general, I'd like to mention that this code might not in all places be fully stable, tested and production-ready - this is why I kept is so long in my own fork. But as it is immensely useful when developing bluetooth stuff on a non-Linux machine, I think it should be made available in ESH to all developers. In a typical production scenario, almost everyone will probably rather use Linux with BlueZ. I've kept the PR as a single commit. If you do not find any severe issues with it anymore, it would be great if a CQ could be filed for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your changes. You seem to have forgotten one emtpy config file and there is a magic UUID as a string in the code. Wouldn't it be nicer to have it as a constant with a nice name?
Otherwise the code looks good to me now.
@@ -0,0 +1 @@ | |||
# Ble.BlueGiga Binding Default Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for not removing this empty configuration file, or did you just overlook it?
command.setConnection(connectionHandle); | ||
command.setStart(1); | ||
command.setEnd(65535); | ||
command.setUuid(UUID.fromString("00002800-0000-0000-0000-000000000000")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you see this comment?
As there also exists #5560 that adds another serial implementation have you already checked if this implementation supports the implementation of the new interface methods, too? |
Didn't we agree that new classes / interfaces should already contain the |
Indeed, that got lost in the commit, sorry. Now it is removed.
The reason I left it there is that it is a magic string for me, too; I do not know, what a good constant name would be for it.
I do not remember such a strict decision. If so, this would be mainly for framework interfaces, but I do not think we enforce it for any internal class of any extension. We only expect that no
Good point. I just checked: Yes, the TelnetSerialPort also has those methods, so it should be easy to adapt #5560 accordingly. To avoid dependencies between this PR and #5560, I have now created the separate PR #5907, which should be merged before any of the other two. This PR here will now hence fail to compile until #5907 is merged - but it imho should not prevent us from already creating a CQ for it. |
I just noticed that this PR copies the source from https://github.com/zsmartsystems/com.zsmartsystems.bluetooth.bluegiga. Can you add a note to this effect in the NOTICE file please? |
The code actually originates from extracting the sources that were included in the zip in #3633, which had then been modified in #4535 to match the ESH bluetooth API. The NOTICE file is usually used for referencing third party code that is included as a binary in the distribution (so that it is clear where to find the source code). But if you wish to also add some note wrt zsmartsystems, please suggest a text and I will add it. |
Also-By: Chris Jackson <[email protected]> Also-By: Vlad Kolotov <[email protected]> Signed-off-by: Kai Kreuzer <[email protected]>
@maggu2810 & @htreu: I have fixed the travis build issue, so imho this is ready for a CQ - any further changes can be done through separate follow-up PRs. |
FTR: CQ16983 created. |
CQ16983 has been approved. |
@kaikreuzer sorry - I didn't see your response to the above. Note that if you're using the original code from 18 months ago, then there were a number of bug fixes since then. Since this has been merged now I will create a separate PR to reference the library if that's ok? |
This is a follow-up on #4535, which had BlueGiga dongle support, while I had removed it from the merged #4997.
I have meanwhile cleaned up the code, fixed a few further bugs that I came across, added a test fragment, adapted the code to EPLv2, updated the license headers and added a README file.
Also-By: Chris Jackson [email protected]
Also-By: Vlad Kolotov [email protected]
Signed-off-by: Kai Kreuzer [email protected]