I am creating an app that utilizes a serial cable adapter for iOS. The basic design of the app is a Split View Controller with a detail view controller, from which I can launch a session (in a separate view) that sends information through the accessory. I got the application "working" in the sense that I set up the delegate that controls the accessory interface (supplied in SDK) from the session view controller, and it works the first time it is run. The only problem is that if I try to run the session a second time (by launching from the detail view controller again or switch between projects in the split view) it fails because of a pre-existing connection, i.e. the previously established connection. This is the console log below:
ERROR - opening session failed
ERROR - /SourceCache/ExternalAccessory/ExternalAccessory-242/EASession.m:-[EASession dealloc] - 139 unable to close session for _accessory=0x14d59250 and sessionID=65536
Cable Not Connected
If it helps as well, here is some stripped-down code from my .h and .m files of the session view controller:
.h
@interface SessionViewController : UIViewController <RscMgrDelegate> {
RscMgr *rscMgr;
CableConnectState cableState;
}
@property (strong, nonatomic) IBOutlet UIBarButtonItem *cableStatus;
- (void) sendStringToSerial: (NSTimer *) timer;
@end
.m
@implementation SessionViewController
@synthesize cableStatus;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// Serial Setup
rscMgr = [[RscMgr alloc] init];
[rscMgr setDelegate:self];
//checks cableConnectState and adjusts the outlet cableStatus accordingly
}
- (void) sendStringToSerial: (NSTimer *) timer {
[rscMgr writeString:someString];
}
@end
So the questions: Is the structure I have the best way to go, and if so, how do I fix the session issue? If not, any suggestions on where to go from here? Thanks!