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

时间:2015-10-03 19:40:34

标签: ios objective-c xcode uiviewcontroller

我有一个非常奇怪的问题,如果我插入IDTech Shuttle我的视图控制器加载后;它按预期连接。 (我正在使用自动连接功能)。

但是如果在我启动视图控制器/应用程序之前连接了设备;它根本不会调用umConnection_connected。 (它确实称为附加)

这也发生在随SDK提供的演示应用中。 (在iOS 8中运行,但在9中运行;但仍然是同一问题)

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

代码:

-(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");
}

以下是两种方案的调试日志:

LOG for在启动应用程序之前插入设备(没有工作)

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(Works)后插入设备的日志:

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 <<

1 个答案:

答案 0 :(得分:0)

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

[uniReader startUniMag: TRUE];

以便自动连接工作。

如果有人在iOS SDK中遇到依赖于自动连接的错误。我发现了以下7.9版本:

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

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