HomePhabricator

Initial Bluetooth support

Description

Initial Bluetooth support
Supported:

  • Bluetooth rfcomm sockets via btdirect:address(comma separated due to conflicting):port

Not supported

  • Device discovery and pairing (use OS features)

This work is incomplete and still being tested.

Details

Auditors
Timotheos
Provenance
0xseantaskerAuthored on
0xseantaskerPushed on Nov 5 2017, 12:47 PM
Parents
rEE70716f0cd9e9: - Added support object check in Android JNI wrapper for application pause.
Branches
Unknown
Tags
Unknown

Event Timeline

Timotheos added a subscriber: Timotheos.
Timotheos added inline comments.
/include/echo/Network/BluetoothConnection.h
8–10

Documentation would be great ;)

55

The documentation appears to say , but the code says .:

boost::replace_all(address,".", ":");

Why is that?

I still don't really know what a Bluetooth address string should look like.

67

Wrong documentation style for Doxygen ;)

/src/Network/BluetoothConnection.cpp
15

Documentation? Better function name? This seems to be copy-pasted or something?

80
if((((!(((IsConnected())))))))
130

It's not hard to see why?

This evidently wants:

mSocketAddress.rc_bdaddr = (bdaddr_t) {{0, 0, 0, 0, 0, 0}};

But you have

#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
mSocketAddress.rc_bdaddr = BDADDR_ANY;

therefore

mSocketAddress.rc_bdaddr = (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}});

So the difference is simply a dereference.

Wouldn't this be what you want?

mSocketAddress.rc_bdaddr = *BDADDR_ANY;
131
;;
This commit now has outstanding concerns.Nov 12 2017, 10:07 PM

Most of the issues here are from the temporary Android hack code.

/include/echo/Network/BluetoothConnection.h
8–10

You're not going to get it. This is experimental stuff, and this block will be removed.

55

That was a mistake and has been fixed in a more recent commit.

A Bluetooth address looks like this 11:22:33:44:55:66, but we already use : to separate parameters in the networking system, so when specifying Bluetooth addresses you should use ',' instead. I did consider changing to commas for separators which probably won't have a huge impact given the number of applications that use this. But this work is part of another project and refactoring is beyond the scope of what I needed to get done.

67

I am aware of that. This class was copied from TCPConnection which was implemented before doxygen comments.

/src/Network/BluetoothConnection.cpp
15

Ignore this. As mentioned, this work is part of another project and not intended to be final.

If you're interested, this is copied from libbluetooth because it isn't available on Android. This inclusion is part of an experiment.

80

*shrug* Probably a historical accumulation of changes.

130

"You have" - is actually a copy and paste from the library.

On Linux a compile error still occurs. I think C might have less of an issue with it.

mSocketAddress.rc_bdaddr = *BDADDR_ANY;

Doesn't work because it dereferences a temporary rvalue, which in theory should be ok, but I don't know what the standard says on that.

131
;;;;

I've been instructed to accept this commit ;)

/include/echo/Network/BluetoothConnection.h
55

A Bluetooth address looks like this 11:22:33:44:55:66, but we already use : to separate parameters in the networking system, so when specifying Bluetooth addresses you should use ',' instead.

That would be a useful comment :)

All concerns with this commit have now been addressed.Nov 12 2017, 11:32 PM
/include/echo/Network/BluetoothConnection.h
55

Done =)