最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

kotlin - Is it possible for an Android device to act as both GATT Server and GATT Client simultaneously? - Stack Overflow

matteradmin7PV0评论

I'm developing an Android application that uses Bluetooth Low Energy (BLE) for communication.
I want to know if it is possible for a single device to function as both a GATT Server and a GATT Client.

For example, if I install the app on two devices, Device A and Device B, can both devices continuously run BLE advertising, BLE scanning, and act as GATT servers?
When they detect each other, can one device connect to the other as a GATT Client?
Additionally, if this is possible, can both devices establish a mutual relationship where each acts as a client to the other's server?

I created a demo application, and while I was able to successfully detect both devices, when I execute device.connectGatt(), there is no response in the GattClientService. Instead, the following logs appear on the GattServerService side.

As you can see, once the device connects to the GATT server, it gets disconnected, and the onConnectionStateChange() callback is invoked.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far