Android Question Serial Lib v1.23

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi

Anyone noticed any odd behavior in v1.23 (b4A3.8). In particular with Bluetooth using async streams. I have noticed after maybe 7-10 connections(15 sec's between each connection) from the PC app to the phone, the PC app can no longer connect. Ont he PC Side it sends a packet then closes the connection.
On the phone if it does not receive any data with in 10 seconds it closes the connection and start listening again.

I did another test where the PC does not close the connection, and allows the phone to close the connection. The PC detects that the phone has closed the connection. In this scenario I do not experience any problems.

Has anyone any insights into this type of behavior ?

Regards

John.
 

petr4ppc

Well-Known Member
Licensed User
Longtime User
John - I had same problem.....

And the reason is that when battery in my phone sink under 50 procent, the connection to wireless network is automatically interrupt,
maybe it is your situation

I know, that maybe it not solve your trouble, but maybe yes..
Good luck
p4ppc
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi p4ppc

Thanks for the reply, phone is plugged in on full power. I think is the issues is with the Bluetooth Stack in android. I will restart the service on a timeout. We also develop electronics and the guys there say restart the Bluetooth is there are any suspected issues.

An yes you are correct with the power usage limits on certain aspects of the OS.

Thanks again for taking the time to reply

[update]
After restarting the service 6 time, it fails. This is really weird !

Regards

John.
 
Last edited:
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
I m not sure if I have solved the actual, but I certainly have made it more robust.

Manifest Editor:
Add the following;
B4X:
AddReceiverText(svc_bt_disconnect, <intent-filter> <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED"/></intent-filter>)
AddPermission(android.permission.BLUETOOTH)

service module code

B4X:
#Region  Service Attributes
   #StartAtBoot: False
#End Region

Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub
Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)

   ' // BT Device is now disconnected
   CallSub(svc_serial,"com_disconnect")
   StopService("")
   
End Sub

Sub Service_Destroy

End Sub

I now can make the disconnect on myside once the receive the closure notification. does not make scence to me bu there ya go.

Hope this is of help to anyone else who has similar problems.

Regards

John.
 
Upvote 0
Top