CaptuvoScannerController.m 5.61 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//
//  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];

}

Alex Moore's avatar
Alex Moore committed
24
25
26
27
-(void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
- (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];
    if (status == ProtocolConnectionStatusUnableToConnect) {
43
        /*
44
45
46
47
48
49
        UIAlertView *sledAlert = [[UIAlertView alloc] initWithTitle:@"Connection Error"
                                                            message:@"Unable to communicate with sled - unknown communication error."
                                                           delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
        [sledAlert show];
50
51
52
53
54
55
56
         */
        UIAlertController *sledAlert = [UIAlertController alertControllerWithTitle:@"Connection Error" message:@"Unable to communicate with sled - unknown communication error." preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            [sledAlert dismissViewControllerAnimated:YES completion:nil];
        }];
        [sledAlert addAction: ok];
        [self presentViewController:sledAlert animated:YES completion:nil];
57
58
    }
    else if (status == ProtocolConnectionStatusUnableToConnectIncompatiableSledFirmware) {
59
        /*
60
61
62
63
64
65
        UIAlertView *sledAlert = [[UIAlertView alloc] initWithTitle:@"Connection Error"
                                                            message:@"Unable to communicate with sled - incompatible sled firmware."
                                                           delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
        [sledAlert show];
66
67
68
69
70
71
72
         */
        UIAlertController *sledAlert = [UIAlertController alertControllerWithTitle:@"Connection Error" message:@"Unable to communicate with sled - incompatible sled firmware." preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            [sledAlert dismissViewControllerAnimated:YES completion:nil];
        }];
        [sledAlert addAction: ok];
        [self presentViewController:sledAlert animated:YES completion:nil];
73
74
    }
    else if (status == ProtocolConnectionStatusBatteryDepleted) {
75
        /*
76
77
78
79
80
81
        UIAlertView *sledAlert = [[UIAlertView alloc] initWithTitle:@"Connection Error"
                                                            message:@"Unable to communicate with sled - battery depleted."
                                                           delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
        [sledAlert show];
82
83
84
85
86
87
88
         */
        UIAlertController *sledAlert = [UIAlertController alertControllerWithTitle:@"Connection Error" message:@"Unable to communicate with sled - battery depleted." preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            [sledAlert dismissViewControllerAnimated:YES completion:nil];
        }];
        [sledAlert addAction: ok];
        [self presentViewController:sledAlert animated:YES completion:nil];
89
90
91
    }
    //[[Captuvo sharedCaptuvoDevice] requestBatteryVoltage] ;
    //[[Captuvo sharedCaptuvoDevice] requestChargeStatus] ;
Alex Moore's avatar
Alex Moore committed
92
93
94
95
96
97
98
99
//    Codabar *codabarOptions = [[Codabar alloc] init];
//    codabarOptions.enabled = TRUE;
//    codabarOptions.transmitStatStopChar = FALSE;
//    codabarOptions.checkCharStatus = CodabarCheckCharNoCheckChar;
//    codabarOptions.concatenationStatus = CodabarConcatenationOff;
//    codabarOptions.minMessageLength = 4;
//    codabarOptions.maxMessageLength = 60;
//    [[Captuvo sharedCaptuvoDevice] setDecoderCodabarConfiguration:codabarOptions persistSetting:NO];
100
    
101
    [[Captuvo sharedCaptuvoDevice] setDecoderGoodReadDelayInMilliSeconds:2000 persistSetting:YES];
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
}



/**
 @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.txtBookID.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