Always Bypass Guest Mode?

edited January 2016 in iOS
Hi everyone,

Following the iOS SDK documentation, I saw that you can tell when a device is in guest mode via it's 'isGuestConnection' property. However, it seems like my device is never in guest mode (though I'm sure it is, because it accessed the mbientlab sample app) -- since it never goes into the if conditional. I tried placing the conditional after I scan and find a device, is this correct? Here's my code:






[[MBLMetaWearManager sharedManager] startScanForMetaWearsWithHandler:^(NSArray *array) {

    for (MBLMetaWear *device in array) {

      

      [[MBLMetaWearManager sharedManager] stopScanForMetaWears];

      

      if (device.isGuestConnection) {

        NSLog(@Guest connection);

        [device setConfiguration:nil handler:^(NSError *error) {

//clears guest mode, then calls itself in order to hopefully establish a normal connection

          [self connectToMetaWear];

        }];

      } else {

      

        [device connectWithHandler:^(NSError *error) {


          if (device.state == MBLConnectionStateConnected) {

            

            NSLog(@Connected to device successfully!);

            self.device = device;


            

          }

        }];

I'd love any suggestions you might have, thank you! Also, when the device is connected in guest mode, am I correct in saying that I don't have access to the accelerometer data? The reason I ask is because sometimes my app never gets an accelerometer data or it only reads a bit of data before the accelerometer data stops streaming. The sample frequency is 100hz. The reason I think it's guest mode is because after I go to the mbientlab sample app and factory reset, then everything is normal and works perfectly.

Thanks!



Comments

  • Please excuse the crazy formatting, the copying and pasting screwed everything up!
  • Thanks for the questions, the documentation isn't clear on this so I will update that and fill you in here.

    isGuestConnection is only valid once a connection is established.  It works by looking a special app specific token stored on the MetaWear and it needs a connection in order to read it.

    Also, you shouldn't call setConfiguration:handler: on a MetaWear without a connection, that should return an error.

    Guest mode doesn't enforce any usage rules, its merely a boolean indicating it's likely a bad idea to trust the current state of the MetaWear (so we recommend a reset).  You can still mess with the accelerometer in guest mode, but it's probably going to cause issues for the first app.
  • So once I connect to the device, is this when I'd call [device setConfiguration:nil handler: nil]? Then possibly within the handler, call the connectWithHandler method?

    Thanks for answering the questions, Stephen! 
This discussion has been closed.