H headingwest Member Licensed User Longtime User Jul 20, 2013 #1 Hi, I'm stuck with Bluetooth using the official Bluetooth with Asynchstreams example. The device I connect to uses Arduino and responds over BT by sending back the characters that it receives. The only change I've made to the demo is to change Astream.Initializeprefix to Astream.Initialize. If I send "1234567890" I get back: 1 23467 8'? or maybe I get back: 1 23467 80 or maybe: 1 23456 p??? So it seems that about half of the characters come back, but some are missing or garbled. But if I use an app called "Bluetooth Viewer" it all works fine. So it's definitely coming from the VB4A end. Any ideas?
Hi, I'm stuck with Bluetooth using the official Bluetooth with Asynchstreams example. The device I connect to uses Arduino and responds over BT by sending back the characters that it receives. The only change I've made to the demo is to change Astream.Initializeprefix to Astream.Initialize. If I send "1234567890" I get back: 1 23467 8'? or maybe I get back: 1 23467 80 or maybe: 1 23456 p??? So it seems that about half of the characters come back, but some are missing or garbled. But if I use an app called "Bluetooth Viewer" it all works fine. So it's definitely coming from the VB4A end. Any ideas?
KitCarlson Active Member Licensed User Longtime User Jul 20, 2013 #2 It works correctly. The data handling must combine, since it comes in parts. I add to buffer, check if complete, then process, or keep adding. The data that is processed, is removed from buffer. I find it very reliable. Upvote 0
It works correctly. The data handling must combine, since it comes in parts. I add to buffer, check if complete, then process, or keep adding. The data that is processed, is removed from buffer. I find it very reliable.
Erel B4X founder Staff member Licensed User Longtime User Jul 21, 2013 #3 The different modes and options available with AsyncStreams are explained at the end of the tutorial: http://www.b4x.com/forum/showthread.php?p=43578 You should also check the encoding. So it's definitely coming from the VB4A end. Click to expand... Might also be a problem in your code... Upvote 0
The different modes and options available with AsyncStreams are explained at the end of the tutorial: http://www.b4x.com/forum/showthread.php?p=43578 You should also check the encoding. So it's definitely coming from the VB4A end. Click to expand... Might also be a problem in your code...
raphael75 Active Member Licensed User Longtime User Jul 21, 2013 #4 headingwest said: So it seems that about half of the characters come back, but some are missing or garbled. Click to expand... Maybe there are two data streams open at the same time. You can try to put following code before Astream.Initialize: B4X: If Astream.IsInitialized Then Astream.Close Upvote 0
headingwest said: So it seems that about half of the characters come back, but some are missing or garbled. Click to expand... Maybe there are two data streams open at the same time. You can try to put following code before Astream.Initialize: B4X: If Astream.IsInitialized Then Astream.Close