BluetoothSerial
BluetoothSerial copied to clipboard
Multiple connections
Just create context in order to allow multiple connections. It keeps full backward compatibility with the original version.
Is there any example that can POC multi connection? I've already try too many times, still not working now.
It's only working on Android.
Here is the small ionic project I created to test it. https://github.com/Shikoruma/blueserialtest
I hope it will help you.
@Shikoruma WOW~ Hey dude, you are pretty fast, I am not sure that ionic could porting to cordova directly,
my goal is to create 2 serial port connection over bluetooth, this is my testing code snippet
In my case, when I start the second connection, the first connection will be colsed.
Thanks .
Ionic plugin are in fact cordova plugin.
From your code snippet I don't see were the error is comming from. Are you sure you're giving two different addresses ?
I cant test your code with just the js file
Oops, belowing are my whole cordova project file. bluetooth-serial-test.zip
Thanks a again. I'm very appreciate for your help.
Ok I found my mistake.
isConnected take also a macAdress because you want to test a particular connection. I forgot to change de Readme for this function, I update it. So change your bluetoothSerial.isConnected(disconnect, connect); to bluetoothSerial.isConnected(disconnect, connect,app.macAddress2);
I also forget to test if the given address is actualy in the context map. I also fixed it, so update my plugin and it should work now.
Thank you for pointing that issue.
Hi, Shikoruma I'm @hypery11 's co-worker, We have problem on a SPP Client Project (It work's now) But I have a question
when I use function openPort in your example there has 4 arg -> delimeter , success call back , fail call back , macAddress so , I write
app = { ... openPort: function() {
app.display("Connected to: " + app.macAddress);
connectButton.innerHTML = "Disconnect";
bluetoothSerial.subscribe('\n',
function (data) {
app.clear();
app.display(data);
},app.showError,app.macAddress);
},
openPort2: function() {
app.display("Connected to: " + app.macAddress2);
connectButton.innerHTML = "Disconnect";
bluetoothSerial.subscribe('\n',
function (data) {
app.clear();
app.display(data);
},app.showError2,app.macAddress2);
}, ... }
this code is no work for me, when I connect the first device, It works , but when I connect the second device, the first will lost connect ...
BUT !!!
When we change to this code
app = { ... openPort: function() {
app.display("Connected to: " + app.macAddress);
connectButton.innerHTML = "Disconnect";
bluetoothSerial.subscribe('\n',
function (data) {
app.clear();
app.display(data);
},app.macAddress)//different here!! ;
},
openPort2: function() {
app.display("Connected to: " + app.macAddress2);
connectButton.innerHTML = "Disconnect";
bluetoothSerial.subscribe('\n',
function (data) {
app.clear();
app.display(data);
},app.macAddress2) //different here;
}, ... }
Strangely, It works @@".... But, I can not find any problem in your java source and javascript lib (it's actually 4 args...)
Anyway, thanks for your help @w@/
Thank you for the PR - there are a couple of merge conflicts. Appreciate you making this PR! <3
Try this plugin https://github.com/bugnano/cordova-plugin-networking-bluetooth
Try this plugin bugnano/cordova-plugin-networking-bluetooth
@lovelyelfpop Does that support multiple clients connect to a host?
@filipef101 Doesn't that depend on the host?
@bittelc I think this looks good. What do you think @dominiquejb
Ya, looks fine to me @braedongough , let's send it through.