Android Question BLE disconnect

Arnaud

Active Member
Licensed User
Longtime User
Hello,

I have tested the BLE 2 example (link below) for Android with 2 BLE device (RN4678 and Ebyte E104-BT40).

Location is enable, but when I try to connect, I receive "disconnect" result just few second after. This with android 7, android 8 and android 10.

When I try with the BLE scanner APP , it works fine.

Here the log unfilter to see the difference between B4A BLE example APP and BLE scanner APP :

Thanks for your help.

unfilter code:
-------------------------B4A APP------------------------------------

connect() - device: D8:80:39:F1:20:33, auto: true
registerApp()
registerApp() - UUID=bf470bf7-13de-43ef-b36b-d152d6289488
registerClient() - UUID=bf470bf7-13de-43ef-b36b-d152d6289488
onClientRegistered() - UUID=bf470bf7-13de-43ef-b36b-d152d6289488, clientIf=10
onClientRegistered() - status=0 clientIf=10
clientConnect() - clientIf =10, address=D8:80:39:F1:20:33, isDirect=false, transport = 0
btif_get_address_type: Device [d8:80:39:f1:20:33] address type 0
btif_get_device_type: Device [d8:80:39:f1:20:33] type 3
Unsupported transport for background connection
bta_gattc_init_bk_conn unable to connect to remote bd_addr:d8:80:39:f1:20:33
onConnected() - clientIf=10, connId=65535, address=D8:80:39:F1:20:33
onClientConnectionState() - status=133 clientIf=10 device=D8:80:39:F1:20:33
close()
unregisterApp() - mClientIf=10
unregisterClient() - clientIf=10
Disconnected



-------------------------BLE Scanner APP------------------------------------

connect() - device: D8:80:39:F1:20:33, auto: false
registerApp()
registerApp() - UUID=570619e6-f8f3-4b15-99b8-9a31d53e2b42
registerClient() - UUID=570619e6-f8f3-4b15-99b8-9a31d53e2b42
onClientRegistered() - UUID=570619e6-f8f3-4b15-99b8-9a31d53e2b42, clientIf=11
onClientRegistered() - status=0 clientIf=11
clientConnect() - clientIf =11, address=D8:80:39:F1:20:33, isDirect=true, transport = 2
btif_get_address_type: Device [d8:80:39:f1:20:33] address type 0
btif_get_device_type: Device [d8:80:39:f1:20:33] type 3
.....
Connected


 

DonManfred

Expert
Licensed User
Longtime User
Too less information for us to help you.

Where is your projectupload/Manifest/example code using Runtimepermission?
 
Upvote 0

Arnaud

Active Member
Licensed User
Longtime User
Hello,

I use the same project as BLE2 example.

Please find the manifest and my project.

Manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddPermission(android.permission.ACCESS_FINE_LOCATION)
 

Attachments

  • BLE test.zip
    150 KB · Views: 276
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
Have you tried the example without modifications? (I'm almost sure you have a permission issue)

also, using nRF APP, everything works? are you getting the right information?
 
Upvote 0

Arnaud

Active Member
Licensed User
Longtime User
@f0raster0, thanks for your help

Have you tried the example without modifications?
Yes

(I'm almost sure you have a permission issue)
I use permission for fine location (please find screenshot in attachment)

also, using nRF APP, everything works?

Yes, it works fine (please find screenshot in attachment)


Manifest:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddPermission(android.permission.ACCESS_FINE_LOCATION)
 

Attachments

  • 20210115_090505.jpg
    20210115_090505.jpg
    313.1 KB · Views: 253
  • 20210115_090340.jpg
    20210115_090340.jpg
    365.1 KB · Views: 277
  • 20210115_090730.jpg
    20210115_090730.jpg
    360.3 KB · Views: 260
  • 20210115_090742.jpg
    20210115_090742.jpg
    381.1 KB · Views: 247
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
Hello,

I use the same project as BLE2 example.

Please find the manifest and my project.

Manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddPermission(android.permission.ACCESS_FINE_LOCATION)
the file attached is not the example

try the example, and post the logs

Have you tried the example without modifications?
 
Last edited:
Upvote 0

Arnaud

Active Member
Licensed User
Longtime User
the file attached is not the example

try the example, and post the logs

Have you tried the example without modifications?

Yes I have try with the example without modification, same result. Please find the UUID get with nRF, and the log.

log:
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Found: , 59:A3:1C:9B:C7:BF, RSSI = -46, (MyMap) {1=[B@b0716ae, 10=[B@381dc4f, -1=[B@3850fdc, 0=[B@aa4f8e5}
Found: , 6C:97:96:7F:8A:4F, RSSI = -46, (MyMap) {1=[B@231efba, -1=[B@a29ee6b, 0=[B@c414dc8}
Found: , 03:C8:4E:63:FD:0B, RSSI = -44, (MyMap) {-1=[B@e313e61, 0=[B@bff4d86}
Found: , 72:00:41:EF:8E:00, RSSI = -92, (MyMap) {1=[B@f70647, 10=[B@f017e74, -1=[B@9e25f9d, 0=[B@ef2bc12}
Found: ALFANO-0BLE, EA:B6:0B:B7:3A:F0, RSSI = -47, (MyMap) {1=[B@a93bfe3, 2=[B@1f20de0, 9=[B@f8a5899, 0=[B@43c875e}
Disconnected
** Activity (main) Pause, UserClosed = false **
 

Attachments

  • 20210115_112443.jpg
    20210115_112443.jpg
    282 KB · Views: 221
  • 20210115_112124.jpg
    20210115_112124.jpg
    234.8 KB · Views: 239
  • 20210115_112138.jpg
    20210115_112138.jpg
    225 KB · Views: 229
  • 20210115_112145.jpg
    20210115_112145.jpg
    232.4 KB · Views: 243
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
Yes I have try with the example without modification, same result. Please find the UUID get with nRF, and the log.

log:
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Found: , 59:A3:1C:9B:C7:BF, RSSI = -46, (MyMap) {1=[B@b0716ae, 10=[B@381dc4f, -1=[B@3850fdc, 0=[B@aa4f8e5}
Found: , 6C:97:96:7F:8A:4F, RSSI = -46, (MyMap) {1=[B@231efba, -1=[B@a29ee6b, 0=[B@c414dc8}
Found: , 03:C8:4E:63:FD:0B, RSSI = -44, (MyMap) {-1=[B@e313e61, 0=[B@bff4d86}
Found: , 72:00:41:EF:8E:00, RSSI = -92, (MyMap) {1=[B@f70647, 10=[B@f017e74, -1=[B@9e25f9d, 0=[B@ef2bc12}
Found: ALFANO-0BLE, EA:B6:0B:B7:3A:F0, RSSI = -47, (MyMap) {1=[B@a93bfe3, 2=[B@1f20de0, 9=[B@f8a5899, 0=[B@43c875e}
Disconnected
** Activity (main) Pause, UserClosed = false **
I see, yes got similar issues (hard to connect and easy to unconnected) using that example with some modules don't remember how I solved that..

anyway can you please try using this example:

you have to update the UUID with your ones
 
Upvote 0
Top