question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need to get device of the peripheral.

See original GitHub issue

Hi 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:closed
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
talatkuyukcommented, Jul 23, 2021

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.

0reactions
talatkuyukcommented, Sep 11, 2021

Hi weliem, I still need to have peripheral.getDevice() for the reason that I have explained above.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found