From c260ec09b74af48d6d551d72f95461e49eb78b03 Mon Sep 17 00:00:00 2001 From: Nick Kibysh Date: Tue, 31 Aug 2021 16:11:19 +0200 Subject: [PATCH] Fixed issue with not sent data over UART: set connect write type. Removed xcworkspace as we use SPM. Set filter by UART Service UUID on scanner device in UART section. --- nRF Toolbox.xcodeproj/project.pbxproj | 6 +++--- nRF Toolbox.xcworkspace/contents.xcworkspacedata | 10 ---------- nRF Toolbox/BluetoothManager/BluetoothManager.swift | 10 +++++----- nRF Toolbox/Profiles/UART/UARTTabBarController.swift | 2 +- 4 files changed, 9 insertions(+), 19 deletions(-) delete mode 100644 nRF Toolbox.xcworkspace/contents.xcworkspacedata diff --git a/nRF Toolbox.xcodeproj/project.pbxproj b/nRF Toolbox.xcodeproj/project.pbxproj index ed5d2dc1..bc3ae939 100644 --- a/nRF Toolbox.xcodeproj/project.pbxproj +++ b/nRF Toolbox.xcodeproj/project.pbxproj @@ -2323,7 +2323,7 @@ "$(PROJECT_DIR)", "$(PODS_ROOT)", ); - MARKETING_VERSION = 5.0.3; + MARKETING_VERSION = 5.0.4; NEW_SETTING = ""; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( @@ -2490,7 +2490,7 @@ "$(PROJECT_DIR)", "$(PODS_ROOT)", ); - MARKETING_VERSION = 5.0.3; + MARKETING_VERSION = 5.0.4; NEW_SETTING = ""; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = ( @@ -2541,7 +2541,7 @@ "$(PROJECT_DIR)", "$(PODS_ROOT)", ); - MARKETING_VERSION = 5.0.3; + MARKETING_VERSION = 5.0.4; NEW_SETTING = ""; ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = ( diff --git a/nRF Toolbox.xcworkspace/contents.xcworkspacedata b/nRF Toolbox.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 45d202d3..00000000 --- a/nRF Toolbox.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/nRF Toolbox/BluetoothManager/BluetoothManager.swift b/nRF Toolbox/BluetoothManager/BluetoothManager.swift index 589e68d9..7de3795e 100644 --- a/nRF Toolbox/BluetoothManager/BluetoothManager.swift +++ b/nRF Toolbox/BluetoothManager/BluetoothManager.swift @@ -184,7 +184,7 @@ class BluetoothManager: NSObject, CBPeripheralDelegate, CBCentralManagerDelegate // Check what kind of Write Type is supported. By default it will try Without Response. // If the RX charactereisrtic have Write property the Write Request type will be used. - let type: CBCharacteristicWriteType = uartRXCharacteristic.properties.contains(.write) ? .withResponse : .withoutResponse + let type: CBCharacteristicWriteType = uartRXCharacteristic.properties.contains(.writeWithoutResponse) ? .withoutResponse : .withResponse let mtu = bluetoothPeripheral?.maximumWriteValueLength(for: type) ?? 20 // The following code will split the text into packets @@ -231,16 +231,16 @@ class BluetoothManager: NSObject, CBPeripheralDelegate, CBCentralManagerDelegate // Check what kind of Write Type is supported. By default it will try Without Response. // If the RX characteristic have Write property the Write Request type will be used. - let type: CBCharacteristicWriteType = uartRXCharacteristic.properties.contains(.write) ? .withResponse : .withoutResponse + let type: CBCharacteristicWriteType = uartRXCharacteristic.properties.contains(.writeWithoutResponse) ? .withoutResponse : .withResponse let mtu = bluetoothPeripheral?.maximumWriteValueLength(for: type) ?? 20 let data = aCommand.data.split(by: mtu) + log(withLevel: .verbose, andMessage: "Writing to characteristic: \(uartRXCharacteristic.uuid.uuidString)") + let typeAsString = type == .withoutResponse ? ".withoutResponse" : ".withResponse" data.forEach { self.bluetoothPeripheral!.writeValue($0, for: uartRXCharacteristic, type: type) + log(withLevel: .debug, andMessage: "peripheral.writeValue(0x\($0.hexString), for: \(uartRXCharacteristic.uuid.uuidString), type: \(typeAsString))") } - log(withLevel: .verbose, andMessage: "Writing to characteristic: \(uartRXCharacteristic.uuid.uuidString)") - let typeAsString = type == .withoutResponse ? ".withoutResponse" : ".withResponse" - log(withLevel: .debug, andMessage: "peripheral.writeValue(0x\(aCommand.data.hexString), for: \(uartRXCharacteristic.uuid.uuidString), type: \(typeAsString))") log(withLevel: .application, andMessage: "Sent command: \(aCommand.title)") } diff --git a/nRF Toolbox/Profiles/UART/UARTTabBarController.swift b/nRF Toolbox/Profiles/UART/UARTTabBarController.swift index 0c8b8be9..b20d57c3 100644 --- a/nRF Toolbox/Profiles/UART/UARTTabBarController.swift +++ b/nRF Toolbox/Profiles/UART/UARTTabBarController.swift @@ -73,7 +73,7 @@ class UARTTabBarController: UITabBarController { private var emptyView: InfoActionView! let btManager = BluetoothManager() private lazy var bSettings: InfoActionView.ButtonSettings = ("Connect", { [unowned self] in - let scanner = PeripheralScanner(services: nil) + let scanner = PeripheralScanner(services: [CBUUID(string: ServiceIdentifiers.uartServiceUUIDString)]) let vc = ConnectionViewController(scanner: scanner) vc.delegate = self let nc = UINavigationController.nordicBranded(rootViewController: vc)