3

I am looking for help in integrating Captuvo SL22 SDK within appcelerator. The Captuvo SDK comes with the Captuvo scanner/msr for ipod. I am trying to use Captuvo SDK in a custom module and call it in the main app. I am able to establish a connection with the Captuvo Device by using the following code in the custom module startup method:

-(void) startup{
    self.captuvo = [Captuvo sharedCaptuvoDevice];
    [self.captuvo addCaptuvoDelegate:self];
    [self.captuvo startDecoderHardware];
}

-(void) DecoderReady{
    //Fire Event successfully to Titanium App
}

After the startup I try to turn the scanner on by hitting a button in the app, this is my code:

-(void) turnScannerOn{
    if([self.captuvo isDecoderRunning]){
        //Fire event successfully to Titanium App
        [self.captuvo startDecoderScanning];
    }
}

However, no matter what I try I cannot get the scanner to turn on for the life of me. I am using Titanium 3.1.1 for an iPod touch running iOS 6.1. Any help would be much appreciated! If I figure it out I will be sure to let others know!

Update: So an update on this is that I was able to get the this to kind of work. This to the tiapp.xml to scan:

<ios>
    <plist>
        <dict>
            <key>UISupportedExternalAccessoryProtocols</key>
            <array>
                <string>com.honeywell.scansled.protocol.decoder</string>
                <string>com.honeywell.scansled.protocol.msr</string>
                <string>com.honeywell.scansled.protocol.pm</string>
            </array>
        </dict>
    </plist>
</ios>

However, when you first startup the app, I am unable to turn on the scanner using a button, but the triggers on the side work, but no data is returned. Honeywell provided some sample code and I noticed that this code added to a native app makes the scanner work on the initial start up so I was wondering if there is a way to replicate this objective C code inside of titanium:

- (void)viewWillAppear:(BOOL)animated
{
    [[Captuvo sharedCaptuvoDevice] removeCaptuvoDelegate:self] ;
    [[Captuvo sharedCaptuvoDevice] addCaptuvoDelegate:self];
    [[Captuvo sharedCaptuvoDevice] startPMHardware];
    [[Captuvo sharedCaptuvoDevice] startDecoderHardware];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [[Captuvo sharedCaptuvoDevice] stopDecoderHardware];
    [[Captuvo sharedCaptuvoDevice] stopPMHardware];
    [[Captuvo sharedCaptuvoDevice] removeCaptuvoDelegate:self];
}
4

5 回答 5

5

确保您在 info.plist 中设置了“支持的外部附件”键,如下所示:

<string>com.honeywell.scansled.protocol.decoder</string>
<string>com.honeywell.scansled.protocol.msr</string>
<string>com.honeywell.scansled.protocol.pm</string>
于 2015-04-06T20:50:25.733 回答
1

取消对 isDecoderRunning 的检查。如果您还没有启动解码器,它将永远不会返回 true,并且您将永远无法到达启动解码器的代码。

此外,请确保您同时启动了条形码和 MSR:

    [self.captuvo startDecoderScanning];
    [self.captuvo startMSRHardware];

我也建议这样做:

    connectionStatus = [captuvo startDecoderHardware];
    switch (connectionStatus) {
        case ProtocolConnectionStatusConnected:
        case ProtocolConnectionStatusAlreadyConnected:
            NSLog(@"Connected!");
            break;
        case ProtocolConnectionStatusBatteryDepleted:
            NSLog(@"Battery depleted!");
            break;
        case ProtocolConnectionStatusUnableToConnect:
            NSLog(@"Error connecting!");
            break;
        case ProtocolConnectionStatusUnableToConnectIncompatiableSledFirmware:
            NSLog(@"Incompatible firmware!");
            break;
        default:
            break;
    }

这样您就可以检查尝试连接时发生的情况。

于 2013-09-23T21:31:58.203 回答
1

@Chris 对于你的更新问题,我写了和你一样的代码,在 viewWillDiseappear 中停止 stopDecoderHardware ,在 viewWillAppear 中停止 startDecoderHardware ,然后偶尔没有数据,但灯总是好的,所以我猜有一些问题是由启动和停止引起的,然后我删除了 viewController 中的所有 stopDecoderHardware 和 startDecoderHardware 方法,只保留 addDelegate 和 removeDelegate 方法,并修改 AppDelegate.m 文件中的方法,如下所示

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    [[Captuvo sharedCaptuvoDevice] startDecoderHardware];
}  
- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [[Captuvo sharedCaptuvoDevice] stopDecoderHardware];
}  

是的,可能会浪费电池,但似乎解决了没有数据获取的问题

于 2014-06-19T04:08:51.560 回答
0

这篇文章已经过时了,但我想如果其他人偶然发现这个问题,我会投入 2 美分来帮忙。

我发现我需要调用startDecoderHardware主 UI 线程,否则我不会收到条形码扫描回调。在我弄清楚这一点之前,我花了很多时间来解决这个问题。

于 2016-05-12T17:03:28.367 回答
-1

当您开始使用霍尼韦尔的 Captuvo SDK 时,您需要先阅读快速入门和发行说明,这将帮助您快速开始开发您自己的应用程序库 CaptuvoSDK for SL22/SL42/SL62

于 2016-10-31T03:07:28.680 回答