Android Question BLE failed to connect

aeric

Expert
Licensed User
Longtime User
I tried the BLE Example project. B4i works fine but for B4A it fails to connect to my bluetooth thermal printer.

Here is the unfiltered logs:

B4X:
Logger connected to:  Xiaomi Redmi 5 Plus
--------- beginning of main
miui_dex2oat: OatFile: /data/app/b4a.example-QUXB6FO4fm1tvaIetSbGcA==/oat/arm64/base.odex Compiler-Filter = quicken
No package identifier when getting name for resource number 0x00000000
No package identifier when getting name for resource number 0x00000000
common created.
Starting remote logger. Port: 35352
AccessibilityManager status: mPackageName = b4a.example, mOptimizeEnabled = true, mIsEnabled = true, mIsUiAutomationEnabled = false, mIsInterestedPackage =true
HWUI GL Pipeline
QUALCOMM build                   : 8e3df98, Ie4790512f3
Build Date                       : 04/11/18
OpenGL ES Shader Compiler Version: EV031.22.00.01
Local Branch                     :
Remote Branch                    : quic/gfx-adreno.lnx.1.0.r36-rel
Remote Branch                    : NONE
Reconstruct Branch               : NOTHING
Loading /vendor/lib64/hw/gralloc.msm8953.so from current namespace instead of sphal namespace.
PFP: 0x005ff087, ME: 0x005ff063
*** Debugger waiting for connection (0) ***
android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
Initialized EGL, version 1.4
Swap behavior 2
ignoring event: create_menu
Loading /vendor/lib64/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.
Loading /vendor/lib64/hw/gralloc.msm8953.so from current namespace instead of sphal namespace.
Show toast from OpPackageName:b4a.example, PackageName:b4a.example
After accept
java.net.SocketTimeoutException: Poll timed out
    at libcore.io.IoBridge.poll(IoBridge.java:691)
    at java.net.PlainSocketImpl.socketAccept(PlainSocketImpl.java:183)
    at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:416)
    at java.net.ServerSocket.implAccept(ServerSocket.java:547)
    at java.net.ServerSocket.accept(ServerSocket.java:515)
    at anywheresoftware.b4a.shell.ShellConnector.connect(ShellConnector.java:153)
    at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:119)
    at java.lang.Thread.run(Thread.java:764)
System.exit called, status: 0
VM exiting with result code 0, cleanup skipped.
miui_dex2oat: OatFile: /data/app/b4a.example-kCDmTAvWXajoA_eturAgXQ==/oat/arm64/base.odex Compiler-Filter = quicken
No package identifier when getting name for resource number 0x00000000
No package identifier when getting name for resource number 0x00000000
common created.
Starting remote logger. Port: 35352
AccessibilityManager status: mPackageName = b4a.example, mOptimizeEnabled = true, mIsEnabled = true, mIsUiAutomationEnabled = false, mIsInterestedPackage =true
HWUI GL Pipeline
QUALCOMM build                   : 8e3df98, Ie4790512f3
Build Date                       : 04/11/18
OpenGL ES Shader Compiler Version: EV031.22.00.01
Local Branch                     :
Remote Branch                    : quic/gfx-adreno.lnx.1.0.r36-rel
Remote Branch                    : NONE
Reconstruct Branch               : NOTHING
Loading /vendor/lib64/hw/gralloc.msm8953.so from current namespace instead of sphal namespace.
PFP: 0x005ff087, ME: 0x005ff063
*** Debugger waiting for connection (0) ***
android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
Initialized EGL, version 1.4
Swap behavior 2
ignoring event: create_menu
Loading /vendor/lib64/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.
Loading /vendor/lib64/hw/gralloc.msm8953.so from current namespace instead of sphal namespace.
Show toast from OpPackageName:b4a.example, PackageName:b4a.example
After accept
java.net.SocketTimeoutException: Poll timed out
    at libcore.io.IoBridge.poll(IoBridge.java:691)
    at java.net.PlainSocketImpl.socketAccept(PlainSocketImpl.java:183)
    at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:416)
    at java.net.ServerSocket.implAccept(ServerSocket.java:547)
    at java.net.ServerSocket.accept(ServerSocket.java:515)
    at anywheresoftware.b4a.shell.ShellConnector.connect(ShellConnector.java:153)
    at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:119)
    at java.lang.Thread.run(Thread.java:764)
System.exit called, status: 0
VM exiting with result code 0, cleanup skipped.
miui_dex2oat: OatFile: /data/app/b4a.example-OLh61MPZ5w4uGnKqSYbkNQ==/oat/arm64/base.odex Compiler-Filter = quicken
No package identifier when getting name for resource number 0x00000000
No package identifier when getting name for resource number 0x00000000
common created.
Starting remote logger. Port: 35352
AccessibilityManager status: mPackageName = b4a.example, mOptimizeEnabled = true, mIsEnabled = true, mIsUiAutomationEnabled = false, mIsInterestedPackage =true
HWUI GL Pipeline
After accept
QUALCOMM build                   : 8e3df98, Ie4790512f3
Build Date                       : 04/11/18
OpenGL ES Shader Compiler Version: EV031.22.00.01
Local Branch                     :
Remote Branch                    : quic/gfx-adreno.lnx.1.0.r36-rel
Remote Branch                    : NONE
Reconstruct Branch               : NOTHING
Loading /vendor/lib64/hw/gralloc.msm8953.so from current namespace instead of sphal namespace.
PFP: 0x005ff087, ME: 0x005ff063
*** Debugger waiting for connection (0) ***
android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
Initialized EGL, version 1.4
Swap behavior 2
ignoring event: create_menu
Loading /vendor/lib64/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.
Loading /vendor/lib64/hw/gralloc.msm8953.so from current namespace instead of sphal namespace.
Show toast from OpPackageName:b4a.example, PackageName:b4a.example
*** Debugger waiting for connection (1) ***
Copying updated assets files (9)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Do partial code cache collection, code=29KB, data=19KB
After code cache collection, code=28KB, data=19KB
Increasing code cache capacity to 128KB
Do partial code cache collection, code=56KB, data=44KB
After code cache collection, code=56KB, data=44KB
Increasing code cache capacity to 256KB
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
startLeScan(): null
isLeEnabled(): ON
onScannerRegistered() - status=0 scannerId=5 mScannerId=0
Found: LMP201, 02:1A:33:62:17:67, RSSI = -62, (MyMap) {1=[B@5c2601b, 6=[B@ced55b8, -1=[B@57bbf91, 9=[B@534eef6, 2=[B@9ce2f7, 0=[B@1fe1564}
stopLeScan()
isLeEnabled(): ON
connecting
connect() - device: 02:1A:33:62:17:67, auto: false
registerApp()
registerApp() - UUID=18617f20-28b2-4575-a622-10baf08dd278
onClientRegistered() - status=0 clientIf=5
Do full code cache collection, code=126KB, data=73KB
After code cache collection, code=93KB, data=46KB
onClientConnectionState() - status=133 clientIf=5 device=02:1A:33:62:17:67
close()
unregisterApp() - mClientIf=5
Disconnected
 

aeric

Expert
Licensed User
Longtime User
Have you added the new permissions?
This:

B4X:
AddPermission(android.permission.ACCESS_FINE_LOCATION)

Yes.
Sometimes it can connect to an iPhone but not the thermal printer.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I tried the BLE3 library and it is connected with the code below:

B4X:
ble3.Connect3("02:1A:33:62:17:67", False, 2)
 
Upvote 0

Star-Dust

Expert
Licensed User
Upvote 0
Top