Cognex Mobile Barcode SDK SDK for supporting communication with Cognex Barcode Reader devices

Instance Methods | Class Methods | Properties | List of all members
CDMDataManSystem Class Reference

Represents a remote DataMan system. More...

`#import <CDMDataManSystem.h>`

Inheritance diagram for CDMDataManSystem:

## Instance Methods
(void) | - setCameraPreviewContainer:completion:
| Sets the container where the camera preview will be placed. More...
(void) | - getCameraExposureCompensationRangeWithCompletion:
| Get camera exposure compensation range (0: lower value, 1: upper value, 2: step) in the completion block. More...
(void) | - setCameraExposureCompensation:completion:
| Sets the camera exposure compensation value. More...
(void) | - loadCameraConfig:
| Load config from app data if exist Method is only supported for Phone Camera. More...
(BOOL) | - connect
| Connects to a remote system without authentication. More...
(BOOL) | - connectWithUsername:password:
| Connects to a remote system, authenticating with the specified username and password. More...
(void) | - disconnect
| Disconnects from the remote system.
(BOOL) | - sendCommand:
| Sends the specified command to the connected remote system. More...
(BOOL) | - sendCommand:withCallback:
| Sends the specified command to the connected remote system. More...
(BOOL) | - sendCommand:withData:timeout:expectBinaryResponse:callback:
| Sends the specified command to the connected remote system. More...
(BOOL) | - sendBatchCommands:completed:
| Sends the specified commands array to the connected remote system. More...
(void) | - acceptIncomingConnection:
| Changes whether the DataMan system accepts incoming messages or not. More...
(void) | - enableHeartbeatWithInterval:
| Enables heartbeat function and sets its interval. More...
(void) | - disableHeartbeat
| Disables the heartbeat when enabled.
(void) | - enableLiveImageWithFormat:imageSize:imageQuality:callback:
| Begins getting the latest image from the connected remote system in live display mode. More...
(void) | - disableLiveImage
| Stops a pending live image retrieval operation.

## Class Methods
(NSString *_Nonnull) | + getVersion
| Returns the current version of the library. More...
(CDMDataManSystem *_Nonnull) | + dataManSystemWithHostname:port:delegate:
| Constructs a DataMan system with hostname and port. More...
(CDMDataManSystem *_Nonnull) | + dataManSystemWithAccessory:delegate:
| Constructs a DataMan system with accessory connector. More...
(CDMDataManSystem *_Nonnull) | + dataManSystemOfExternalAccessoryWithDelegate:
| Constructs a DataMan system with accessory connector. More...
(CDMDataManSystem *_Nonnull) | + dataManSystemWithCameraMode:previewOptions:nullablePreviewView:delegate:
| Constructs a DataMan system with iOS camera. More...
(CDMDataManSystem *_Nonnull) | + dataManSystemWithCameraMode:previewOptions:delegate:
| Constructs a DataMan system with iOS camera. More...
(CDMDataManSystem *_Nonnull) | + dataManSystemWithCameraMode:previewOptions:nullablePreviewView:registrationKey:delegate:
| Constructs a DataMan system with iOS camera. More...
(CDMDataManSystem *_Nonnull) | + dataManSystemWithCameraMode:previewOptions:nullablePreviewView:registrationKey:customData:delegate:
| Constructs a DataMan system with iOS camera. More...
(CDMDataManSystem *_Nonnull) | + datamanSystemWithBluetoothPeripheralUUID:psm:delegate:
| Constructs a DataMan system with a Bluetooth device. More...

## Properties
DataManDeviceClass | deviceClass
| Gets the device type of the CDMDataManSystem instance.
CDMConnectionState | connectionState
| Gets the current connection state of the CDMDataManSystem instance.
id< CDMDataManSystemDelegate > _Nullable | delegate
| Sets or gets the delegate where the messages will be sent to. More...
CDMResultTypes | resultTypes
| Sets which result types the application wants to receive.
BOOL | heartbeatEnabled
| Read-only state of the heartbeat function.
BOOL | liveImageEnabled
| Read-only state of live image mode.
NSTimeInterval | timeout
| Timeout for commands and connection, default value is 6 sec.
MDMAuthCredentials *_Nullable | defaultMDMAuthCredentials
| Default credentials for MDM communication. More...
BOOL | MDMReportingEnabled
| Enables reporting properties of the connected MX device to an MDM system. More...
BOOL | connected
| Read-only connection state of the system.

## Detailed Description

Represents a remote DataMan system.

## Method Documentation

## ◆ acceptIncomingConnection:

- (void) acceptIncomingConnection: |  | (BOOL) | accept |

Changes whether the DataMan system accepts incoming messages or not.

It does not effect an already connected device.

Parameters

  accept | Flag to signal whether the incoming connection is accepted or not

## ◆ connect

- (BOOL) connect |  |  |

Connects to a remote system without authentication.

## @name Instance methods

## ◆ connectWithUsername:password:

- (BOOL) connectWithUsername: |  | (NSString *_Nullable) | username
password: |  | (NSString *_Nullable) | password

Connects to a remote system, authenticating with the specified username and password.

If the password is specified but the username is not, the username will be "admin" by default.

Parameters

  username | the username for the authentication
  password | the password for the given user

Returns
  YES, if the system has successfully started the connection process. (it may return NO mostly with EA devices if the session can't be opened)

## ◆ dataManSystemOfExternalAccessoryWithDelegate:

+ (CDMDataManSystem *_Nonnull) dataManSystemOfExternalAccessoryWithDelegate: |  | (id< CDMDataManSystemDelegate >_Nonnull) | delegate |

Constructs a DataMan system with accessory connector.

To properly detect and connect to the device, be sure to declare UISupportedExternalAccessoryProtocols key with Cognex DMCC protocol (com.cognex.dmcc) item in Info.plist.

Parameters

  delegate | The delegate where the messages will be sent to

Returns
  DataMan system with external accessory connection configured or nil, if there is no supported accessory connected

See also
  CDMDataManSystemDelegate

## ◆ dataManSystemWithAccessory:delegate:

+ (CDMDataManSystem *_Nonnull) dataManSystemWithAccessory: |  | (EAAccessory *_Nullable) | accessory
delegate: |  | (id< CDMDataManSystemDelegate >_Nonnull) | delegate

Constructs a DataMan system with accessory connector.

To properly detect and connect to the device, be sure to declare UISupportedExternalAccessoryProtocols key with Cognex DMCC protocol (com.cognex.dmcc) item in Info.plist.

Parameters

  accessory | The EAAccessory object with information about the connected device
  delegate | The delegate where the messages will be sent to

Returns
  DataMan system with external accessory connection configured or nil, if the accessory is not a CDM device

See also
  CDMDataManSystemDelegate

## ◆ datamanSystemWithBluetoothPeripheralUUID:psm:delegate:

+ (CDMDataManSystem *_Nonnull) datamanSystemWithBluetoothPeripheralUUID: |  | (NSUUID *_Nonnull) | peripheralUUID
psm: |  | (CBL2CAPPSM) | psm
delegate: |  | (ios(11)) | API_AVAILABLE

Constructs a DataMan system with a Bluetooth device.

You should first scan for a Bluetooth device or load its saved UUID to connect.

Parameters

  peripheralUUID | The UUID of the CBPeripheral object you want to connect to.
  psm | The default value is 192.
  delegate | The delegate where the messages will be sent to

Returns
  DataMan system using the Bluetooth device identified by peripheralUUID parameter

See also
  CDMDataManSystemDelegate

## ◆ dataManSystemWithCameraMode:previewOptions:delegate:

+ (CDMDataManSystem *_Nonnull) dataManSystemWithCameraMode: |  | (CDMCameraMode) | cameraMode
previewOptions: |  | (CDMPreviewOption) | previewOptions
delegate: |  | (id< CDMDataManSystemDelegate >_Nonnull) | delegate

Constructs a DataMan system with iOS camera.

To properly detect and connect to the device, be sure to declare NSCameraUsageDescription key with Cognex DMCC protocol (com.cognex.dmcc) item in Info.plist.

Parameters

  cameraMode | Check CDMCameraMode for possible values.
  previewOptions | Check CDMPreviewOption for possible values.
  delegate | The delegate where the messages will be sent to

Returns
  DataMan system using the devices built in camera

See also
  CDMDataManSystemDelegate

## ◆ dataManSystemWithCameraMode:previewOptions:nullablePreviewView:delegate:

+ (CDMDataManSystem *_Nonnull) dataManSystemWithCameraMode: |  | (CDMCameraMode) | cameraMode
previewOptions: |  | (CDMPreviewOption) | previewOptions
nullablePreviewView: |  | (UIView *_Nullable) | previewView
delegate: |  | (id< CDMDataManSystemDelegate >_Nonnull) | delegate

Constructs a DataMan system with iOS camera.

To properly detect and connect to the device, be sure to declare NSCameraUsageDescription key with Cognex DMCC protocol (com.cognex.dmcc) item in Info.plist.

Parameters

  cameraMode | Check CDMCameraMode for possible values.
  previewOptions | Check CDMPreviewOption for possible values.
  previewView | Camera preview will be attached on that view, can be null (in which case, camera preview will be in full screen).
  delegate | The delegate where the messages will be sent to

Returns
  DataMan system using the devices built in camera

See also
  CDMDataManSystemDelegate

## ◆ dataManSystemWithCameraMode:previewOptions:nullablePreviewView:registrationKey:customData:delegate:

+ (CDMDataManSystem *_Nonnull) dataManSystemWithCameraMode: |  | (CDMCameraMode) | cameraMode
previewOptions: |  | (CDMPreviewOption) | previewOptions
nullablePreviewView: |  | (UIView *_Nullable) | previewView
registrationKey: |  | (NSString *_Nullable) | registrationKey
customData: |  | (NSString *_Nullable) | customData
delegate: |  | (id< CDMDataManSystemDelegate >_Nonnull) | delegate

Constructs a DataMan system with iOS camera.

To properly detect and connect to the device, be sure to declare NSCameraUsageDescription key with Cognex DMCC protocol (com.cognex.dmcc) item in Info.plist.

Parameters

  cameraMode | Check CDMCameraMode for possible values.
  previewOptions | Check CDMPreviewOption for possible values.
  previewView | Camera preview will be attached on that view, can be null (in which case, camera preview will be in full screen).
  registrationKey | The license key for registering the camera scanner.
  customData | Custom string to be send to the licensing server for tracking purposes.
  delegate | The delegate where the messages will be sent to

Returns
  DataMan system using the devices built in camera

See also
  CDMDataManSystemDelegate

## ◆ dataManSystemWithCameraMode:previewOptions:nullablePreviewView:registrationKey:delegate:

+ (CDMDataManSystem *_Nonnull) dataManSystemWithCameraMode: |  | (CDMCameraMode) | cameraMode
previewOptions: |  | (CDMPreviewOption) | previewOptions
nullablePreviewView: |  | (UIView *_Nullable) | previewView
registrationKey: |  | (NSString *_Nullable) | registrationKey
delegate: |  | (id< CDMDataManSystemDelegate >_Nonnull) | delegate

Constructs a DataMan system with iOS camera.

To properly detect and connect to the device, be sure to declare NSCameraUsageDescription key with Cognex DMCC protocol (com.cognex.dmcc) item in Info.plist.

Parameters

  cameraMode | Check CDMCameraMode for possible values.
  previewOptions | Check CDMPreviewOption for possible values.
  previewView | Camera preview will be attached on that view, can be null (in which case, camera preview will be in full screen).
  registrationKey | The license key for registering the camera scanner.
  delegate | The delegate where the messages will be sent to

Returns
  DataMan system using the devices built in camera

See also
  CDMDataManSystemDelegate

## ◆ dataManSystemWithHostname:port:delegate:

+ (CDMDataManSystem *_Nonnull) dataManSystemWithHostname: |  | (NSString *_Nonnull) | hostname
port: |  | (int) | port
delegate: |  | (id< CDMDataManSystemDelegate >_Nonnull) | delegate

Constructs a DataMan system with hostname and port.

This factory method constructs a new DataMan system with an ethernet connector configured inside.

Parameters

  hostname | The hostname of the remote system
  port | The port of the remote system
  delegate | The delegate where the messages will be sent to

Returns
  DataMan system with ethernet connection configured

See also
  CDMDataManSystemDelegate

## ◆ enableHeartbeatWithInterval:

- (void) enableHeartbeatWithInterval: |  | (NSTimeInterval) | interval |

Enables heartbeat function and sets its interval.

Parameters

  interval | Specifies heartbeat interval in seconds

## ◆ enableLiveImageWithFormat:imageSize:imageQuality:callback:

- (void) enableLiveImageWithFormat: |  | (CDMImageFormat) | imageFormat
imageSize: |  | (CDMImageSize) | imageSize
imageQuality: |  | (CDMImageQuality) | quality
callback: |  | (void(^)(UIImage *_Nullable image, CDMResponse *_Nonnull response)) | callback

Begins getting the latest image from the connected remote system in live display mode.

Parameters

  imageFormat | Image format
  imageSize | Image size
  quality | Image quality
  callback | Callback block with image to be called when operation completes

## ◆ getCameraExposureCompensationRangeWithCompletion:

- (void) getCameraExposureCompensationRangeWithCompletion: |  | (void(^)(NSArray< NSNumber * > *_Nullable range, NSError *_Nullable error)) | completionBlock |

Get camera exposure compensation range (0: lower value, 1: upper value, 2: step) in the completion block.

Camera must to be opened before

Parameters

  completionBlock | The block will contain an array with the minimum and maximum exposure values, or an error when used on connector other than the Phone Camera The camera needs to be started within cmbSDK at least once to get the camera exposure compensation range

## ◆ getVersion

+ (NSString *_Nonnull) getVersion |  |  |

Returns the current version of the library.

Returns
  current DataMan SDK version

## ◆ loadCameraConfig:

- (void) loadCameraConfig: |  | (void(^)(NSError *_Nullable error)) | completionBlock |

Load config from app data if exist Method is only supported for Phone Camera.

Parameters

  completionBlock | The block will contain an error when used on connector other than the Phone Camera

## ◆ sendBatchCommands:completed:

- (BOOL) sendBatchCommands: |  | (NSArray *_Nonnull) | commands
completed: |  | (void(^)(void)) | complete

Sends the specified commands array to the connected remote system.

Parameters

  commands | The array of commands to send to the remote system
  complete | A callback that will be called when all the commands are sent

Returns
  YES, if the system is connected and the command can be sent, NO otherwise

## ◆ sendCommand:

- (BOOL) sendCommand: |  | (NSString *_Nonnull) | command |

Sends the specified command to the connected remote system.

Parameters

  command | The command to send to the remote system

Returns
  YES, if the system is connected and the command can be sent, NO otherwise

## ◆ sendCommand:withCallback:

- (BOOL) sendCommand: |  | (NSString *_Nonnull) | command
withCallback: |  | (void(^)(CDMResponse *_Nonnull response)) | callback

Sends the specified command to the connected remote system.

Code samples:

[self.dataManSystem sendCommand:@"TRIGGER ON" withCallback:^(CDMResponse *response){
if (response.status == DMCC_STATUS_NO_ERROR) {
// command has succeed.
} else {
// handle error
}
}];
DMCC_STATUS_NO_ERROR
#define DMCC_STATUS_NO_ERROR
Definition: CDMResponse.h:9
CDMResponse
Represents a DMCC response sent by a remote system.
Definition: CDMResponse.h:37
[self.dataManSystem sendCommand:@"GET TRAINED-CODE.INFO" withCallback:^(CDMResponse *response){
if (response.status == DMCC_STATUS_NO_ERROR) {
if ([response.payload isEqualToString:@"Untrained"]) {
// device is untrained
} else {
// device is trained
}
}
}];

Parameters

  command | The command to send to the remote system
  callback | A callback that will be called when the command is completed

Returns
  YES, if the system is connected and the command can be sent, NO otherwise

## ◆ sendCommand:withData:timeout:expectBinaryResponse:callback:

- (BOOL) sendCommand: |  | (NSString *_Nonnull) | command
withData: |  | (NSData *_Nullable) | data
timeout: |  | (NSTimeInterval) | timeout
expectBinaryResponse: |  | (BOOL) | expectBinaryResponse
callback: |  | (void(^)(CDMResponse *_Nonnull response)) | callback

Sends the specified command to the connected remote system.

Parameters

  command | The command to send to the remote system
  data | Additional data to send to the remote system
  timeout | Timeout for the command
  expectBinaryResponse | Flag to signal if we expect binary response
  callback | A callback that will be called when the command is completed

Returns
  YES, if the system is connected and the command can be sent, NO otherwise

## ◆ setCameraExposureCompensation:completion:

- (void) setCameraExposureCompensation: |  | (float) | exposureCompensation
completion: |  | (void(^)(NSError *_Nullable error)) | completionBlock

Sets the camera exposure compensation value.

Parameters

  exposureCompensation | Float value that will be set as exposure compensation
  completionBlock | The block will contain an error when used on connector other than the Phone Camera

## ◆ setCameraPreviewContainer:completion:

- (void) setCameraPreviewContainer: |  | (UIView *_Nullable) | previewContainer
completion: |  | (void(^)(NSError *_Nullable error)) | completionBlock

Sets the container where the camera preview will be placed.

Parameters

  previewContainer | The container where the camera preview will be placed.
  completionBlock | The block will contain an error when used on connector other than the Phone Camera Method is only supported for Phone Camera

## Property Documentation

## ◆ defaultMDMAuthCredentials

- (MDMAuthCredentials* _Nullable) defaultMDMAuthCredentials
| read write nonatomic assign

Default credentials for MDM communication.

Credentials provided by managed app configuration will override this property per field basis.

## ◆ delegate

- (id<CDMDataManSystemDelegate> _Nullable) delegate
| read write atomic weak

Sets or gets the delegate where the messages will be sent to.

See also
  CDMDataManSystemDelegate

## ◆ MDMReportingEnabled

- (BOOL) MDMReportingEnabled
| read write nonatomic assign

Enables reporting properties of the connected MX device to an MDM system.

Default value is false.

The documentation for this class was generated from the following file:

- CDMDataManSystem.h