Need to get device of the peripheral.
See original GitHub issueHi Weliem,
I need to broadcast the device of the BluetoothPeripheral instance when it is connected or disconnected. I can put the address of the peripheral into intent.putExtra, but in my case I need to put the bluetooth device into intent.putExtra. The bluetooth peripheral is not parcelable but the bluetooth device is parcaleble, so I am able to put the device into intent.putExtra. The thing that I would like to stress is that I need to get the device of the peripheral, but it is private.
override fun onConnectedPeripheral(peripheral: BluetoothPeripheral) {
Timber.i("connected to '%s' '%s'", peripheral.name, peripheral.address)
broadcastUpdate(ACTION_PERIPHERAL_CONNECTED, peripheral.getDevice())
}
private fun broadcastUpdate(action: String, device: BluetoothDevice) {
val intent = Intent(action)
intent.putExtra(EXTRA_DATA, device)
mainHandler.post { context.sendBroadcast(intent) }
}
My proposal: Can you add a method into BluetoothPeripheral like below:
/**
* Get the device of the bluetooth peripheral.
*
* @return device of the bluetooth peripheral
*/
@NotNull
public BluetoothDevice getDevice() {
return this.device; // or return device;
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Peripheral device | Definition & Examples | Britannica
used to enter information and instructions into a computer for storage or processing and to deliver the processed data to a human operator...
Read more >What is a Peripheral Device? - Definition from Techopedia
A peripheral device is an internal or external device that connects directly to a computer or other digital device but does not contribute ......
Read more >What Is a Peripheral Device? (Peripheral Definition) - Lifewire
A peripheral is any device, like a keyboard, hard drive, mouse, etc., that connects to the computer, either internally or externally.
Read more >Peripheral device recommendations - UNC ITS
Both vendors provide options for Headsets, Webcams, Microphones, Speakers, Keyboards, Mice, Mouse/Keyboard combinations, Monitors, Docking Stations, Laptop ...
Read more >Peripheral Device - an overview | ScienceDirect Topics
Peripheral devices have low complexity and support a single connection. The most complex role is that of a Central device which can initiate...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @ceduliocezar, I got it.
But I don’t understand why the package owner @weliem does not allow
peripheral.getDevice()
and what the restriction is for not getting BluetoothDevice of the BluetoothPeripheral in behind the scene.Hi weliem, I still need to have
peripheral.getDevice()
for the reason that I have explained above.