Hi, I want to send acquired sensor data to android app(cellphone act as Server) through bluetooth. The watch was paired with my cellphone already. So, I want to send data from watch to my paired cellphone. However, there is only a few infomation I could find from Tizen Document.Bluetooth API
Thus, I want to ask that if there’s any extra data or demo I can learn from? Especially RFCOMM service, because I wrote RFCOMM in my android app. And I tried but the android app can not receive any data.
Thanks!!!
And, here’s my code:
var adapter = tizen.bluetooth.getDefaultAdapter();
var deviceAddress = "40:B8:37:94:1C:B9";//Xperia Z5 Premium
var SERVICE_UUID = "00001105-0000-1000-8000-00805F9B34FB";//00001101-0000-1000-8000-00805F9B34FB:ALVIN//00001105-0000-1000-8000-00805F9B34FB
var clientSocket = null;
var msg = "hello day";
//Execution.
if (adapter.powered){
console.log("Bluetooth is already enabled");
adapter.getDevice(deviceAddress, onDeviceReady, function(e){
console.log("Error: " + e.message);
});
}
else{
console.log("Try to launch the Bluetooth Settings application");
tizen.application.launchAppControl(bluetoothSwitchAppControl, null, launchSuccess, launchError, serviceReply);
}
function onDeviceReady(device){//cellphone
// Validates device and service uuid
if (device.uuids.indexOf(SERVICE_UUID) != -1){
adapter.registerRFCOMMServiceByUUID(SERVICE_UUID, 'My Service', ServiceSuccessCb,
function(e) {
console.log( "Could not register service record, Error: " + e.message);
});
}
else{
console.log("Chat service is not supported by this device");
}
function ServiceSuccessCb(){
device.connectToServiceByUUID(SERVICE_UUID, function(sock) {
console.log('socket connected');
clientSocket = sock;
var somemsg = [3, 2, 1];
if(clientSocket.writeData(somemsg)){
console.log("sendMessage Success");
}
}, function(error){
console.log('Error while connecting: ' + error.message);
});
}
}