New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BLE devices are retuning device name NULL during scanning process on android 13 #660
Comments
Hi @BasuHuddar, I'm the friendly issue checker. |
Similar observations have been reported before, e.g. in #456. Is the device name missing for all devices that are returned by the scan, or only some of them? |
@janusw Yes, it is missing all the device's names in android 13. |
I am able to see the device name and device Id for some but not for others. HOWEVER since the latest Android update with Android 13, if a device drops connection, I cannot seed the device again unless I restart the app. Then the device is seen an automatically connects again. when the device drops connection I have tried stopping and restarting the scanning but the device is never found again. Other devices are, just not the device that lost connection. I have tested this with a variety of products. I guess I should submit a bug for this as well |
@janusw, i got the fix for this, should we get access to the code to edit and generate a nupkg? |
@BasuHuddar If you have a fix, you could either just post a patch/snippet here or ideally open a Pull Request. |
@janusw @BasuHuddar I would be curious if it fixes the issue I listed in #665 |
if (string.IsNullOrEmpty(BluetoothDevice.Name)) |
yeah that is not the same issue I am seeing. I cannot see item if it drops
connection
…On Mon, Apr 3, 2023 at 8:48 AM BasuHuddar ***@***.***> wrote:
if (string.IsNullOrEmpty(BluetoothDevice.Name))
{
ByteBuffer order =
ByteBuffer.Wrap(AdvertisementData).Order(ByteOrder.LittleEndian);
while (order.Remaining() > 2)
{
byte b = (byte)order.Get();
if (b != 0)
{
if (order.Get() != 9)
{
order.Position((order.Position() + b) - 1);
}
else
{
byte[] bArr2 = new byte[(b - 1)];
order.Get(bArr2);
try
{
Name = (System.Text.Encoding.UTF8.GetString(bArr2)).Trim();
}
catch (UnsupportedEncodingException unused)
{
Trace.Message("Error occured while converting byte to string",
unused.Message);
}
}
}
}
}
else
{
Name = BluetoothDevice.Name;
}
@janusw <https://github.com/janusw> here is the code base we need to
chage it device class in android
—
Reply to this email directly, view it on GitHub
<#660 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOZ5VYA6FIUMFZ7SSZO3GC3W7LWLTANCNFSM6AAAAAAWAZ5Q3I>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Have you actually tried if this fixes the problem? I haven't looked at it very closely yet. Where exactly does this code need to go? What you should do to go forward with this is:
The PR will actually generate a nupkg automatically. Then others can try and review it. |
@janusw Yes it's fixed the problem for me, From which branch should i create the branch? |
master, please :) |
Unable to build it getting errors, but I'm able to build tag 2.1.3, i tested here it's working @janusw are you ok with this? |
@janusw I tested in Tag 2.1.3 it working, PFA |
We will not have another 2.x release, so in the end it will need to be applied to master. If you have trouble building master, you can also start with a branch based on 2.1.3 and we forward-port it from there. Or you port your code to master yourself. The CI will tell you if there are build errors. |
Thanks for the commit. It seems you're taking the device name from advertisement records of type I think the idea as such is pretty good, but the technical implementation needs some adjustment IMHO:
|
@janusw I dint get it, but i checked the code in the parseScanrecord you are using for getting the advertisement data, but how should we use it to assign the name of the BLE device? One more before parsing the advertising byte we were setting the name in the update method. |
Let me take care of molding this into the right form. I'll also create a PR from it. Maybe you can test once more after I'm done ... |
See #667. |
@BasuHuddar Two more questions here:
|
@janusw Yes I'm getting the device name null in the 2.x and 3.0 beta version |
I recently noticed that in the developer settings (networking section), there is an option to show Bluetooth devices without names (Mac addr only). @BasuHuddar Could you check if you have that switch enabled? |
@janusw I tried but no luck on that as well |
What do you mean? You could not check it? Or "show devices without names" is not enabled? If the developer mode is not enabled, try this: |
I enable the developer mode and switched enabled for the Bluetooth devices without names (Mac address only), but it's not working |
Well, of course. If that switch is enabled, then you will certainly not see any device names. The question is: Do you still fail to see device names if the switch is off? Do I understand correctly that the device names are only missing on one particular device (Samsung M33), but not on others? |
Yes, I haven't seen any device names, if it's switched off or switched on. We are seeing this in Samsung M33 and Redmi phones(Android 13). As I don't haves the other phone to check it here. |
Ok, thanks for checking.
AFAICS it is not a general Android 13 problem, since my Samsung S21+ seems to show device names properly.
Hm, but in #667 (comment) you said that you see CompleteLocalName ad records on a Samsung M40 on Android 11, right? I still wonder how the patch that you proposed above can work if you don't see any CompleteLocalName records on the M33? This can only mean that the parsing of those records somehow fails in Plugin.BLE. It would be great if you could verify/debug this hypothesis, otherwise we'll not be able to make progress here, unfortunately (I cannot reproduce the issue after all). |
@BasuHuddar Could this possibly be related to #567? Do you see a |
Yes it's an Android 11
Yes debugged here, but I'm not finding it completeLocalname |
**On My side I am not seeing System.ArgumentException during the parsing of the advertisement ** |
Actually I found one condition, under which I can reproduce missing device names on Android (v13) ... If I use a scan filter, which excludes @BasuHuddar Could your issue be related to scan filtering? Did you use a scan filter in your tests? Can you reproduce the issue when no scan filter is in effect? |
This comment was marked as off-topic.
This comment was marked as off-topic.
@paulobikiwelu Please open a new issue, this one is about missing device names. |
We are not getting the BLE device name while scanning the Bluetooth devices in android 13.
Steps to reproduce
Expected behavior
We should get the device name in the scanned result
Actual behavior
The device name is null
Configuration
Version of the Plugin: 2.1.3
Platform: e.g. Android .. (including version!!! e.g. Android 13)
Device: e.g. Samsung, Redmi
The text was updated successfully, but these errors were encountered: