macroyau / blue2serial Goto Github PK
View Code? Open in Web Editor NEWA simple Android library for implementing Bluetooth Serial Port Profile (SPP) communication.
License: MIT License
A simple Android library for implementing Bluetooth Serial Port Profile (SPP) communication.
License: MIT License
Once I send the bytes with value of 128 to 255 by Bluetooth to Android then I see different bytes. I receive -17, -65, -67 instead of 128 to 255. But, it works with 0 to 127. Something happens to "(byte[]) msg.obj" with negative values in the
private final Handler mHandler = new Handler()
in the section
case MESSAGE_READ:
byte[] bufferRead = (byte[]) msg.obj;
Would you please resolve it?
Best regards
Hamid Naghizadeh
Connection got disconnect when app is in background and do not reconnect when resumed again.
Hello.
Great library btw. I don't want to modify your library, I like using it with gradle.
Can you please make an update so that onBluetoothSerialWrite and onBluetoothSerialRead have a byte[] parameter, instead of String?
It would help me a lot. I am using bytes processing and by converting them from String some of the bytes get messed up.
Thank you.
I think something needs to be changed here:
case MESSAGE_WRITE:
byte[] bufferWrite = (byte[]) msg.obj;
String messageWrite = new String(bufferWrite);
mListener.onBluetoothSerialWrite(messageWrite);
break;
case MESSAGE_READ:
byte[] bufferRead = (byte[]) msg.obj;
String messageRead = new String(bufferRead);
mListener.onBluetoothSerialRead(messageRead);
break;
This is in BluetoothSerial.java
This project has some outdated libraries and some reference errors. At first I change the build.gradle script for the latest libraries that one of them was 'com.afollestad:material-dialogs' and the script had no problems but then a ListCallback error was found while compiling. The error was the following:
I tried few things like calling the class builder by reference or creating a local object of the function but due to my inexperienced skills I was unable to resolve the root of the problem. Has the author or anyone have some plans to update this project?
Is there are ways to set different Baudrates?
My App works with 115200 but if i change the baudrate on my BT Datalogger, my App cant communicate anymore.
Hi, I use this library and It helped me a lot. Is it possibile to auto connect to the device , when the app is open?
How to scan and paired device?
It is asking for choose paired device and and use of CRLF/?
Need help
Hello
This works perfectly if i wanna connect to a paired device. How can i show results new (scanned) devices and conntect to them.
In your example code I found only paired soulution
Once I upload it in the tablet or android phone then it pops up a dialogue box on the tablet or phone says " Unfortunately, Blue2Serial has stopped". I attached the output log.
It was working before, but I think once Android Studio asked to upgrade, then it's happened after upgrading!
ScreenShot.pdf
Please help me to find the issue.
First of all, thanks for developing this.
I was testing your app with a bluetooth barcode scanner in SPP profile. Unfortunately, it keeps breaking the string up in arbitrary parts. Usually the first few characters will be considered a different message than the rest of the barcode.
Do you know of why this might be?
Hi,
I have a bluetooth barcode reader and have connected it to my app using Blue2Serial. When I scan it and read the message String from onBluetoothSerialRead(), not every time I get the whole number.
Suppose the bar code is "MN000012HA". Sometimes when I scan I get "MN". Sometimes "00012" and sometimes the right number.
Can anyone please help me with that? I have configured the barcode reader to SPP mode.
Thanks
Hi, can this be used to connect to multiple devices? I am doing a school project and need this info urgently. I tried with no success. Can anyone give me some sample code on how to do this?
Thanks in advance!
Hi
I'm trying to use this library and example app to connect two paired Android phones. But each time I click on "Connect" it just goes "Connecting..." and then "Disconnected"
Is it possible to connect between two Android phone using this library?
Hello Guys, great work you done.
We had for last Days some trouble with this API. Its exactly Issue#9. You wrote that you fixed it but it was not fixed.
Problem: If our App recieve byte 128 (hax 80), this lib read it as -128 and wrong hex.
We all know this happen because of signed Bytes in Java.
Workaround: SPPService.java
Replace this:
mHandler.obtainMessage(BluetoothSerial.MESSAGE_READ, bytes, -1, read.getBytes()).sendToTarget();
with this
mHandler.obtainMessage(BluetoothSerial.MESSAGE_READ, bytes, -1, read.getBytes(StandardCharsets.US_ASCII)).sendToTarget();
If you do this changes, issue like #9 never happen again. In most of usecases with SPP we think US_ASCII as default is much better....
Great work keep on.
Hello,
I have my function in MainActivity:
public void send(String value) { String send = value.trim(); if (send.length() > 0) { try { bluetoothSerial.write(send); } catch(Exception e) { e.printStackTrace(); } } }
It's sending well when I call it from this MainActivity.
But, when I call it from my class "LaunchGame" (which is an extended class of MainActivity), it's sending nothing and I have no error...
Someone already had this kind of error ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.