EMConnectionManager Class Reference
Inherits from | NSObject |
Conforms to | EMConnectionDelegate |
Declared in | EMConnectionManager.h EMConnectionManager.m |
Overview
EMConnectionManager is a singleton class for managing a connection with a physical or mock device.
Tasks
-
backgroundUpdatesEnabled
@property backgroundUpdatesEnabled @description If you set this flag to “YES”, the connection manager has the ability to persist while running in the background. By default, the connection manager severs connections when entering the background.
property -
+ sharedManager
Use the +sharedManager class method to access the application-wide singleton instance of EMConnectionManager. Note: Accessing the connection manager in any way other is not recommended.
-
– connectDevice:onSuccess:onFail:
Tells the connection manager to connect to a specific device.
-
– connectDevice:timeoutInterval:onSuccess:onFail:
Tells the connection manager to connect to a specific device.
-
– disconnectWithSuccess:onFail:
Tells the connection manager to disconnect from a specific device
-
– readResource:onSuccess:onFail:
Reads a resource from a connected device
-
– writeValue:toResource:onSuccess:onFail:
Writes a value to a resource on a connected device
-
– connectedDevice
Returns an array of EMDeviceBasicDescription’s for the device that is actively connected
-
– schemaHashForConnectedDevice
Returns a version of the the schema hash from a connected device’s firmware as it appears on em-hub
-
– addSchemaSearchForFilesInDirectory:
Tells the connection manager where it should look for schemas other than the NSBundle’s mainBundle
-
– removeSchemaSearchForFilesInDirectory:
Tells the connection manager to no longer look in the specified path for schemas
-
– forceConnectionWithDefaultSchema:
Forces the connection manager to connect to a device with the default schema
-
– updateInternalSchemaCache
Tells EMConnectionManager to update its internal cache of schemas used for connection. @description EMConnectionManager uses this method internally. It is very rare taht you will need to call this method directly.
-
– schemaFileNameForHashString:
Gives the schema name in the application bundle for a given hash string
-
– schemaForConnectedDevice
Gets the schema for the connected device. @description Returns nil if no device is connected.
-
– embeddedSystemProtocolLevel
Gets the embedded system protocol level from the schema used to connect to the device @description This call does not send a message down to the board - the protocol level is pulled directly from the schema that was used to connect to the device.
Properties
backgroundUpdatesEnabled
@property backgroundUpdatesEnabled @description If you set this flag to “YES”, the connection manager has the ability to persist while running in the background. By default, the connection manager severs connections when entering the background.
@property (nonatomic) BOOL backgroundUpdatesEnabled
Discussion
@property backgroundUpdatesEnabled @description If you set this flag to “YES”, the connection manager has the ability to persist while running in the background. By default, the connection manager severs connections when entering the background.
Declared In
EMConnectionManager.h
Class Methods
sharedManager
Use the +sharedManager class method to access the application-wide singleton instance of EMConnectionManager. Note: Accessing the connection manager in any way other is not recommended.
+ (EMConnectionManager *)sharedManager
Discussion
Use the +sharedManager class method to access the application-wide singleton instance of EMConnectionManager. Note: Accessing the connection manager in any way other is not recommended.
Declared In
EMConnectionManager.h
Instance Methods
addSchemaSearchForFilesInDirectory:
Tells the connection manager where it should look for schemas other than the NSBundle’s mainBundle
- (void)addSchemaSearchForFilesInDirectory:(NSString *)path
Parameters
- path
The path for the directory in which to search
Discussion
Tells the connection manager where it should look for schemas other than the NSBundle’s mainBundle
Declared In
EMConnectionManager.h
connectDevice:onSuccess:onFail:
Tells the connection manager to connect to a specific device.
- (void)connectDevice:(EMDeviceBasicDescription *)device onSuccess:(void ( ^ ) ( void ))successBlock onFail:(void ( ^ ) ( NSError *error ))failBlock
Parameters
- device
An instance of EMDeviceBasicDescription the connection manager should connect to
- successBlock
The block to run after a successful connection
- failBlock
The block to run if the connectino fails @description The implementation of this method calls connectDevice:timeoutInterval:onSuccess:onFail: with a default time interval of 10 seconds
Discussion
Tells the connection manager to connect to a specific device.
Declared In
EMConnectionManager.h
connectDevice:timeoutInterval:onSuccess:onFail:
Tells the connection manager to connect to a specific device.
- (void)connectDevice:(EMDeviceBasicDescription *)device timeoutInterval:(NSTimeInterval)timeout onSuccess:(void ( ^ ) ( void ))successBlock onFail:(void ( ^ ) ( NSError *error ))failBlock
Parameters
- device
An instance of EMDeviceBasicDescription the connection manager should connect to
- timeout
The time the connection manager should allow for a successful connection. After the specified time interval passes, the fail block will be called.
- successBlock
The block to run after a successful connection
- failBlock
The block to run if the connection fails @description The implementation of this method calls connectDevice:timeoutInterval:onSuccess:onFail: with a default time interval of 10 seconds
Discussion
Tells the connection manager to connect to a specific device.
Declared In
EMConnectionManager.h
connectedDevice
Returns an array of EMDeviceBasicDescription’s for the device that is actively connected
- (EMDeviceBasicDescription *)connectedDevice
Discussion
Returns an array of EMDeviceBasicDescription’s for the device that is actively connected
Declared In
EMConnectionManager.h
disconnectWithSuccess:onFail:
Tells the connection manager to disconnect from a specific device
- (void)disconnectWithSuccess:(void ( ^ ) ( void ))successBlock onFail:(void ( ^ ) ( NSError *error ))failBlock
Parameters
- successBlock
The block to run after a successful disconnection
- failBlock
The block to run if the disconnection fails.
Discussion
Tells the connection manager to disconnect from a specific device
Declared In
EMConnectionManager.h
embeddedSystemProtocolLevel
Gets the embedded system protocol level from the schema used to connect to the device @description This call does not send a message down to the board - the protocol level is pulled directly from the schema that was used to connect to the device.
- (NSNumber *)embeddedSystemProtocolLevel
Discussion
Gets the embedded system protocol level from the schema used to connect to the device @description This call does not send a message down to the board - the protocol level is pulled directly from the schema that was used to connect to the device.
Declared In
EMConnectionManager.h
forceConnectionWithDefaultSchema:
Forces the connection manager to connect to a device with the default schema
- (void)forceConnectionWithDefaultSchema:(EMDeviceBasicDescription *)device
Parameters
- device
The device for the forced connection @description Use this method with extreme caution. Many undefined behaviors can come from using this method with a schema that isn’t an exact match for the specified device. EMConnectionManager uses this method internally. It is very rare that you will need to call this method directly.
Discussion
Forces the connection manager to connect to a device with the default schema
Declared In
EMConnectionManager.h
readResource:onSuccess:onFail:
Reads a resource from a connected device
- (void)readResource:(NSString *)resourceName onSuccess:(void ( ^ ) ( id readValue ))successBlock onFail:(void ( ^ ) ( NSError *error ))failBlock
Parameters
- resourceName
The name of the resource to read. This is the name of the resource in the device’s schema.
- successBlock
The block to call when a read occurs successfully. Connection manager will call this block with the value read.
- failBlock
The block to call when a read fails.
Discussion
Reads a resource from a connected device
Declared In
EMConnectionManager.h
removeSchemaSearchForFilesInDirectory:
Tells the connection manager to no longer look in the specified path for schemas
- (void)removeSchemaSearchForFilesInDirectory:(NSString *)path
Parameters
- path
The path to no longer search @description Note: This method will never ignore the current bundle’s mainBundle
Discussion
Tells the connection manager to no longer look in the specified path for schemas
Declared In
EMConnectionManager.h
schemaFileNameForHashString:
Gives the schema name in the application bundle for a given hash string
- (NSString *)schemaFileNameForHashString:(NSString *)hashString
Parameters
- hashString
A full or partial schema hash string @description This method takes either a full hash or partial hash. If any schema begins with ‘hash string’, the file name in the bundle is returned. Returns nil if no matching schema was found in the bundle. If one or more schemas share ‘hashString’ at the beginning of their hash, the first path will be returned.
Discussion
Gives the schema name in the application bundle for a given hash string
Declared In
EMConnectionManager.h
schemaForConnectedDevice
Gets the schema for the connected device. @description Returns nil if no device is connected.
- (EMSchema *)schemaForConnectedDevice
Discussion
Gets the schema for the connected device. @description Returns nil if no device is connected.
Declared In
EMConnectionManager.h
schemaHashForConnectedDevice
Returns a version of the the schema hash from a connected device’s firmware as it appears on em-hub
- (NSString *)schemaHashForConnectedDevice
Discussion
Returns a version of the the schema hash from a connected device’s firmware as it appears on em-hub
Declared In
EMConnectionManager.h
updateInternalSchemaCache
Tells EMConnectionManager to update its internal cache of schemas used for connection. @description EMConnectionManager uses this method internally. It is very rare taht you will need to call this method directly.
- (void)updateInternalSchemaCache
Discussion
Tells EMConnectionManager to update its internal cache of schemas used for connection. @description EMConnectionManager uses this method internally. It is very rare taht you will need to call this method directly.
Declared In
EMConnectionManager.h
writeValue:toResource:onSuccess:onFail:
Writes a value to a resource on a connected device
- (void)writeValue:(id)resourceValue toResource:(NSString *)resource onSuccess:(void ( ^ ) ( void ))successBlock onFail:(void ( ^ ) ( NSError *error ))failBlock
Parameters
- resourceValue
The value to write to the resource. This should be an instance of NSString, NSData, NSArray, NSNumber, or NSDictionary
- resource
The name of the resource for writing. This is the name of the resource in the schema.
- successBlock
The block to call when the write occurs successfully.
- failBlock
The block to call when the write fails.
Discussion
Writes a value to a resource on a connected device
Declared In
EMConnectionManager.h