Android Question BLE Device not connecting?

Scantech

Well-Known Member
Licensed User
Longtime User
I am trying to connect to a BLE Device. I ran a scan and found mac name and id.

I use manager.Connect and manager.Connect2 and failed to connect. manager_Disconnected event gets triggered.

Is there something i am missing or some procedure required? BLE is new to me and i am trying to figure this out.
 

Scantech

Well-Known Member
Licensed User
Longtime User
What happens when you run the BLE example? Are you able to connect?

Make sure that the peripheral device allows connections. Maybe you need to press on something before it accepts connections.

I had to modify your BLE example because it stops scan to the first available device and connects to it. I added "if Found Device ID = myDevice ID then Stop Scan and Connect2". Still no progress.

The device does not have anything to press on to. It is Viecar OBD2 Device Dual Mode (Bluetooth 2.0 and Bluetooth 4.0) and there are many apps at the store supports this device. I am only interested in BLE 4.0 with your BLE2 library.
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
Are you able to connect (not read data from the advertising packets) with an app such as this one: https://play.google.com/store/apps/details?id=com.lapis_semi.bleapp&hl=en ?

I downloaded it and it will not connect with Android. I tried the same app with IOS and it connected fine. It has a Dual mode and i am beginning to think the Bluetooth 2.0 is for Android and 4.0 is IOS. Is it possible it only works for IOS? Should Android also have ways to connect to it?

Your BLE2 is awesome and i should of never under estimate the library.
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
We are fighting a similar dragon in another thread, and you might want to consider:

We bought tablets that specs say are Bluetooth 4.0 and 4.2 compatible, and turns out they don't support BLE. Then I spent an hour with Samsung trying to pin down which of their tablets support BLE, and it was like trying to round up sheep ;-/
https://www.b4x.com/android/forum/threads/bluetooth-4-0-data-exchange.103107/#post-646702

whether they are communicating with Bluetooth Low Energy or with Bluetooth Classic (BR/EDR). The two are not the same, nor compatible with each other. The B4A BLE2 library only works for Bluetooth Low Energy.

https://en.wikipedia.org/wiki/Bluetooth_Low_Energy#Compatibility

So, the next step is to use the BLE Checker app to confirm that the Android devices support BLE, and then to use nRF Connect or BLE UUID Explorer to scan and find and connect your hardware and read a value.
https://www.b4x.com/android/forum/threads/bluetooth-4-0-data-exchange.103107/#post-646730

The apps that I've been using to confirm that devices are actually using BLE (so that I don't get tricked into attempting miracles with B4A+BLE2) are:
(The impossible we do at once; the miraculous takes a little longer)

upload_2019-2-27_3-42-39-png.77771


If you can't communicate with the BLE device using nRF Connect or BLE UUID Explorer or BLE Analyser, then you can rely on B4A+BLE2 not being able to communicate with it either (unless one of those three apps includes a secret non-BLE ie BR/EDR Bluetooth interface... :-/ )
 
Upvote 0

Comalco

Member
Licensed User
Longtime User
Note that there is a similar library for B4i.

There is almost nothing to configure before a connection is made. So if it doesn't work then there isn't much that you can do.
I have spent hours today reading through various posts here, and on the wider www, about this issue as I too have the problem many describe.
I have an ESP32 running some small Micropython code that sends a simple 2 values from a transducer to a BLE device.
The BLE2 example app scans, finds the device, but won't Connect to it. After a timeout the Debug reports 'Disconnected'.
Serial terminal on the phone connects without issue, as does nRF Connect. As soon as the phone connects using either of these two apps I can see the ESP32 sending the 2 values......
I think the issue is in the manager.Connect2(device.Mac, False) line in the private Sub scanTimeout_Tick.
The Log entry is written on the previous line, but nothing occurs from this line onwards........
Its out of my depth but I will have a look at Github (I think I read somewhere the BLE library was open source on there) as I am curious what manager.Connect2 does....
Would there be any other pointers on what I could try to resolve this issue please ?
 
Upvote 0
Top