Cardboard Robot SDK
 All Classes Functions Properties
CBDevice.h
1 /*=========================================================================
2  This file is part of the Cardboard Robot SDK.
3 
4  Copyright (C) 2012 Ken Ihara.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 =========================================================================*/
19 
20 #import <Foundation/Foundation.h>
21 
22 @class CBDeviceConnection;
23 @class CBRobot;
24 @protocol CBDeviceDelegate;
25 
26 /* A high-level connection to the Cardboard Robot USB device. */
27 @interface CBDevice : NSObject {
28  CBDeviceConnection *connection; /* Low-level connection */
29  IONotificationPortRef notificationPort; /* Notification port for device connection / disconnection */
30  io_iterator_t deviceAddedIterator; /* Iterator for added devices */
31  io_iterator_t deviceRemovedIterator; /* Iterator for removed devices */
32  NSTimer *autoConnectTimer; /* Auto-connect timer, in case detection fails */
33 }
34 
36 @property (readonly, nonatomic) BOOL connected;
37 
39 @property (assign, nonatomic) id <CBDeviceDelegate> delegate;
40 
41 - (id)init;
42 
43 - (void)startAutoConnect;
44 - (void)stopAutoConnect;
45 
46 - (void)tryConnect;
47 - (void)disconnect;
48 
49 - (void)updateRobot:(CBRobot *)robot;
50 
51 @end