Skip to content

Commit

Permalink
Fixed issue with not sent data over UART: set connect write type.
Browse files Browse the repository at this point in the history
Removed xcworkspace as we use SPM.
Set filter by UART Service UUID on scanner device in UART section.
  • Loading branch information
NickKibish committed Aug 31, 2021
1 parent ac2d70d commit c260ec0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
6 changes: 3 additions & 3 deletions nRF Toolbox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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 = (
Expand Down
10 changes: 0 additions & 10 deletions nRF Toolbox.xcworkspace/contents.xcworkspacedata

This file was deleted.

10 changes: 5 additions & 5 deletions nRF Toolbox/BluetoothManager/BluetoothManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)")

}
Expand Down
2 changes: 1 addition & 1 deletion nRF Toolbox/Profiles/UART/UARTTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c260ec0

Please sign in to comment.