Bluetooth connections

Stulish

Active Member
Licensed User
Longtime User
I thought i would ask here first, i want my tablet to connect to my laptop when available, they are both paired with each other.

If i use a timer to check if BT can connect to the device will it throw an error when its not available (not in range).

I will make a sample program tomorrow, but thought i would ask first.

Thanks

Stu
 

Stulish

Active Member
Licensed User
Longtime User
I have implemented a timer and every 2 seconds it carries out:

B4X:
Serial1.Connect(BTMAC)
Serial1.Listen

BTMAC is the MAC Address of the Bluetooth transmitter i connect to, the app seems to work fine, i can knock the transmitter off and on at random intervals and the app reconnects. i have left it running for a few hours to see if it throws up any errors and none have occurred.

Can anyone see a problem with this code, something it may do behind the scenes of B4A that could cause problems over time (ie a memory leak or something).

I will keep testing to see if i can 'break it' but so far so good :)
 
Upvote 0

Stulish

Active Member
Licensed User
Longtime User
Thanks Erel,

I have found it i mess with the Bluetooth transmitter (switching it off at random times and then back on to simulate moving out of range) that the tablet can sometimes say its connected but receive no data.

What i have done to get around this is for the app to see if data has been received and if nothing is seen for 12 seconds then the tablet disconnects and disables Bluetooth, then re-enables and re-connects, this all seems to work fine now no matter what i throw at the app to see if i can cause a problem.

Thanks

Stu
 
Upvote 0
Top