Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

updateScheduleWithSchedule often returns "The operation couldn't be completed." error #83

Open
jfhamel opened this issue Jan 25, 2015 · 0 comments

Comments

@jfhamel
Copy link

jfhamel commented Jan 25, 2015

Hi,

I'm currently developing an application that triggers a schedule update with a UISwitch. Unfortunately, I often get the following error: "Error Domain=com.philips.hue.sdk Code=92 "The operation couldn\U2019t be completed. (com.philips.hue.sdk error 92.)""

I realized that I systematically get the error when I tap the switch approximately just before the heartbeat occurs. I feel that there are interferences between the heartbeat and the calls the the PHBridgeSendAPI method calls.

In the first thing, I would expect that the SDK manages all this. It should queue all the bridge activities one after the other. Is it a bug or I miss something?

I also tried many things to get around the issue:

  1. I tried to stop the heartbeat with [UIAppDelegate.phHueSDK disableLocalConnection] before calling updateScheduleWithSchedule and restart it with [UIAppDelegate.phHueSDK enableLocalConnection] in the completion handler of [BridgeSendAPI updateScheduleWithSchedule... but I got the same result.
  2. I tried with [UIAppDelegate.phHueSDK disableCacheUpdateLocalHeartbeat:YES] and ...NO with the same result.
  3. I tried to add some delay with [NSThread sleepForTimeInterval:1.0f] and [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]] after the call to [UIAppDelegate.phHueSDK disableLocalConnection] and before the call to [UIAppDelegate.phHueSDK enableLocalConnection] with the same result. I tried many length of delay.
  4. I also tried to move things around like calling [UIAppDelegate.phHueSDK disableLocalConnection] before initializing PHBridgeSendAPI *myBridgeSendAPI but without any effect.

The only way I found to get rid of the error is to stop the heartbeat. Unfortunately, I need it.

Can anybody help me with this?

My method code is below.

Thank you.

-(void) mySwitchOnOffScheduleWithSchedule:(PHSchedule *)mySchedule newStatus:(bool)myNewStatus
{
    PHBridgeSendAPI *myBridgeSendAPI = [[PHBridgeSendAPI alloc] init];

    //Stop heartbeat
    [UIAppDelegate.phHueSDK disableLocalConnection];

    PHSchedule *myNewSchedule=[mySchedule copy];
    [myNewSchedule setStatusAsEnum:myNewStatus ? SCHEDULE_STATUS_ENABLED : SCHEDULE_STATUS_DISABLED];

    [myBridgeSendAPI updateScheduleWithSchedule:myNewSchedule completionHandler:^(NSArray *myErrors)
     {
         if (myErrors!=nil)
         {
             NSString *myMessage=[NSString stringWithFormat:@"Errors: %@", myErrors];
             UIAlertView *myErrorAlert =[[UIAlertView alloc] initWithTitle:@"Response" message:myMessage delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
             [myErrorAlert show];
             NSLog(@"%@",myMessage);
         }

         //Restart heartbeat after schedule update completeion
         [NSThread sleepForTimeInterval:1.0f];
         [UIAppDelegate.phHueSDK enableLocalConnection];
         [UIAppDelegate.phHueSDK setLocalHeartbeatInterval:3.0f forResourceType:RESOURCES_ALL];
     }];
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant