Creating Bluetooth Piconet on Android

I am working on installing Bluetooth Piconet among several devices in a test bench. The topology of this network is known to all devices.

Devices in the testbed are Ubuntu desktops and Android devices (Eclair). Now I am considering a way to establish a basic slave connection between these devices in a deterministic way. In particular, I am looking for a way to install an android device as master and open several connections with 7 other devices.

I looked at my own implementations using the blue column and NDK, but the implementation of the bluez stack on my device (Samsung GT 15503) does not meet the standards that I assume, and even ordinary applications like hcitool, hciconfig do not work.

So I tried using the official SDK and was even able to install the RFCOMM socket with my laptop (using the example bluetooth chat application as a link). But I am stuck at the point where I am trying to connect two or more devices using the same BluetoothServerSocket. If I do not close the source socket, I cannot open new connections.

Any suggestions in this regard are welcome.

+3
source share
2 answers

I finally realized what I was doing wrong. Apparently, whenever you call the accept method from BluetoothServerSocket and return the socket, you need to close this socket before calling accept again.

, , , 7 UUID BluetoothServerSocket UUID. UUID, UUID.

, BTClickLinkCompete.

for (int i = 0; i < 7; i++) {
                BluetoothServerSocket myServerSocket = mBtAdapter
                        .listenUsingRfcommWithServiceRecord(srcApp, mUuid.get(i));
                BluetoothSocket myBSock = myServerSocket.accept();
                myServerSocket.close(); // Close the socket now that the connection
                //has been made
                //Do stuff with the socket here, like callback to main thread
}

mUuid - , 7 uuids. , , uuids , , .

+8

, :

accept() ( BluetoothServerSocket), .

, , , accept()

+1

Source: https://habr.com/ru/post/1792244/


All Articles