I have my gear s2 watch (tizen 2.3.2) connected to my samsung galaxy s3 (android 4.3) over bluetooth using Tizen Bluetooth API. Using the MAC address of the phone, I am able to "discover" 16 different UUIDs, including 0000111F-0000-1000-8000-00805F9B34FB, the UUID for the HFP service, as I understand. But when I attempt to connect to that service, I get no response, neither the successCallback nor the errorCallback. Interestingly, doing the same for the Serial Port UUID (1101), I'm able to connect to the service and even get messages through the socket when my phone receives a call or text, no problem. So, why do I get no response when attempting to connect to the Hands-free service (UUID 111F)?
Here's the code I'm using:
function getPhoneBatteryLevel()
{
try {
writeLog("Initializing.");
bluetoothAdapter = tizen.bluetooth.getDefaultAdapter();
bluetoothAdapter.getDevice("50:A4:C8:D4:95:E2",onGetDeviceSuccess,onGetDeviceError);
writeLog("Looking for device.");
}
catch (err)
{writeLog("getPhoneBatteryLevel-ERROR:"+err);}
}
function onGetDeviceSuccess(device)
{
try {
if (device.isBonded && device.isConnected){
writeLog("Found connected Device.");
var uuidStr="";
for (var i=0;i<device.uuids.length;i++)
{
if (device.uuids[i].substr(4,4)==="111F")
{
uuidStr = device.uuids[i];
writeLog("Found UUID at "+i+":"+uuidStr);
break;
}
}
if (uuidStr.length>0)
{
device.connectToServiceByUUID(uuidStr, onServiceConnectSuccess, onServiceConnectError);
writeLog("Attempted Connect To Service.");
}
}
else {
writeLog("Device not connected.");
}
}
catch (err)
{writeLog("onGetDeviceSuccess-ERROR:"+err);}
}
function onServiceConnectSuccess(socket)
{
writeLog("Connected to service UUID="+socket.uuid);
}
After running this code, my log file looks like this:
Initializing.
Looking for device.
Found connected Device.
Found UUID at 6:0000111F-0000-1000-8000-00805F9B34FB
Attempted Connect To Service.
and that's it... I expected/hoped to also see "Connected to service UUID=0000111F-0000-1000-8000-00805F9B34FB" upon a successful connection via the successCallback..or at least a similar error written to the log via the errorCallback, but I got neither. Yet, the hands-free service appears to be running on the phone. And of course, when the phone is in my car, the hands free functions work fine, so I know the phone supports it. Where am I going wrong?
UPDATE: After a few more tests, I have some additional clues. I have two devices: an iPhone S5 (iOS 11.2.6) and a Galaxy S3 (android 4.3). After "discovering" and connecting to each, I was able to loop through the services (uuids). 0x111F is on both. And there are several other uuids that these two devices have in common. I tried connecting to all of these common services on both devices. The results relative to the two devices were identical - on both, I was able to connect to some services, got NotFound errors on others and on the one I'm really interested in, I got no callback at all. So, allow me to refine my question. I was able to connect to the following services that my two devices have in common: 110A [A2DP], 110C [AVRCP], 112F [PBAP], 1132[MAP]
But, even though UUID 0x1200 is in both devices' lists of available UUIDS, the response to my attempt to connect to the service called my errorCallBack routine with a "Not Found" error. This happened on both devices. Why would this be Not Found when it was in the list of valid UUIDs?
And most disappointing of all (to me, anyway), is that I still get no response at all (no success callback and no error callback) when I attempt to connect to the Hands Free Profile service, 0x111F. Why wouldn't I get a response - either a success call back or an error call back?