Languages

Menu
Sites
Language
Central - Peripharal / Client - Server Architecture, BLE communication Tizen Wearable with iOS not working

Hi all,

My requirement is to create a Application which can transfer data / text from Tizen Wearable to iOS App. To accomplish this requirement i created a BLE communication architecture i.e. central - peripharal. So issue here is:

1. iOS Central - Tizen Peripharal :   In this Tizen Peripharal register a service to adapter and Advertise the same service to be scanned. I received the advertised service on central but registered service is not received on central side when i scan for services. Here is some code :

 

var adapter2 = tizen.bluetooth.getDefaultAdapter();

var CHAT_SERVICE_UUID = "5BCE9431-6C75-32AB-AFE0-2EC108A30860";

 

function chatServiceSuccessCb(recordHandler)

{

  console.log("Chat service registration succeeds!");

  chatServiceHandler = recordHandler;

}

 

function publishChatService()

{

  adapter2.registerRFCOMMServiceByUUID(CHAT_SERVICE_UUID, "Chat service", chatServiceSuccessCb,

      function(e)

      {

        console.log("Could not register service record, Error: " + e.message);

      });

}

 

publishChatService();

 

var adapter = tizen.bluetooth.getLEAdapter();

var advertiseData = new tizen.BluetoothLEAdvertiseData({

    includeName: true,

    uuids: [CHAT_SERVICE_UUID]

});

var connectable = true;

adapter.startAdvertise(advertiseData, 'ADVERTISE', function onstate(state) {

    console.log('Advertising configured: ' + state);

}, function(error) {

    console.log('startAdvertise() failed: ' + error.message);

}, 'LOW_LATENCY', connectable);

 

 

 

2. iOS Peripharal - Tizen Central : This time i created peripharal on iOS side, created the same service, advertised the service. I received the advertised data on Tizen side. I connect to remote device, Connection success listener called. Now when i try to connect to service i receive exception i.e. device not connected exception.

In code remoteDevice.getService(remoteDevice.uuids[0]) create exception while remoteDevice.addConnectStateChangeListener(onConnectionStateChange); these listeners never get called.

Here is some code:

 

function connectFail(error) {

    console.log('Failed to connect to device: ' + error.message);

}

 

function connectSuccess() {

    console.log('Connected to device');

    var serviceUUIDs = remoteDevice.uuids;

    console.log('total number of services found here are: ' + serviceUUIDs.length);

    service = remoteDevice.getService(remoteDevice.uuids[0]);

    console.log('flag next step 1');

}

 

function onerror(e)

{

  console.log("Error occurred: " + e.message);

}

 

function onDeviceFound(device)

{

  console.log("Found new device: " + device.name);

  var onConnectionStateChange =

  {

    onconnected: function(device)

    {

            heartrateVal.innerHTML = 'connected';

      console.log("Device " + device.name + " connected");

    },

    ondisconnected: function(device)

    {

      console.log("Device " + device.name + " disconnected");

      device.removeConnectStateChangeListener(listenerID);

    }

  };

 

  if (device.name === "aBcD")

  {

    remoteDevice = device

    console.log("Found required device: " + device.name);

    listenerID = remoteDevice.addConnectStateChangeListener(onConnectionStateChange);

    remoteDevice.connect(connectSuccess, connectFail);

    adapter.stopScan();

  }

}

 

var adapter = tizen.bluetooth.getLEAdapter();

var listenerID = null;

adapter.startScan(onDeviceFound, onerror);

 

 

 

I have tested my iOS application with another iOS application as well as android application which works fine. But with tizen i face these issues. I am not sure is there any issue in Tizen SDK or Tizen BLE works in different way than the iOS and android.

 

Note: All above mentioned code are from the Tizen Samples and API specifications. few links are

https://developer.tizen.org/dev-guide/2.3.1/org.tizen.sampledescriptions/html/mobile_w/bluetoothchat_mw.htm

https://developer.tizen.org/development/guides/web-application/connectivity-and-wireless/bluetooth

 

Thanks in advance.

Edited by: Jaideep Kumar on 10 Oct, 2019