Android Question Bluetooth problem

milanjo

Member
Licensed User
Longtime User
Hi,
I'm writing bluetooth aplication which is communicating with HC-06 module attached to my another hardware. Everything seems to work correctly (I was developping on android 4.x tablets). But when I tried this app on huawei android 5.1.1 tablet (I have correctly installed android 5.1.1 sdk) bluetooth work but each time I something send or receive it start heavy lagging (freezing) and it use to end up with "application stopped working" and I must force quit it. So could anybody please check up (review) my code and tell if I'm doing something wrong.

Thank you. Here you can download my code http://rpsx.eu/1pCg
Source codes are located in folder Serial_HC06 (SerialExample.b4a)
Additional libraries which is needed is located in folder "kniznice".
 

milanjo

Member
Licensed User
Longtime User
Thank you for your reply. I have changed textwirter&reader to asyncstreams. It fixed my problem - now it works on both tablets. But there another problem happened. When I awaiting new data - that data come separated like I waiting for "$WP+DCMSG=Test" but it comes like "$WP+DSCMSG" and then another "=Test". I need that data to be in one string. How can I do that. My goal is to received it in one notseparated string like "$WP+DCMSG=Test" - the lenght of string is dynamically changing I cannot know what I should expect - there will be variable lenght of data which I will receive. How I can fix that. Thank you. Source code in attachment.
 

Attachments

  • naforum.zip
    10.6 KB · Views: 222
Upvote 0

milanjo

Member
Licensed User
Longtime User
Thank you. It seems that it partically solved my problem. I have been looking for something like your asyncstreamstext class. Now it work correctly on both tablets when I receive small amount of data. But in Debug mod (my application debug option which will throught bluetooth setup debug on other device - other device start to send me huge amount of debugging data) on my old tablet (yarwik android 4.1.1) it works as before (when I was using textreader) but on the new tablet (huawei android 5.1.1) it laggs for a minute (maybe 30second) and then it shows that huge amount of data which arrived during lagg and then lagg again for another minute and so on. Where I should look for problem ? I cannot understand why it on first tablet works perfectly and on another one it doesn't work. Could you help me again ? Thank you very much. Source code in attachment.
 

Attachments

  • na_forum_dva.zip
    12.3 KB · Views: 229
Upvote 0

milanjo

Member
Licensed User
Longtime User
1.) No the performance in release mode is the same - first tablet OK, second tablet really hard lagging - by the word debug mode I thought mode of my aplication (not b4a ide mode), if I press "debug" button in my app it enable debug on my hardware (witch which I'm communicating throught bluetooth) that device then start me sending huge amounts of debug data - this make my second tablet lagg.
2.)I've tried doesn't help.
 
Upvote 0
Top