-
-
Notifications
You must be signed in to change notification settings - Fork 763
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
Scan sometimes doesn't find anything #1019
Comments
Hi read this Issue May be help for you. |
Thanks but i have already do your solution. Maybe it is related to #943. If so, well, we need to wait for an update who can fix this problem |
@1mike12 Did you find out what the problem is? I'm using expo and installed Here's what I see in the console log: Note the following:
So instead of scanning I just connected directly to the device using its MAC address. And that worked. (But I've read in some comments that I shouldn't be able to connect without scanning first?) |
@ic-twist I actually didn't dig too much into it but I did run the app in the ble rich environment of an airplane and there, I got lots of rows to render, but I couldn't really tell if it was really working since every row seemed to be white text on white background. But I think it was. Oh wait I ran it again and I just have to long press to see it really is returning results. 🤦♂️ |
@ic-twist Have you gave the Location permission? On android you must have access to the location to use bluetooth. Maybe it's just this. If not can we see your code? |
@1mike12 your images show exactly what i got on my side. When you're on the example app, you always see the "No peripheral" or is it just sometime like me? |
@TheMizuchi Granting the location permission did make a difference. But now when I start scanning, the bleManager is stuck on scanning and the promise is never resolved. I'm using the example code that comes with the library (https://github.com/innoveit/react-native-ble-manager/blob/master/example/App.tsx), I just modified some console logs to show more information. But here's the code for scanning.
|
Well for me all work on the example (except my problem of scanning...) |
To get scanning to work for now I request precise location on Android 12. You may also need to also add it to your manifest. PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, '') |
I think I found out what my problem was:
Two suggestions/question I have:
Thanks everyone for the help! |
I propose adding this function enableBle() {
BleManager.enableBluetooth()
.then(() => {
// Success code
console.log("The bluetooth is already enabled or the user confirmed");
})
.catch((error) => {
// Failure code
console.log("The user refuse to enable bluetooth");
})
} And call the function after BLE starts BleManager.start({ showAlert: false })
.then(() => {
console.debug('BleManager started.');
enableBle();
})
.catch(error =>
console.error('BeManager could not be started.', error),
); This can prevent the case when the user (like myself) forgot to turn on their bluetooth while trying the example code. |
Hi, i am facing the same issue. |
@ReactRaylogic What is the issue, then, if you're able to get BLE devices in scan list? |
@ic-twist The thing was after adding the permissions in Manifest I would have to go into the app setting and click on allow of Nearby Device permission (which was already added) to get the list. |
Describe the bug
When you scan, 1 time out of 6-10, the scan don't find anything and run out of times
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The method scan find all BLE devices available
Smartphone (please complete the following information):
Additional context
When you relaunch a scan with this app, the scan rework. I don't know why but it's work.
If it's happened to anyone else, a way to get around is to make the stop scan listener relaunch a scan if it doesn't find anything. The cons of that is the scan can be stuck for 3-15s and make the connection a bit long.
(just for precision, the scan on plx work perfecly so I don't think it's my smartphone the cause of the problem)
The text was updated successfully, but these errors were encountered: