New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropped or swapped characters #9
Comments
It is possible the problem is that the plugin is treating the Bluetooth data as a String and some of your data is incompatible or being encoded incorrectly. If you have some sample code I could run that might help troubleshoot the issue. |
Hey Don, We're interfacing with some hardware that will send as csv (or with any seperating character). Currently my Arduino is just sending dummy data:
I've just made minor adjustments to your current code (specifically, the subscribe part)
Where convertArray just returns into array via str.split(","); I'm reading console.log via adb logcat -s "CordovaLog" Sample output:
Here are the files: You'll need to edit with your BT MAC address. Any help would be appreciated. |
Hi don, We are still experiencing problems with your plugin. For the record, the arduino is sending out "ASCII" encoded strings, and the javascript app is just reading whatever your plugin sent as a "string" via the subscribe method. Does the subscribe method use the buffer or not? This is because we used your chat example, of which we sent less than 4 char strings per 100ms, but yet we still got swapped characters (If the buffer has been filled completely, shouldn't we be getting dropped characters only, not swapped? what about when I sent "1234" and got "2234"... weird). This is since we are sending data at a rate of 9600 baud rate, and on going though your java code on the buffer ( stringbuffer() specifically), we found that you by default use a buffer of 16 characters. I don't know if this would be a solution to us, would it be theoretically be possible to solve this issue by changing "stringbuffer()" to increase buffer size to something larger? (according to http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/StringBuffer.html , you can change buffer to 100 by "stringbuffer(100)") Oh and apologies if the cause or solution is obvious, we are newbies to javascript and phonegap. -BK |
I haven't had a chance to try your code and debug the problem yet. I'll try
|
I'm having exactly the same problem. cheers, |
I have been putting this off so far, working on other parts of our code. I think it could be a buffer size problem. Going to try clearing the buffer after each received string or increase the buffer size next week. We were using the subscribe function for the first test code, perhaps other code is somehow stuttering the app, causing the bluetooth library to run irregularly. @manorius how fast were you sending your data? Baud rate and OS? If you could send me your code I could give it a test? @don any luck with taking a look at this? Also, could you provide some sample code for read/readUntil/available and buffer? |
Other than that, our team was planning on incorporating a CRC within each line for error detection. Our app is proof of concept (before we go native) but it would be great if this corruption was resolved, as Phonegap works great for us otherwise. We're also moving from a HC05 bluetooth to RN42 by Roving Networks |
@jiandu baud is 9600 and I just found a workaround to my problem.
But if I add a line feed before my data I don't get any errors and no character swapping
cheers, |
Does it also work if your data is longer? say, 32 characters long? |
@jiandu I tried, and I've noticed errors occurring more frequently... even with the line feed.... |
@jiandu @manorius sorry this fix took so long The data was being corrupted while it was being passed in the android.os.Message from BluetoothSerialService to BluetoothSerial. I guess passing a byte[] in a Message is a bad idea. Maybe the original was being overwritten? I updated the code to create the String in the Service and pass the String in the message. It appears to be working without corruption now. Hopefully this fixes the problem for you too. |
Hi Don, I will try this out and report back ASAP. Thanks for this. JD |
I can confirm this issue is fixed, thanks Don! |
@McSodbrenner This might be a problem with PhoneGap build. Unfortunately it's really painful to get updates pushed to build. Any chance you could try using Cordova locally? I'm going to release 0.2.3. momentarily. This includes additional fixes that might help. |
Sorry, I am a beginner at Phonegap and don't want to have the hassle with Phonegap and the SDKs. But it is not urgent. I can wait for a couple of weeks and have a look then. :) Thanks, |
phonegap build has 0.2.2 |
Does not work. :) Hoping for .0.2.3. |
Hello,
I am using Phonegap/this plugin/js for the first time to send Arduino serial data to an app.
Using the SimpleSerial example (bluetoothSerial.subscribe), I am seeing some issues with some lines being corrupted (swapped/removed/added characters in the received string).
Below is received data sent to console.log (viewed on comp w/adb logcat)
This issue doesn't exist when using a Bluetooth app downloaded from the Play store.
Thanks
Built with Cordova 2.7.6
Device Samsung Galaxy S2
Android 4.0.3
Baud rate 9600
BT chipset: http://www.elecfreaks.com/store/download/datasheet/Bluetooth/Bluetooth%20HC-06.pdf
The text was updated successfully, but these errors were encountered: