首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >升级UNIMAG 7.5 --> 7.16自动连接错误

升级UNIMAG 7.5 --> 7.16自动连接错误
EN

Stack Overflow用户
提问于 2015-10-04 03:40:34
回答 1查看 184关注 0票数 0

我遇到了一个非常奇怪的问题,如果我在视图控制器加载后插入IDTech穿梭程序,它会按预期进行连接。(我正在使用自动连接功能)。

但如果设备在我启动视图控制器/应用程序之前就连接上了,它根本不会调用umConnection_connected。(它确实调用了attach)

在SDK提供的演示应用程序中也会发生这种情况。(在iOS 8中运行,但不在9中运行;但仍然存在相同的问题)

这在7.5版本中没有发生,为了与苹果兼容,我需要升级到7.16。

代码:

代码语言:javascript
复制
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.toolbarHidden = NO;
    self.navigationController.navigationBarHidden = YES;

    //init alert views
    prompt_changeStoreUrl = [[UIAlertView alloc] initWithTitle:@"Confirmation"
                                                       message:@"Are you really sure you want to change store URL?"
                                                      delegate:self
                                             cancelButtonTitle:@"No"
                                             otherButtonTitles:@"Yes", nil];
    [self umsdk_activate];

}

-(void) umsdk_activate {

    NSLog(@"ACTIVATE");

    //register observers for all uniMag notifications
    [self umsdk_registerObservers:TRUE];


    //enable info level NSLogs inside SDK
    // Here we turn on before initializing SDK object so the act of initializing is logged
    [uniMag enableLogging:TRUE];

    //initialize the SDK by creating a uniMag class object
    uniReader = [[uniMag alloc] init];

     //Set the reader type to UMREADER_SHUTTLE
    uniReader.readerType = UMREADER_SHUTTLE;

    /*
     //set SDK to perform the connect task automatically when headset is attached
     */

     [uniReader setAutoConnect:TRUE];

    //set swipe timeout to infinite. By default, swipe task will timeout after 20 seconds
    [uniReader setSwipeTimeoutDuration:0];

    //make SDK maximize the volume automatically during connection
    [uniReader setAutoAdjustVolume:TRUE];

}


//called when the connection task is successful. SDK's connection state changes to true
- (void)umConnection_connected:(NSNotification *)notification
{
    NSLog(@"CONNECTED");

    [[[[iToast makeText:@"Connected Credit Card Reader"] setGravity:iToastGravityCenter] setDuration:iToastDurationNormal] show];
}


/called when uniMag is physically attached
- (void)umDevice_attachment:(NSNotification *)notification
{
    NSLog(@"ATTACH");
}

//called when uniMag is physically detached
- (void)umDevice_detachment:(NSNotification *)notification
{
    NSLog(@"DETACH");
}

#pragma mark attachment

//called when uniMag is physically attached
- (void)umDevice_attachment:(NSNotification *)notification
{
    NSLog(@"ATTACH");
}

以下是两种情况下的调试日志:

在启动应用之前记录设备插入的时间(不起作用)

代码语言:javascript
复制
2015-10-03 15:30:56.442 PHP POS[743:218493] ACTIVATE
2015-10-03 15:30:56.442 PHP POS[743:218493] [UM Info] --Init >>
2015-10-03 15:30:56.442 PHP POS[743:218493] [UM Info] --lock 01 >
2015-10-03 15:30:56.442 PHP POS[743:218493] [UM Info] SDK: initialized
2015-10-03 15:30:56.442 PHP POS[743:218493] [UM Info] --checkAndFireTachmentEvent only >= i6.0
2015-10-03 15:30:56.442 PHP POS[743:218493] [UM Info] --isHeadsetPluggedIn >= i6.0
2015-10-03 15:30:56.447 PHP POS[743:218493] [UM Info] --event_attachStateChanged >>
2015-10-03 15:30:56.447 PHP POS[743:218493] [UM Info] SysEvent: headset attached
2015-10-03 15:30:56.447 PHP POS[743:218493] [UM Info] --activateAudioSession: 1 >>
2015-10-03 15:30:56.518 PHP POS[743:218493] [UM Info] --activateAudioSession <<
2015-10-03 15:30:56.518 PHP POS[743:218493] [UM Info] --remoteControlEventEnable: 1 >>
2015-10-03 15:30:56.706 PHP POS[743:218493] [UM Info] --remoteControlEventEnable <<
2015-10-03 15:30:56.706 PHP POS[743:218493] [UM Info] --fire event Attach/Detach
2015-10-03 15:30:56.707 PHP POS[743:218493] [UM Info] --post, uniMagAttachmentNotification >>
2015-10-03 15:30:56.707 PHP POS[743:218493] [UM Info] --post <<
2015-10-03 15:30:56.707 PHP POS[743:218493] [UM Info] --event_attachStateChanged. <<
2015-10-03 15:30:56.707 PHP POS[743:218493] [UM Info] --regester callback
2015-10-03 15:30:56.707 PHP POS[743:218493] [UM Info] --Init <<
2015-10-03 15:30:56.707 PHP POS[743:218493] [UM Info] SDK: reader type set to Shuttle
2015-10-03 15:30:56.707 PHP POS[743:218493] [UM Info] --lock 08 >
2015-10-03 15:30:56.708 PHP POS[743:218493] [UM Info] --stopConnection >>
2015-10-03 15:30:56.708 PHP POS[743:218493] [UM Info] --stopConnection no <<
2015-10-03 15:30:56.709 PHP POS[743:218493] [UM Info] SDK: canceling task
2015-10-03 15:30:56.710 PHP POS[743:218493] [UM Info] SDK: TASK_NONE
2015-10-03 15:30:56.710 PHP POS[743:218493] [UM Info] SDK: task cancelled
2015-10-03 15:30:56.825 PHP POS[743:218493] [UM Info] --notifier >>
2015-10-03 15:30:56.826 PHP POS[743:218493] ATTACH
2015-10-03 15:30:56.826 PHP POS[743:218493] [UM Info] --notifier <<

启动app/view后插入设备时的日志(有效):

代码语言:javascript
复制
2015-10-03 15:33:45.402 PHP POS[754:219962] ACTIVATE
2015-10-03 15:33:45.403 PHP POS[754:219962] [UM Info] --Init >>
2015-10-03 15:33:45.403 PHP POS[754:219962] [UM Info] --lock 01 >
2015-10-03 15:33:45.403 PHP POS[754:219962] [UM Info] SDK: initialized
2015-10-03 15:33:45.403 PHP POS[754:219962] [UM Info] --checkAndFireTachmentEvent only >= i6.0
2015-10-03 15:33:45.403 PHP POS[754:219962] [UM Info] --isHeadsetPluggedIn >= i6.0
2015-10-03 15:33:45.408 PHP POS[754:219962] [UM Info] --regester callback
2015-10-03 15:33:45.408 PHP POS[754:219962] [UM Info] --Init <<
2015-10-03 15:33:45.409 PHP POS[754:219962] [UM Info] SDK: reader type set to Shuttle
2015-10-03 15:33:45.409 PHP POS[754:219962] [UM Info] --lock 08 >
2015-10-03 15:33:45.409 PHP POS[754:219962] [UM Info] --stopConnection >>
2015-10-03 15:33:45.409 PHP POS[754:219962] [UM Info] --stopConnection no <<
2015-10-03 15:33:45.409 PHP POS[754:219962] [UM Info] SDK: canceling task
2015-10-03 15:33:45.409 PHP POS[754:219962] [UM Info] SDK: TASK_NONE
2015-10-03 15:33:45.409 PHP POS[754:219962] [UM Info] SDK: task cancelled
2015-10-03 15:33:51.031 PHP POS[754:219999] [UM Info] --audioRouteChangeListenerCallback >=6.0
2015-10-03 15:33:51.032 PHP POS[754:219999] [UM Info] --plugged in
2015-10-03 15:33:51.032 PHP POS[754:219999] [UM Info] --event_attachStateChanged >>
2015-10-03 15:33:51.032 PHP POS[754:219999] [UM Info] SysEvent: headset attached
2015-10-03 15:33:51.033 PHP POS[754:219999] [UM Info] --activateAudioSession: 1 >>
2015-10-03 15:33:51.226 PHP POS[754:219999] [UM Info] --activateAudioSession <<
2015-10-03 15:33:51.228 PHP POS[754:219999] [UM Info] --remoteControlEventEnable: 1 >>
2015-10-03 15:33:51.427 PHP POS[754:219999] [UM Info] --remoteControlEventEnable <<
2015-10-03 15:33:51.428 PHP POS[754:219999] [UM Info] --startTaskConnect >>
2015-10-03 15:33:51.430 PHP POS[754:219999] [UM Info] --post, uniMagPoweringNotification >>
2015-10-03 15:33:51.430 PHP POS[754:219962] [UM Info] --notifier >>
2015-10-03 15:33:51.431 PHP POS[754:219962] STARTING CONN
2015-10-03 15:33:51.431 PHP POS[754:219962] [UM Info] --notifier <<
2015-10-03 15:33:51.431 PHP POS[754:219999] [UM Info] --post <<
2015-10-03 15:33:51.431 PHP POS[754:219999] [UM Info] --startTaskConnect <<
2015-10-03 15:33:51.431 PHP POS[754:219999] [UM Info] --fire event Attach/Detach
2015-10-03 15:33:51.431 PHP POS[754:219999] [UM Info] --post, uniMagAttachmentNotification >>
2015-10-03 15:33:51.431 PHP POS[754:219962] [UM Info] --notifier >>
2015-10-03 15:33:51.431 PHP POS[754:219962] ATTACH
2015-10-03 15:33:51.432 PHP POS[754:219962] [UM Info] --notifier <<
2015-10-03 15:33:51.432 PHP POS[754:219999] [UM Info] --post <<
2015-10-03 15:33:51.432 PHP POS[754:219999] [UM Info] --event_attachStateChanged. <<
2015-10-03 15:33:51.432 PHP POS[754:219986] [UM Info] Connect: task start. um mode
2015-10-03 15:33:51.432 PHP POS[754:219999] [UM Info] --audioRouteChangeListenerCallback <<
2015-10-03 15:33:51.432 PHP POS[754:219986] [UM Info] --connect Main >>
2015-10-03 15:33:51.461 PHP POS[754:219986] [UM Info] Connect: set channel
2015-10-03 15:33:51.461 PHP POS[754:219986] [UM Info] to sendCMD: <02534101 350327>
2015-10-03 15:33:51.465 PHP POS[754:219999] [UM Info] --audioRouteChangeListenerCallback >=6.0
2015-10-03 15:33:51.465 PHP POS[754:219999] [UM Info] --ReasonCategory
2015-10-03 15:33:51.466 PHP POS[754:219999] [UM Info] --isHeadsetPluggedIn >= i6.0
2015-10-03 15:33:51.473 PHP POS[754:219999] [UM Info] --event_attachStateChanged >>
2015-10-03 15:33:51.474 PHP POS[754:219999] [UM Info] --event_attachStateChanged 1. <<
2015-10-03 15:33:51.474 PHP POS[754:219999] [UM Info] --audioRouteChangeListenerCallback <<
2015-10-03 15:33:52.381 PHP POS[754:219986] [UM Info] packet detected
2015-10-03 15:33:52.386 PHP POS[754:219986] [UM Info] RD: read 1 bytes: 
 06
2015-10-03 15:33:52.387 PHP POS[754:219986] [UM Info] Connect: connected 'baud'
2015-10-03 15:33:52.403 PHP POS[754:219986] [UM Info] --connect Main <<
2015-10-03 15:33:52.404 PHP POS[754:219986] [UM Info] Connect: task stop
2015-10-03 15:33:52.404 PHP POS[754:219986] [UM Info] --post, uniMagDidConnectNotification >>
2015-10-03 15:33:52.405 PHP POS[754:219962] [UM Info] --notifier >>
2015-10-03 15:33:52.405 PHP POS[754:219962] CONNECTED
2015-10-03 15:33:52.405 PHP POS[754:219986] [UM Info] --post <<
2015-10-03 15:33:52.410 PHP POS[754:219962] [UM Info] --notifier <<
EN

回答 1

Stack Overflow用户

发布于 2015-10-04 09:45:09

另一种修复方法是此版本的API更改。您需要做的是:

[uniReader startUniMag: TRUE];

为了让自动连接正常工作。

如果任何人在依赖于自动连接的iOS SDK中遇到此错误。我在以下位置找到了以下7.9版本:

https://github.com/MercuryPay/IDTech.Shuttle.ObjC/tree/570487a30dd0ddbf646a0f788d37b257de0a0b86/HC.POS/uniMag-SDK

(我确保了特定提交时的链接,以防此存储库将来更新)。没有自动连接功能,支持64位。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32926729

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档