You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Greetings.
I have tired your BluetoothSerial Chat plugin to transfer set of data from one device to another (android-android and ios-ios).
while testing for android-android, it lists the devices and both are even connected. From device-1 if i send data, it says success. but it is not received in the device-2!
for your reference, i am attaching the screens took while testing in both android devices
Device-1
Device-2
and here is my index.js file
`var app = {
initialize: function() {
this.bindEvents();
this.showMainPage();
},
bindEvents: function() {
var TOUCH_START = 'touchstart';
if (window.navigator.msPointerEnabled) { // windows phone
TOUCH_START = 'MSPointerDown';
}
document.addEventListener('deviceready', this.onDeviceReady, false);
refreshButton.addEventListener(TOUCH_START, this.refreshDeviceList, false);
sendButton.addEventListener(TOUCH_START, this.sendData, false);
disconnectButton.addEventListener(TOUCH_START, this.disconnect, false);
deviceList.addEventListener('touchstart', this.connect, false);
},
onDeviceReady: function() {
app.refreshDeviceList();
},
refreshDeviceList: function() {
bluetoothSerial.list(app.onDeviceList, app.onError);
app.onData();
},
onDeviceList: function(devices) {
var option;
// remove existing devices
deviceList.innerHTML = "";
app.setStatus("");
devices.forEach(function(device) {
var listItem = document.createElement('li'),
html = '<b>' + device.name + '</b><br/>' + device.id;
listItem.innerHTML = html;
if (cordova.platformId === 'windowsphone') {
// This is a temporary hack until I get the list tap working
var button = document.createElement('button');
button.innerHTML = "Connect";
button.addEventListener('click', app.connect, false);
button.dataset = {};
button.dataset.deviceId = device.id;
listItem.appendChild(button);
} else {
listItem.dataset.deviceId = device.id;
}
deviceList.appendChild(listItem);
});
if (devices.length === 0) {
option = document.createElement('option');
option.innerHTML = "No Bluetooth Devices";
deviceList.appendChild(option);
if (cordova.platformId === "ios") { // BLE
app.setStatus("No Bluetooth Peripherals Discovered.");
} else { // Android or Windows Phone
app.setStatus("Please Pair a Bluetooth Device.");
}
} else {
app.setStatus("Found " + devices.length + " device" + (devices.length === 1 ? "." : "s."));
}
},
connect: function(e) { alert('1');
var onConnect = function() {
// subscribe for incoming data
bluetoothSerial.subscribe('\n', app.onData, app.onError);
resultDiv.innerHTML = "";
app.setStatus("Connected");
app.showDetailPage();
};
var deviceId = e.target.dataset.deviceId;
if (!deviceId) { // try the parent
deviceId = e.target.parentNode.dataset.deviceId;
}
bluetoothSerial.connect(deviceId, onConnect, app.onError);
},
onData: function(data) { // data received from Arduino
alert("data="+data);
resultDiv.innerHTML = resultDiv.innerHTML + "Received: " + data + "<br/>";
resultDiv.scrollTop = resultDiv.scrollHeight;
},
sendData: function(event) { // send data to Arduino
//connect();
var success = function() {
alert("success");
resultDiv.innerHTML = resultDiv.innerHTML + "Sent: " + messageInput.value + "<br/>";
resultDiv.scrollTop = resultDiv.scrollHeight;
};
var failure = function() {
alert("Failed writing data to Bluetooth peripheral");
};
var data = messageInput.value;
bluetoothSerial.write(data, success, failure);
},
disconnect: function(event) {
bluetoothSerial.disconnect(app.showMainPage, app.onError);
},
showMainPage: function() {
mainPage.style.display = "";
detailPage.style.display = "none";
},
showDetailPage: function() {
mainPage.style.display = "none";
detailPage.style.display = "";
},
setStatus: function(message) {
alert("message="+message);
window.clearTimeout(app.statusTimeout);
statusDiv.innerHTML = message;
statusDiv.className = 'fadein';
// automatically clear the status with a timer
app.statusTimeout = setTimeout(function () {
statusDiv.className = 'fadeout';
}, 5000);
},
onError: function(reason) {
alert("ERROR: " + reason); // real apps should use notification.alert
}
};`
my problem is, data not received in the device-2.
Thanks in advance. :)
The text was updated successfully, but these errors were encountered:
@PriyankaRose Currently can't connect Android to Android. You can pair two Android devices, but unless one of them opens provides Serial Port Profile, you're not going to be able to connect. This plugin doesn't currently support incoming connections. Some of the other github issues may point to forks from other users that fix this. #50 (comment) It's technically possible, I just haven't implemented it and no one has submitted a pull request.
Android to iOS is not possible with this plugin. Android uses Bluetooth Classic and iOS uses Bluetooth Low Energy.
You could do iOS to iOS (or Android) is the other device implements one of the UART-like BLE SPP services. #75 (comment) You'd need to implement the BLE service with native code. I don't think there's a Corodva plugin for that yet.
hi Don,
Greetings.
I have tired your BluetoothSerial Chat plugin to transfer set of data from one device to another (android-android and ios-ios).
while testing for android-android, it lists the devices and both are even connected. From device-1 if i send data, it says success. but it is not received in the device-2!
for your reference, i am attaching the screens took while testing in both android devices
![screenshot_2016-04-16-12-35-00](https://cloud.githubusercontent.com/assets/6791896/14579685/50e9a6f4-03d0-11e6-8c1d-cc70b1eb3557.png)
![screenshot_2016-04-16-12-35-34](https://cloud.githubusercontent.com/assets/6791896/14579687/51e83098-03d0-11e6-9990-33f26839781e.png)
![screenshot_2016-04-16-12-35-40](https://cloud.githubusercontent.com/assets/6791896/14579688/5215a6ae-03d0-11e6-957b-61502353af04.png)
![screenshot_2016-04-16-12-35-48](https://cloud.githubusercontent.com/assets/6791896/14579689/5215ba0e-03d0-11e6-9c6c-d634ca2a9970.png)
![screenshot_2016-04-16-12-35-56](https://cloud.githubusercontent.com/assets/6791896/14579686/50fcc0cc-03d0-11e6-97d6-1fb7cb585c0e.png)
Device-1
Device-2
![screenshot_2016-04-16-12-35-19-483](https://cloud.githubusercontent.com/assets/6791896/14579692/66ccc6a4-03d0-11e6-84f1-81ec53613242.jpeg)
![screenshot_2016-04-16-12-35-27-799](https://cloud.githubusercontent.com/assets/6791896/14579691/66b82b40-03d0-11e6-8b73-ed8a90af6e26.jpeg)
and here is my index.js file
`var app = {
initialize: function() {
this.bindEvents();
this.showMainPage();
},
bindEvents: function() {
};`
my problem is, data not received in the device-2.
Thanks in advance. :)
The text was updated successfully, but these errors were encountered: