Post

Replies

Boosts

Views

Activity

CoreBluetooth - peripheral's services missing
I'm hitting an issue with a connected peripheral that was discovered with BLE when that peripheral also happens to be classic BT paired. If that peripheral is not classic BT paired, there is no issue. When calling discoverServices([serviceCBUUID]) the peripheral delegate peripheral:didDiscoverServices: is called without error, but peripheral.services is empty whenever the peripheral happens to also be classic BT paired. How can it be possible to get a callback that services where discovered, yet the peripheral has no services when queried in that callback? Is this a known issue with a workaround? Thanks.
0
0
556
Jun ’22
SwiftUI Table with copy
I've implemented a macOS app that displays a table of records in a document using SwiftUI. However, I want to allow the user to copy selected records. I've tried adding onCopyCommand, but I'm not seeing Edit -> Copy enabled.     HSplitView {     Table(records, selection: $selectedRecordIDs) {      TableColumn("Timestamp", value: \.timestamp.description)      TableColumn("Message", value: \.message)       .width(ideal: columnWeight.message * geometry.size.width)     }     .onCopyCommand {      [NSItemProvider(item: "Hello, World!" as NSString, typeIdentifier: UTType.plainText.identifier)]     } How to enabled Copy? Thanks.
2
0
1.1k
May ’22
Secure BLE L2CAP Channel between iOS and Android
Hi, I'm trying to establish a secure L2CAP channel between and iPhone and Android device. I'm able to do it for an insecure L2CAP channel but not a secure L2CAP channel, and the error that I'm getting back on the iOS side is not useful (Error code: 104, description: Unknown ATT error). Here's what I'm doing on the Android side: serverSocket = adapter.listenUsingL2capChannel() Log.d("DemoService", "startL2CapService socket psm=" + serverSocket.psm) serverSocketExecutor.submit { Log.d("DemoService", "startL2CapService Waiting for a connection...") val socket = serverSocket.accept() Log.d("DemoService", "startL2CapService accepted socket...") } I'm also posting the PSM from the server socket as a GATT characteristic. On the iOS side, I read that characteristic to get the PSM and attempt to open the L2CAP channel: func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) { print("Did update value for characteristic: \(characteristic)") guard let rawValue = characteristic.value else { return } print("raw value: \(rawValue)") let psmInt: Int32 = rawValue.withUnsafeBytes { $0.load(as: Int32.self) } let psm = CBL2CAPPSM(psmInt) print("psm: \(psm)") peripheral.openL2CAPChannel(psm) } If the two devices are not paired, then the pairing workflow gets triggered on the Android side and I pair the two devices. So, I know that my attempt at creating a secure L2CAP channel is at least triggering the secure flow. The problem is that the socket never gets created on the Android side (unless I instead use the insecure version) and on the iOS side, I get an error (Error code: 104, description: Unknown ATT error) in the delegate callback: func peripheral(_ peripheral: CBPeripheral, didOpen channel: CBL2CAPChannel?, error: Error?) { print("Did open channel: \(String(describing: channel?.psm))") if let error = error as NSError? { print("Error code: \(error.code), description: \(error.localizedDescription)") } } I've confirmed that I'm using the correct PSM, and this code will work if I instead listenUsingInsecureL2capChannel on the Android side. Has anyone successfully opened a secure L2CAP channel between iOS and Android? If so, can you point me to the code and/or provide guidance on what I'm doing wrong. Thanks, Tom
0
0
1.6k
Mar ’21
IOUSBHostPipe - Unable to enqueue IO
Hi. I'm hitting an error when attempting to enqueue IO on a IOUSBHostPipe. The error info is: code=268435459, description=<Unable to enqueue IO.> I'm not sure what that error means or how to address it. I'm trying to communicate through a USB Bluetooth dongle. I've done the following: Instantiated a device using IOUSBHostDevice with a service specifying the USB Dongle. I've set the configuration (there's only one) as the active configuration. I've claimed all four interfaces for the active configuration. I've cycled through the endpoints for each interface and used copyPipeWithAddress:error: to copy the pipe. I've stored those pipes in a dictionary keyed by the endpoint address. I'm hitting the error when attempting to read from the pipe as such: [pipe enqueueIORequestWithData:data completionTimeout:0.0 error:&error completionHandler:^(IOReturn status, NSUInteger bytesTransferred) {     NSLog(@"<submit_bulk_transfer> Read completed, status=%d, bytes transfered=%lu", status, bytesTransferred);    }] Any guidance on how to address this issue? Thanks.
0
0
836
Jan ’21
How to access a USB Device in macOS using IOUSBHostObject
When attempting to access a USB device on macOS using IOUSBHostDevice, I get the following error: Error:Failed to create IOUSBHostObject. with reason: Exclusive open of usb object failed So, to workaround that error, I've added the following entitlement: com.apple.vm.device-access But that leads to an error with attempting to run the application: Exception Type: EXCCRASH (Code Signature Invalid) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXCCORPSE_NOTIFY Termination Reason: Namespace CODESIGNING, Code 0x1 My code looks like:    NSLog(@"Instantiating USBConfig...");   _queue = dispatch_queue_create("usbconfig", DISPATCH_QUEUE_SERIAL);   _productId = asusBluetoothDongleProductId;   _vendorId = asusBluetoothDongleVendorId;   CFMutableDictionaryRef query = [IOUSBHostDevice         createMatchingDictionaryWithVendorID:[NSNumber numberWithUnsignedInteger:_vendorId]          productID:[NSNumber numberWithUnsignedInteger:_productId]          bcdDevice:nil         deviceClass:nil       deviceSubclass:nil       deviceProtocol:nil            speed:nil       productIDArray:nil];   _service = IOServiceGetMatchingService(kIOMasterPortDefault, query);   if (_service == 0) {    NSLog(@"No service match found for product/vendor query.");    return nil;   }   kern_return_t authorized = IOServiceAuthorize(_service, 0);   if (authorized) {        }   NSError* error = nil;   _device = [[IOUSBHostDevice alloc] initWithIOService:_service    options:IOUSBHostObjectInitOptionsDeviceCapture    queue:_queue    error:&error    interestHandler:^(IOUSBHostObject * _Nonnull hostObject, uint32_t messageType, void * _Nullable messageArgument) {     NSLog(@"Interest handler...");    }];   if (error != nil) {    NSLog(@"Error creating device: %@", [error localizedDescription]);   } I'm not sure what to do to address this issue. Thanks.
1
0
1.2k
Nov ’20
IOUSBHostDevice: Exclusive open of usb object failed
I have a command line tool and am trying to connect to a USB device using:    _device = [[IOUSBHostDevice alloc] initWithIOService:_service    options:IOUSBHostObjectInitOptionsDeviceCapture    queue:_queue    error:&error    interestHandler:^(IOUSBHostObject * _Nonnull hostObject, uint32_t messageType, void * _Nullable messageArgument) {     NSLog(@"Interest handler...");    }]; However, when I run this tool (even under sudo), I'm hitting the error: Error:Unable to open io&#92;&#95;service&#92;&#95;t object and create user client. with reason: Exclusive open of usb object failed. The documentation for IOUSBHostObjectInitOptionsDeviceCapture implies that using this option and having root privilege should gain exclusive access to the device. The alternative is to use an entitlement, but the executable is terminated immediately in that case probably due to code signing. I would have expected that running the tool under sudo would have been sufficient to avoid this issue. I just want to first get things working locally on my Mac for a proof of concept, so I don't really want to deal with code signing up front unless that is absolutely necessary. What do I need to do to get exclusive access to the USB device? Thanks in advance.
5
0
2.7k
Oct ’20
Creating IOUSBHostDevice in Swift
How to instantiate IOUSBHostDevice in swift? https://developer.apple.com/documentation/iousbhost/iousbhostdevice references as the initializer: https://developer.apple.com/documentation/iousbhost/iousbhostobject/3181717-initwithioservice But when I call that init like: let device = try IOUSBHostDevice(ioService: service, queue: queue) I get the error: init(ioService:queue:interestHandler:)' is unavailable in Swift: Please use the refined for Swift API
2
0
1k
Oct ’20
MetricKit: Custom Metrics signposts
Hi, I'm using mxSignpost() to post custom metrics for my iOS app and I'm subscribing for receiving metric payloads, but I'm not seeing my custom signposts in the payloads. I'm only seeing the standard metrics in the payloads. If I simulate payloads in Xcode, I see the fake signposts that are generated by the simulation. I've confirmed using breakpoints that I'm calling mxSignpost() and I've exercised the paths that to trigger the signposts. Is there any way to see what MetricKit has logged? Otherwise, I have to wait 24 hours to see the posted payloads. I'm testing on iPhone 8 running iOS 13.6. Thanks, Tom
3
0
1.6k
Aug ’20