Machado
Machado

Reputation: 14489

How to send Bluetooth data to an unknown device?

I'm asking because I've been facing that issue for weeks.

I need to develop an Android application that can be able to perform an Bluetooth Connection and send data to an Bluetooth Hardware.

Ok, so here's the point:

is it possible to perform a RFCOMM connection to an 'unknown' device? I mean, is it possible to do this without having any information about the hardware code?

Because i'm only able to modify the AndroidDevice (cellphone) code, for SENDING purposes.

I want to send a byte and make sure it was received, but there's only a sending code.

Upvotes: 0

Views: 1241

Answers (2)

kagronick
kagronick

Reputation: 2688

With bluetooth the two devices have a UUID. If you a writing a program that runs on both devices you have them listen for that UUID. When they connect as a client or a server you have a dataInputStream and a dataOutputStream. Then you can push and pull bytes out of those.

Upvotes: 0

boztalay
boztalay

Reputation: 562

Could we have some more details? Is the other device accessible by you, as in can the other device know information about the Android device? And what do you mean by a "sending code"?

The Android device can pick up any active Bluetooth device in its range, and know the name and address of those devices. So, if the Android device doesn't know anything about the Bluetooth device it wants to connect to, you can always sort through the list of devices in range, and get its hardware code through that.

See the documentation about Bluetooth, specifically the Finding Devices section: http://developer.android.com/guide/topics/connectivity/bluetooth.html

I've done a fair amount of Bluetooth work with Android devices and Arduinos, and the Bluetooth library might be a bit of a pain to work with, but it is powerful.

Upvotes: 1

Related Questions