CaptuvoScannerController.m 4.29 KB
Newer Older
Alex Moore's avatar
Alex Moore committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
//  CaptuvoScannerController.m
//  CaptuvoSDKDemo
//
//  Created by PLUC SeniorDesign on 2/24/15.
//  Copyright (c) 2015 Anthony J. Carno. All rights reserved.
//

#import "CaptuvoScannerController.h"

@interface CaptuvoScannerController ()

@end

@implementation CaptuvoScannerController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self initDecoder];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    
}

/**
 @brief This method attempts to establish a connection to the Captuvo SL22 Enterprise Sled and start the decoder hardware.  A UIAlertView prompts the user if a connection cannot be established.  Additionally, this method adds the current class (self) as a CaptuvoDelegate.
 
 @return ProtocolConnectionStatus - the connection status of the Captuvo sled
 */
- (void)initDecoder
{
    ProtocolConnectionStatus status = [[Captuvo sharedCaptuvoDevice] startDecoderHardware];
    //    switch (status) {
    //        case ProtocolConnectionStatusAlreadyConnected:
    //            printf("ProtocolConnectionStatusAlreadyConnected\n");
    //            break;
    //        case ProtocolConnectionStatusBatteryDepleted:
    //            printf("ProtocolConnectionStatusBatteryDepleted\n");
    //            break;
    //        case ProtocolConnectionStatusConnected:
    //            printf("ProtocolConnectionStatusConnected\n");
    //            break;
    //        case ProtocolConnectionStatusUnableToConnect:
    //            printf("ProtocolConnectionStatusUnableToConnect\n");
    //            break;
    //        case ProtocolConnectionStatusUnableToConnectIncompatiableSledFirmware:
    //            printf("ProtocolConnectionStatusUnableToConnectIncompatiableSledFirmware\n");
    //            break;
    //        default:
    //            printf("ERROR\n");
    //            break;
    //    }
    if (status == ProtocolConnectionStatusUnableToConnect) {
        UIAlertView *sledAlert = [[UIAlertView alloc] initWithTitle:@"Connection Error"
                                                            message:@"Unable to communicate with sled - unknown communication error."
                                                           delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
        [sledAlert show];
    }
    else if (status == ProtocolConnectionStatusUnableToConnectIncompatiableSledFirmware) {
        UIAlertView *sledAlert = [[UIAlertView alloc] initWithTitle:@"Connection Error"
                                                            message:@"Unable to communicate with sled - incompatible sled firmware."
                                                           delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
        [sledAlert show];
    }
    else if (status == ProtocolConnectionStatusBatteryDepleted) {
        UIAlertView *sledAlert = [[UIAlertView alloc] initWithTitle:@"Connection Error"
                                                            message:@"Unable to communicate with sled - battery depleted."
                                                           delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
        [sledAlert show];
    }
    //[[Captuvo sharedCaptuvoDevice] requestBatteryVoltage] ;
    //[[Captuvo sharedCaptuvoDevice] requestChargeStatus] ;
}



/**
 @brief This method handles the barcode data returned by the scanner
 
 @param (NSString *)data - the scanned barcode (in text form)
 */
- (void) decoderDataReceived:(NSString *)data {
    self.barcodeLabel.textAlignment = NSTextAlignmentLeft;
    self.barcodeLabel.text = data;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end