Multiple Metawears and method callbacks

In the project I'm currently working on I need multiple metawears connected to one iOS device, I'm using the latest Xcode 6.2 and iOS 8.2. Multiple metawears connect without problems but when I subscribe to get data from multiple boards (any inputs: pushbutton, accelerometer, temperature sensor) I don't know how to detect from which board the data is sent.


[device[i].mechanicalSwitch.switchUpdateEvent startNotificationsWithHandler:^(MBLNumericData *obj, NSError *error) {

NSLog(@Switch Changed: %@", obj);

}];


How can I know from which board that message is sent? 


Using [NSThread callStackSymbols] I can retrieve an address of a MBLRegister  but that is not enough to get to the device instance or device identifier.

Comments

  • You can capture the MBLMetaWear object in the callback.  For example:

    for (MBLMetaWear *cur in devices) {

        [cur.mechanicalSwitch.switchUpdateEvent startNotificationsWithHandler:^(MBLNumericData *obj, NSError *error) {

            NSLog(@Switch Changed: %@, On Device: %@", obj, cur);

        }];

    }

  • Thank you stephen. 
  • It is working fine with any method but the accelerometer. When calling the function
    [device.accelerometer.dataReadyEventstartNotificationsWithHandler:^(MBLAccelerometerData *acceleration, NSError*error) 

    it never works if more than two devices are connected. Guesses?
  • What sample frequencies are you using?  BLE is not a high bandwidth radio and trying to stream accelerometer data higher than 100Hz will get you into trouble.  Since the iPhone only has a single BLE radio that 100Hz is shared between all connected devices.

    Just doing a quick guess I'd say 50Hz max using 2 devices or 33Hz with 3 (in reality maybe even less because of switching overhead).  Try lowering data rates.

This discussion has been closed.