언어 설정

Menu
Sites
Language
Tizen Watch and iOS Connectivity Problems

Hi all,
My requirement is to create an application which transfer text from iOS device to Tizen Wearable. As per tizen documents I have used BLE for communication.
On our end architecture would be Tizen as central and iOS as peripheral where initial connection will be from tizen to iOS app.

For Tizen :
var remoteDevice = null;
var adapter = tizen.bluetooth.getLEAdapter();

function onDeviceFound(device) {
    if (remoteDevice === null) {
        remoteDevice = device;
        console.log('Found device ' + device.name + '. Connecting...');

        device.connect(connectSuccess, connectFail);
    }

    adapter.stopScan();
}

function connectFail(error) {
    console.log('Failed to connect to device: ' + e.message);
}

function connectSuccess() {
    console.log('Connected to device');
    var serviceUUIDs = remoteDevice.uuids;
    var gattService = remoteDevice.getService(serviceUUIDs[0]); //error in this one
    var property = gattService.characteristics[0];
}

adapter.startScan(onDeviceFound);

 

For iOS BLE connection:

private func setupPeripheral() {
   let transferCharacteristic = CBMutableCharacteristic(type: TransferService.characteristicUUID,
                                                     properties: [.notify, .writeWithoutResponse],
                                                     value: nil,
                                                     permissions: [.readable, .writeable])
    
    let transferService = CBMutableService(type: TransferService.serviceUUID, primary: true)
    transferService.characteristics = [transferCharacteristic]
    peripheralManager.add(transferService)
    self.transferCharacteristic = transferCharacteristic
}

peripheralManager.startAdvertising([CBAdvertisementDataServiceUUIDsKey: [TransferService.serviceUUID]])

 func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
        switch peripheral.state {
        case .poweredOn:
            os_log("CBManager is powered on")
            setupPeripheral()
        case .poweredOff:
            os_log("CBManager is not powered on")
            return
        case .resetting:
            os_log("CBManager is resetting")
            return
        case .unauthorized:
           os_log("Unexpected authorization")
            return
        case .unknown:
            os_log("CBManager state is unknown")
            return
        case .unsupported:
            os_log("Bluetooth is not supported on this device")
            return
        @unknown default:
            os_log("A previously unknown peripheral manager state occurred")
            return
        }
    }
    func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didSubscribeTo characteristic: CBCharacteristic) {

  os_log("Central subscribed to characteristic")
        connectedCentral = central
    }
    func peripheralManager(_ peripheral: CBPeripheralManager, central: CBCentral, didUnsubscribeFrom characteristic: CBCharacteristic) {
        os_log("Central unsubscribed from characteristic")
        connectedCentral = nil
    }

 

By implementing remoteDevice.getService(remoteDevice.uuids[0]) code I am getting error device not found exception.

 

Same issue has been posted in this link also:
https://developer.tizen.org/ko/forums/web-application-development/central-peripharal-client-server-architecture-ble-communication-tizen-wearable-ios-not-working?langredirect=1.

 

If someone have faced similar kind of challenge and found required solution then please provide your valuable inputs as it is kind of blocker on our end.

 

Thanks In advance.

 

Edited by: WLI Dev on 13 3월, 2020