Multiple Sensors - Fighting for resources on MAC OSX and Swift
I have two metawear sensors that I want to connect to my mac application, to read data.
I am attempting to do it as follows:
let manager = MBLMetaWearManager.shared();
...
manager.startScanForMetaWears() { array in
for currentDevice in array {
currentDevice.connectAsync().success() { _ in
// connected
}.failure() { error in
// failed to connect
}
}
self.manager.stopScan();
}
Using this approach, I can see that a connection is attempted to be made to both of my devices. However, as soon as one connects, the other is stuck in the async method trying to connect. ( However, it never does ) Note : Yes, I can connect to each sensor individually, and retrieve the data without an issue. It is only when I try to connect to multiple that I get the resource fight for which one will be connected to first.
Am I missing something here in being able to connect to two?
I have been reading thee threads to try and solve the problem, but it seems I cannot find any more hints:
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #4f8187; background-color: #ffffff}
span.s1 {color: #ba2da2}
span.s2 {color: #000000}
span.s3 {color: #31595d}
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #31595d; background-color: #ffffff}
span.s1 {color: #4f8187}
span.s2 {color: #000000}
span.s3 {color: #ba2da2}
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff; min-height: 13.0px}
span.s1 {color: #ba2da2}
span.s2 {color: #31595d}
span.s3 {color: #008400}
span.s4 {color: #4f8187}
This discussion has been closed.
Comments
for currentDevice in x {
task = task.continueOnDispatch { _ in
return currentDevice.connectAsync().success() { _ in
// connected
}.failure() { error in
// failed to connect
}
}
}