Skip to content

Conversation

@ConnorWhalen
Copy link
Contributor

#242

On the ROV side, the BluetoothReader listens for messages on the bluetooth serial port and broadcasts BluetoothValues

On Topsides, the BluetoothView is a console view that displays each emitted BluetoothValue

Copy link
Contributor

@cal-pratt cal-pratt left a comment

Choose a reason for hiding this comment

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

Only concern is closing the inputstream of the serial port object during calls to onNext. Apart from that and a few nitpicks LGTM

Ship it.

public class BluetoothViewController implements ViewController {
private final BluetoothView view;

private Observable<BluetoothValue> bluetoothValues;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be final.

final String comPortName,
final String comPort,
final int connectionTimeout,
final int baudRate) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick:

I've been opting for single tabs in all indent cases and to place the ( on a new line to distinguish where the parameters end and the method begins.

public BluetoothReader(
    final String comPortName,
    final String comPort,
    final int connectionTimeout,
    final int baudRate
) {
    this.comPortName = comPortName;
    this.comPort = comPort;
    this.connectionTimeout = connectionTimeout;
    this.baudRate = baudRate;
}

try {
try (final InputStream inputStream = serialPort.getInputStream();
final Scanner scanner = new Scanner(inputStream)
) {
Copy link
Contributor

@cal-pratt cal-pratt Jun 11, 2017

Choose a reason for hiding this comment

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

Will calls to close on the inputstream cause the serial port to close?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe don't use the inputstream as a try-with resource and wait for the proper cleanup in onUnsubscribe which will close all connections from/to the serial port.

protected SerialPort next(final SerialPort serialPort, final Observer<? super BluetoothValue> observer) {
try {
final InputStream inputStream = serialPort.getInputStream();
try (final Scanner scanner = new Scanner(inputStream)) {
Copy link
Contributor

@cal-pratt cal-pratt Jun 11, 2017

Choose a reason for hiding this comment

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

Not sure if this will also kill the input. Calling close on a wrapped stream usually closes the initial stream.

@ConnorWhalen
Copy link
Contributor Author

ConnorWhalen commented Jun 11, 2017 via email

@cal-pratt cal-pratt merged commit 1576ab7 into master Jun 13, 2017
@cal-pratt cal-pratt deleted the bluetooth branch June 13, 2017 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants