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.

IDevice.ReadRssi() throws NullReferenceException

See original GitHub issue

I am playing around with the plugin a bit and ran into this issue with calling ReadRssi() on an IDevice instance.

What I am doing is basically, scan for devices, select one of them and show details about it.

On that selected IDevice instance I do:

_device?.ReadRssi();

This throws the following exception:

05-04 10:43:20.080 E/mono-rt (20530): [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.
05-04 10:43:20.080 E/mono-rt (20530):   at MvvmCross.Plugins.BLE.Droid.Bluetooth.LE.Device.ReadRssi () [0x00000] in c:\Users\sead\Documents\GitHub\MvvmCross-BluetoothLE\Source\MvvmCross.Plugins.BLE.Droid\Bluetooth\LE\Device.cs:264 
05-04 10:43:20.080 E/mono-rt (20530):   at com.bksv.ems.sxuble.ViewModels.DeviceDetailsViewModel.StartData () [0x00031] in C:\Users\Tomasz\Documents\Visual Studio 2015\Projects\SXUBLE\SXUBLE\ViewModels\DeviceDetailsViewModel.cs:90 
05-04 10:43:20.080 E/mono-rt (20530):   at com.bksv.ems.sxuble.droid.Views.DeviceDetailsView.OnResume () [0x00008] in C:\Users\Tomasz\Documents\Visual Studio 2015\Projects\SXUBLE\SXUBLE.Droid\Views\DeviceDetailsView.cs:22 
05-04 10:43:20.080 E/mono-rt (20530):   at Android.App.Activity.n_OnResume (IntPtr jnienv, IntPtr native__this) [0x00009] in /Users/builder/data/lanes/2923/b4be22e9/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:3920 
05-04 10:43:20.080 E/mono-rt (20530):   at (wrapper dynamic-method) System.Object:ec6c167c-6312-4270-86db-3b0ff9ed091e (intptr,intptr)

Looking at the line it throws at: https://github.com/xabre/xamarin-bluetooth-le/blob/master/Source/MvvmCross.Plugins.BLE.Droid/Bluetooth/LE/Device.cs#L264 it could seem like the _gattCallback is null for some reason.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Cheesebaroncommented, May 4, 2016

I guess XML docs would be a good place to document this. Or a small wiki walking this through.

0reactions
Cheesebaroncommented, May 25, 2016

Yes, it is good now 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

IDevice.ReadRssi() throws NullReferenceException #35
I am playing around with the plugin a bit and ran into this issue with calling ReadRssi() on an IDevice instance.
Read more >
Android returning "null" for Bluetooth RSSI
After hitting the scan button to discover nearby devices it returns the device name, device address, and is also suppose to return the...
Read more >
Nrf Connect SDK peripheral always reads RSSI as 127 ...
Hello, I'm using an nRF5340 board with nRF Connect SDK as a BLE peripheral device, and I'm trying to get RSSI value when...
Read more >
BLE scan for RSSI for bluetooth paired devices : r/androiddev
Is there a way to scan nearby devices and get RSSI values for my paired devices without connecting to them ... getName() +...
Read more >
Java Examples & Tutorials of Intent.getShortExtra (android. ...
makeText(getApplicationContext()," RSSI: " + rssi + "dBm", Toast.LENGTH_SHORT).show(); } } }; ... Android RSSI value of Bluetooth returns -32768 always?
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