Comments (11)
Can I see the code you are using to send the image? What exactly is missing from the message you are sending?
from simplebluetoothlibrary.
Is the issue similar to #14 ?
from simplebluetoothlibrary.
yes its similar....i will send the code...
from simplebluetoothlibrary.
here's the code
` simpleBluetooth.initializeSimpleBluetooth();
simpleBluetooth.setInputStreamType(BluetoothUtility.InputStreamType.BUFFERED);
simpleBluetooth.setSimpleBluetoothListener(new SimpleBluetoothListener() {
@Override
public void onBluetoothDataReceived(byte[] bytes, String data) {
//Log.d(TAG + "incoming data", data);
// result = result + data;
//db.AddFriend(fp.friend());
Log.d(TAG, data);
try{
toParse = data.split(":");
byte[] im = Base64.decode(toParse[4], Base64.CRLF);
Log.d("decoder", "decoder");
Bitmap bit = BitmapFactory.decodeByteArray(im, 0, im.length);
}catch (Exception e){
e.printStackTrace();
}
//friendParser fp = new friendParser(result);
//Log.d(TAG, String.valueOf(bytes.length));
isConnected=false;
//read the data coming in.
}
`
from simplebluetoothlibrary.
Thanks for the code.
I would try this without using the buffered stream type. When you set the stream type to buffered, the library will be looking for a newline character and will not report the results in onBluetoothDataReceived
until a new line character is reached which is more than likely why you're losing data since I'm assuming there is no \n
in your image data.
Try that and update this issue with the results.
from simplebluetoothlibrary.
ok thanks very much..i'll do that
from simplebluetoothlibrary.
I tested the solution it gives the full data when i added the escape character \n
but i noticed that while the data is being read it overrides the previous data argument on the received method. Is there a way it can send the data after all has been collected? my work around was to create a global string which i concatenate the data received to the global variable. Heres the code
` simpleBluetooth.initializeSimpleBluetooth();
simpleBluetooth.setInputStreamType(BluetoothUtility.InputStreamType.BUFFERED);
simpleBluetooth.setSimpleBluetoothListener(new SimpleBluetoothListener() {
@Override
public void onBluetoothDataReceived(byte[] bytes, String data) {
//Log.d(TAG + "incoming data", data);
result = result + data;
//db.AddFriend(fp.friend());
Log.d(TAG, data);
toParse = result.split(":");
Log.d(TAG, String.valueOf(toParse.length));
i = toParse.length;
if(i == 6){
Log.d(TAG, "called");
try{
Log.d(TAG, "called");
friendParser fp = new friendParser(result);
db.AddFriend(fp.friend());
/*toParse = data.split("LIFE");
byte[] im = Base64.decode(toParse[4], Base64.CRLF);
Bitmap bit = BitmapFactory.decodeByteArray(im, 0, im.length);
*/
}catch (Exception e){
e.printStackTrace();
}
}
`
from simplebluetoothlibrary.
Maybe I wasn't clear in my previous post. What I meant to do is change the line:
simpleBluetooth.setInputStreamType(BluetoothUtility.InputStreamType.BUFFERED);
to the following:
simpleBluetooth.setInputStreamType(BluetoothUtility.InputStreamType.NORMAL);
from simplebluetoothlibrary.
Did that work?
from simplebluetoothlibrary.
yes it did, sorry was suppose to close the issue. thanks for the support
SmileCs past3.com.ng
On 21 Mar 2016 13:08, "DeveloperPaul123" [email protected] wrote:
Did that work?
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#22 (comment)
from simplebluetoothlibrary.
No problem. Thanks for using my lib.
from simplebluetoothlibrary.
Related Issues (20)
- Issue with Device to Device Communication HOT 8
- Switch to JitPack.io HOT 1
- Add support for minimum SDK 14 HOT 4
- Receiving partial data from Arduino HOT 10
- device not avaible error HOT 2
- Add Marshmallow support HOT 2
- Unable to send to Arduino HOT 3
- Create new sendData(byte[] bytes) method HOT 3
- Silent enableBluetooth() method HOT 6
- Initialize with flag to disable toast messages HOT 8
- Update support library 23.2.0 HOT 6
- Data not complete HOT 40
- BluetoothUtility.closeConnections() crashes HOT 3
- Update to latest libs HOT 1
- Nexus 5 doesn't scan any devices HOT 2
- can i use this library to read Glucose reading device , HOT 3
- Data Lossed with arduino HOT 6
- failed to resolve: com.afollestad.material-dialogs:core:0.8.5.6 HOT 1
- error: incompatible types: <anonymous SimpleBluetoothListener> cannot be converted to Activity HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplebluetoothlibrary.