Мое требование - создать приложение, которое переносит текст с устройства iOS на Tizen Wearable. Согласно документам tizen я использовал BLE для общения. С нашей стороны архитектура будет Tizen как центральная и iOS как периферийная, где начальное соединение будет от tizen до iOS приложения.
Для 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);
Для iOS BLE-соединения:
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
}
При реализации remoteDevice.getService (remoteDevice.uuids [0]) код Я получаю ошибку устройство не найдено исключение.
Эта же проблема была опубликована в этой ссылке также: https://developer.tizen.org/ko/forums/web-application-development/central-peripharal-client-server-architecture-ble-communication-tizen-wearable-ios-not-working?langredirect=1
Если кто-то сталкивался с подобной проблемой и обнаружил Требуемое решение, пожалуйста, предоставьте ваши ценные материалы, так как это своего рода блокиратор с нашей стороны.
Заранее спасибо.