Parcourir la source

contrast mobile 1.99

support ble scanner
Ray Zhang il y a 3 ans
Parent
commit
e7a12ccac8

+ 4 - 4
RA Image/RA Image.xcodeproj/project.pbxproj

@@ -1008,12 +1008,12 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 47192;
+				CURRENT_PROJECT_VERSION = 52472;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				INFOPLIST_FILE = "RA Image/Info.plist";
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 1.17;
+				MARKETING_VERSION = 1.19;
 				PRODUCT_BUNDLE_IDENTIFIER = "usai.redant.RA-Image";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";
@@ -1025,12 +1025,12 @@
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 47192;
+				CURRENT_PROJECT_VERSION = 52472;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				INFOPLIST_FILE = "RA Image/Info.plist";
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 1.17;
+				MARKETING_VERSION = 1.19;
 				PRODUCT_BUNDLE_IDENTIFIER = "usai.redant.RA-Image";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE_SPECIFIER = "";

+ 2 - 2
RedAnt ERP Mobile/HMLG Scan Order.xcodeproj/project.pbxproj

@@ -2519,7 +2519,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 52062;
+				CURRENT_PROJECT_VERSION = 52313;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2567,7 +2567,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 52062;
+				CURRENT_PROJECT_VERSION = 52313;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",

+ 1 - 1
RedAnt ERP Mobile/HMLG Scan Order.xcodeproj/xcuserdata/ruizhang.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -7,7 +7,7 @@
 		<key>HMLG Scan Order.xcscheme_^#shared#^_</key>
 		<dict>
 			<key>orderHint</key>
-			<integer>5</integer>
+			<integer>4</integer>
 		</dict>
 	</dict>
 </dict>

+ 28 - 2
RedAnt ERP Mobile/common/AppDelegateBase.h

@@ -12,6 +12,7 @@
 #import "UIResponder+Router.h"
 #import "iSalesDB.h"
 #import "SyncControlPanelViewController.h"
+#import <CoreBluetooth/CoreBluetooth.h>
 
 #ifdef SCANNER_ORDER
 #import "RAUploadManager.h"
@@ -32,7 +33,7 @@ typedef enum {
 } CustomerType;
 
 @interface AppDelegateBase : UIResponder<UIApplicationDelegate , NSURLConnectionDataDelegate
-,ScanApiHelperDelegate>
+,ScanApiHelperDelegate,CBCentralManagerDelegate, CBPeripheralDelegate>
 //{
 //        id<ScannerEventsFeedback> _eventsFeedback;
 //}
@@ -93,7 +94,7 @@ typedef enum {
 @property (strong,nonatomic) NSString * duid;
 @property bool bLogin;
 
-@property long user_type;
+@property (nonatomic) long user_type;
 @property CustomerType customer_type;
 
 
@@ -218,4 +219,29 @@ typedef enum {
 @property (strong, nonatomic)  NSArray *available_price_group;
 
 #endif
+
+
+
+@property (nonatomic, strong) CBCentralManager *manager;
+@property (nonatomic, strong) CBPeripheral *peripheral;
+@property (strong ,nonatomic) CBCharacteristic *writeCharacteristic;
+@property (strong,nonatomic) NSMutableArray *nDevices;
+@property (strong,nonatomic) NSMutableArray *nServices;
+@property (strong,nonatomic) NSMutableArray *nCharacteristics;
+@property (strong,nonatomic) NSString *strBTLog;
+@property (nonatomic,strong) NSDate *forgroundDate;
+@property bool bAutoConnect;
+@property bool cbReady;
+@property bool bAppBTOn;
+@property bool bBTAuthorize;
+@property (strong,nonatomic) NSString *strDeviceName;
+@property (strong,nonatomic) NSString *strDeviceUUID;
+
+-(void) scanBLE;
+-(void) stopScanBLE;
+-(void) disconnectDevice;
+-(void)setBLEAutoReconnect:(bool) bAutoReconnect;
+
+
+-(void) enableBLE:(bool) bEnable;
 @end

+ 428 - 4
RedAnt ERP Mobile/common/AppDelegateBase.m

@@ -41,11 +41,13 @@
 #define UNZIP_SUCCESS 1
 #define UNZIP_NO_SPACE 2
 #define UNZIP_FILE_DAMAGE 3
-@interface AppDelegateBase ()
 
 
 
-@property (nonatomic,strong) NSDate *forgroundDate;
+
+@interface AppDelegateBase ()
+
+
 
 @end
 @implementation AppDelegateBase
@@ -600,8 +602,9 @@ void UncaughtExceptionHandler(NSException *exception) {
 
     });
     
-    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    
 #ifdef SCANNER_ORDER
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
         [appDelegate saveUploadTasks];
 #endif
 }
@@ -2902,6 +2905,32 @@ void UncaughtExceptionHandler(NSException *exception) {
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
     
+    
+    // 蓝牙扫描枪
+    
+    
+    self.manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
+    _cbReady = false;
+    _nDevices = [[NSMutableArray alloc]init];
+    _nServices = [[NSMutableArray alloc]init];
+    _nCharacteristics = [[NSMutableArray alloc]init];
+    
+    
+    
+    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+    self.bAutoConnect=[defaults boolForKey:@"BLE_AutoReconnect"];
+    self.bAppBTOn=[defaults boolForKey:@"BLE_Enable"];
+    if(self.bAutoConnect)
+    {
+        self.strDeviceName = [defaults valueForKey:@"BLE_Name"];
+        self.strDeviceUUID = [defaults valueForKey:@"BLE_UUID"];
+    }
+
+    
+
+//    [defaults removeObjectForKey:@"BLE_AutoReconnect"];
+    
+    
 #ifdef SCANNER_ORDER
     //审核时连接测试数据库
     
@@ -3058,7 +3087,7 @@ void UncaughtExceptionHandler(NSException *exception) {
     
     
     self.recent_model = [[NSMutableDictionary alloc]init];
-    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+//    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
     bool  offline = [defaults boolForKey:@"EnableOfflineMode"] ;
     self.offline_mode = offline;
     // Override point for customization after application launch.
@@ -3845,4 +3874,399 @@ void UncaughtExceptionHandler(NSException *exception) {
     return nil;
 }
 #endif
+
+#pragma mark - core bluetooth
+
+-(void) disconnectDevice
+{
+    if(self.peripheral)
+        [self.manager cancelPeripheralConnection:self.peripheral];
+    
+    if( self.bAppBTOn ==true)
+       [self scanBLE];
+}
+-(void)setBLEAutoReconnect:(bool) bAutoReconnect
+{
+    self.bAutoConnect = true;
+    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+    [defaults removeObjectForKey:@"BLE_Name"];
+    [defaults removeObjectForKey:@"BLE_UUID"];
+    [defaults removeObjectForKey:@"BLE_AutoReconnect"];
+    if(bAutoReconnect&&self.peripheral)
+    {
+        
+        
+        
+        [defaults setValue:self.peripheral.name forKey: @"BLE_Name"];
+        [defaults setValue:self.peripheral.identifier.UUIDString forKey: @"BLE_UUID"];
+
+    
+        
+        
+        
+    }
+    else
+    {
+        self.strDeviceName = nil;
+        self.strDeviceUUID=nil;
+    }
+  
+    [defaults setBool:bAutoReconnect forKey:@"BLE_AutoReconnect"];
+    
+    [defaults synchronize];
+}
+-(void) enableBLE:(bool) bEnable
+{
+    self.bAppBTOn =bEnable;
+    
+    NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
+    [defaults removeObjectForKey:@"BLE_Enable"];
+    [defaults setBool:self.bAppBTOn forKey:@"BLE_Enable"];
+    [defaults synchronize];
+    if(bEnable)
+        [self scanBLE];
+    else
+        [self stopScanBLE];
+}
+
+-(void) scanBLE
+{
+    
+
+    switch (self.manager.state) {
+        case CBManagerStatePoweredOn:
+        {
+            [self updateLog:@"Scanning..."];
+            
+            [_manager scanForPeripheralsWithServices:/*@[[CBUUID UUIDWithString:@"FFF0"]]*/nil  options:@{CBCentralManagerScanOptionAllowDuplicatesKey : @false}];
+//            [_manager scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:@"FFF0"]]  options:@{CBCentralManagerScanOptionAllowDuplicatesKey : @true}];
+        }
+            break;
+        case CBManagerStatePoweredOff:
+            [self updateLog:@"Please turn on bluetooth。"];
+            break;
+        default:
+            break;
+    }
+}
+-(void) stopScanBLE
+{
+//    self.bAppBTOn = false;
+    [self.manager stopScan];
+    
+    if(self.self.peripheral)
+        [self.manager cancelPeripheralConnection:self.peripheral];
+    self.nDevices = [NSMutableArray new];
+    self.peripheral = nil;
+    if((_eventsFeedback!=nil)&&([_eventsFeedback respondsToSelector:@selector(OnUpdateDevicesList)])){
+        [_eventsFeedback OnUpdateDevicesList];
+    }
+    
+}
+//检查蓝牙状态
+- (void)centralManagerDidUpdateState:(nonnull CBCentralManager *)central {
+    switch (central.state) {
+        case CBManagerStatePoweredOn:
+        {
+            [self updateLog:@"Bluetooth on."];
+            self.bBTAuthorize = true;
+           if(self.bAppBTOn)
+           {
+               [_manager scanForPeripheralsWithServices:/*@[[CBUUID UUIDWithString:@"FFF0"]]*/nil  options:@{CBCentralManagerScanOptionAllowDuplicatesKey : @false}];
+           }
+            
+//            [_manager scanForPeripheralsWithServices:@[[CBUUID UUIDWithString:@"FFF0"]]  options:@{CBCentralManagerScanOptionAllowDuplicatesKey : @true}];
+        }
+            break;
+        case CBManagerStatePoweredOff:
+            [self updateLog:@"Bluetooth off."];
+            self.bBTAuthorize = true;
+            break;
+            
+        case CBManagerStateUnauthorized:
+                  //蓝牙未授权
+                    
+                    // app一定未授权,蓝牙是否开启不知
+            [self updateLog:@"Bluetooth Unauthorized."];
+            
+            self.bBTAuthorize = false;
+            
+            if((_eventsFeedback!=nil)&&([_eventsFeedback respondsToSelector:@selector(onStatusChanged:)])){
+                [_eventsFeedback onStatusChanged:@"Unauthorized"];
+            }
+            break;
+        default:
+            break;
+    }
+}
+-(void)updateLog:(NSString*) log
+{
+//    NSLog(log);
+//
+//    self.strBTLog=[self.strBTLog stringByAppendingString:[log stringByAppendingString:@"\n"]];
+
+    [self addlog:log];
+}
+
+
+
+
+//查到外设后,停止扫描,连接设备
+-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
+{
+//    NSLog(@"didDiscoverPeripheral");
+    
+    NSArray* pservice = advertisementData[@"kCBAdvDataServiceUUIDs"];
+    if(pservice.count<=0)
+        return;
+    if(peripheral.name.length<=0)
+        return;
+//    _peripheral = peripheral;
+//    [_manager connectPeripheral:_peripheral options:nil];
+//    [self.manager stopScan];
+//    [_activity stopAnimating];
+    BOOL replace = NO;
+    // Match if we have this device from before
+    for (int i=0; i < _nDevices.count; i++) {
+        CBPeripheral *p = [_nDevices objectAtIndex:i];
+        if ([p isEqual:peripheral]) {
+            [_nDevices replaceObjectAtIndex:i withObject:peripheral];
+            replace = YES;
+        }
+    }
+    if (!replace) {
+        [_nDevices addObject:peripheral];
+        [self updateLog:[NSString stringWithFormat:@"Found device: %@ rssi: %@, UUID: %@ advertisementData: %@ ", peripheral, RSSI, peripheral.identifier, advertisementData]];
+    }
+    
+    if((_eventsFeedback!=nil)&&([_eventsFeedback respondsToSelector:@selector(OnUpdateDevicesList)])){
+        [_eventsFeedback OnUpdateDevicesList];
+    }
+    
+    if(self.bAutoConnect&& [self.strDeviceUUID isEqualToString:peripheral.identifier.UUIDString])
+    {
+        self.peripheral = peripheral;
+        NSString* log = [NSString stringWithFormat:@"Reconnect to device %@ ...", peripheral.name];
+        [self updateLog:log];
+        NSLog(@"Retrying");
+        [self.manager connectPeripheral:peripheral options:nil];
+    }
+        
+//    if(peripheral.identifier == self.peripheral.identifier)
+//    {
+//        //重新连接
+//        [_manager connectPeripheral:_peripheral options:nil];
+//    }
+  
+    //[_bluetoothTable reloadData];
+}
+
+//连接外设成功,开始发现服务
+- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {
+    NSLog(@"%@", [NSString stringWithFormat:@"成功连接 peripheral: %@ with UUID: %@",peripheral,peripheral.identifier]);
+    [self updateLog:[NSString stringWithFormat:@"Connect peripheral: %@ with UUID: %@",peripheral,peripheral.identifier]];
+    [self.peripheral setDelegate:self];
+    [self.peripheral discoverServices:nil];
+    
+    if((_eventsFeedback!=nil)&&([_eventsFeedback respondsToSelector:@selector(onStatusChanged:)])){
+        [_eventsFeedback onStatusChanged:@"Connected"];
+    }
+//    [self updateLog:@"扫描服务"];
+}
+//连接外设失败
+-(void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error
+{
+    NSLog(@"%@",error);
+    [self updateLog:@"Failed to connect device."];
+}
+-(void)peripheralDidUpdateRSSI:(CBPeripheral *)peripheral error:(NSError *)error
+{
+    NSLog(@"%s,%@",__PRETTY_FUNCTION__,peripheral);
+    int rssi = abs([peripheral.RSSI intValue]);
+    CGFloat ci = (rssi - 49) / (10 * 4.);
+    NSString *length = [NSString stringWithFormat:@"Found hotpoint:%@,distence:%.1fm",_peripheral,pow(10,ci)];
+    [self updateLog:[NSString stringWithFormat:@"Distence:%@", length]];
+}
+
+
+//已发现服务
+-(void) peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error{
+    [self updateLog:@"Found service."];
+    int i=0;
+    for (CBService *s in peripheral.services) {
+        [self.nServices addObject:s];
+    }
+    for (CBService *s in peripheral.services) {
+        [self updateLog:[NSString stringWithFormat:@"%d :service UUID: %@(%@)",i,s.UUID.data,s.UUID]];
+        i++;
+        [peripheral discoverCharacteristics:nil forService:s];
+//        if ([s.UUID isEqual:[CBUUID UUIDWithString:@"FFF0"]])
+//        {
+//            BOOL replace = NO;
+//            // Match if we have this device from before
+//            for (int i=0; i < _nDevices.count; i++) {
+//                CBPeripheral *p = [_nDevices objectAtIndex:i];
+//                if ([p isEqual:peripheral]) {
+//                    [_nDevices replaceObjectAtIndex:i withObject:peripheral];
+//                    replace = YES;
+//                }
+//            }
+//            if (!replace) {
+//                [_nDevices addObject:peripheral];
+////                [_bluetoothTable reloadData];
+//            }
+//        }
+    }
+}
+//已搜索到Characteristics
+-(void) peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error{
+    [self updateLog:[NSString stringWithFormat:@"service:%@ (%@)",service.UUID.data ,service.UUID]];
+    for (CBCharacteristic *c in service.characteristics)
+    {
+        [self updateLog:[NSString stringWithFormat:@"Characteristic UUID: %@ (%@)",c.UUID.data,c.UUID]];
+        
+        if(c.properties& CBCharacteristicPropertyWrite) //写
+//        if ([c.UUID isEqual:[CBUUID UUIDWithString:@"FFF2"]])
+        {
+
+            _writeCharacteristic = c;
+        }
+        if (c.properties&CBCharacteristicPropertyNotify) // 通知
+//        if ([c.UUID isEqual:[CBUUID UUIDWithString:@"FFF1"]])
+        {
+            [_peripheral readValueForCharacteristic:c];
+            [_peripheral setNotifyValue:YES forCharacteristic:c];
+        }
+    }
+}
+
+- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
+    [self updateLog:[NSString stringWithFormat:@"Disconnect device:[%@]", peripheral.name]];
+    if((_eventsFeedback!=nil)&&([_eventsFeedback respondsToSelector:@selector(onStatusChanged:)])){
+        [_eventsFeedback onStatusChanged:@"Disconnected"];
+    }
+    
+    if ([self.peripheral.identifier.UUIDString isEqualToString:peripheral.identifier.UUIDString]) {
+        [self updateLog:@"Retrying..."];
+        NSLog(@"Retrying");
+        [self.manager connectPeripheral:peripheral options:nil];
+    }
+}
+
+
+
+- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
+{
+    NSLog(@"didUpdateValueForCharacteristic from Characteristic %@",characteristic.UUID);
+    NSData * data = characteristic.value;
+    
+    
+    NSString *datastring = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+    
+    datastring = [datastring stringByReplacingOccurrencesOfString:@"\r" withString:@""];
+    
+    NSLog(datastring);
+    
+    
+    if((_eventsFeedback!=nil)&&([_eventsFeedback respondsToSelector:@selector(onDecodedData:)])){
+        [_eventsFeedback onDecodedData:datastring];
+    }
+    
+    [self addlog:datastring];
+    
+//    if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:@"FF02"]]) {
+//        NSData * data = characteristic.value;
+//        Byte * resultByte = (Byte *)[data bytes];
+//        for(int i=0;i<[data length];i++)
+//            printf("testByteFF02[%d] = %d\n",i,resultByte[i]);
+//        if (resultByte[1] == 0) {
+//        }else if (resultByte[1] == 1) {
+//            [self updateLog:@"未知错误"];
+//        }else if (resultByte[1] == 2) {
+//            [self updateLog:@"鉴权失败"];
+//        }
+//    }
+//    if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:@"FF04"]]) {
+//        NSData * data = characteristic.value;
+//        Byte * resultByte = (Byte *)[data bytes];
+//        for(int i=0;i<[data length];i++)
+//            printf("testByteFF04[%d] = %d\n",i,resultByte[i]);}
+//    if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:@"FF05"]]) {
+//        NSData * data = characteristic.value;
+//        Byte * resultByte = (Byte *)[data bytes];
+//        for(int i=0;i<[data length];i++)
+//            printf("testByteFF05[%d] = %d\n",i,resultByte[i]);
+//        if (resultByte[0] == 0) {
+//            // 设备加解锁状态 0 撤防     1 设防
+//            [self updateLog:@"当前车辆撤防状态"];
+//        }else if (resultByte[0] == 1) {
+//            // 设备加解锁状态 0 撤防     1 设防
+//            [self updateLog:@"当前车辆设防状态"];
+//        }
+//    }
+}
+//中心读取外设实时数据
+- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
+    if (error) {
+        NSLog(@"Error changing notification state: %@", error.localizedDescription);
+    }
+    // Notification has started
+    if (characteristic.isNotifying) {
+        [peripheral readValueForCharacteristic:characteristic];
+    } else { // Notification has stopped
+        // so disconnect from the peripheral
+        NSLog(@"Notification stopped on %@.  Disconnecting", characteristic);
+        [self updateLog:[NSString stringWithFormat:@"Notification stopped on %@.  Disconnecting", characteristic]];
+        [self.manager cancelPeripheralConnection:self.peripheral];
+    }
+}
+//用于检测中心向外设写数据是否成功
+-(void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
+{
+    if (error) {
+        NSLog(@"=======%@",error.userInfo);
+        
+        
+        [self updateLog:[RAConvertor dict2string:error.userInfo]];
+    }else{
+        NSLog(@"发送数据成功");
+        [self updateLog:@"Send data."];
+    }
+    /* When a write occurs, need to set off a re-read of the local CBCharacteristic to update its value */
+    [peripheral readValueForCharacteristic:characteristic];
+}
+
+
+
+//
+////#parammark tableview
+//
+//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+//    return self.nDevices.count;
+//}
+//
+//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+//    static NSString *CellIdentifier = @"Cell";
+//  //      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
+//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+//    if (!cell) {
+//        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
+//    }
+//
+//    CBPeripheral *p=self.nDevices[indexPath.item];
+//    NSString* name = p.name;
+//    if(name.length==0)
+//        name=@"NO Name";
+//    cell.textLabel.text = name;
+//
+//    return cell;
+//}
+//-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
+//{
+//    CBPeripheral *p=self.nDevices[indexPath.item];
+//
+//        _peripheral = p;
+//        [_manager connectPeripheral:_peripheral options:nil];
+//}
+
 @end

+ 48 - 2
RedAnt ERP Mobile/common/Functions/MainViewController.m

@@ -6,6 +6,8 @@
 //  Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
 //
 
+
+
 #import "MainViewController.h"
 //#import "SideMenuViewController.h"
 //#import "RootContainerViewController.h"
@@ -33,6 +35,10 @@
 #import "NotificationNameCenter.h"
 //#import "OLOSettingViewController.h"
 #import "CustomerEditViewController.h"
+
+#ifdef USE_BLE_SCANNER
+#import "CommonScannerSettingViewController.h"
+#endif
 @interface MainViewController ()
 
 @end
@@ -2124,11 +2130,25 @@
     //    [map setValue:@"rect_search_history" forKey:@"img"];
     //    [self.sideMenuItems addObject:map.copy];
     //
-#if defined(BUILD_NPD)
+#if defined(USE_MFI_SCANNER)
     [map setValue:@"Scanner Setting" forKey:@"title"];
     [map setValue:@"rect_change_password" forKey:@"img"];
     [self.sideMenuItems addObject:map.copy];
 # endif
+#ifdef USE_BLE_SCANNER
+    {
+        //        [map setValue:@"Contact" forKey:@"title"];
+        //        [map setValue:@"rect_contact_list" forKey:@"img"];
+        //        [self.sideMenuItems addObject:map.copy];
+        
+        
+        [map setValue:@"Scanner Setting" forKey:@"title"];
+        [map setValue:@"rect_change_password" forKey:@"img"];
+        [self.sideMenuItems addObject:map.copy];
+        
+
+    }
+#endif
     
 #if defined(SCANNER_ORDER)
     [map setValue:@"Scanner Order" forKey:@"title"];
@@ -2870,7 +2890,7 @@
     {
         
         
-        
+#ifdef USE_MFI_SCANNER
 //
 #ifndef RA_NOTIFICATION
         UIApplication * app = [UIApplication sharedApplication];
@@ -2903,6 +2923,32 @@
             //   self.btop = false;
             //  <#code#>
         }];
+#else
+#ifdef USE_BLE_SCANNER
+
+        CommonScannerSettingViewController * gunVC =[[UIStoryboard storyboardWithName:@"commonScanner" bundle:nil] instantiateViewControllerWithIdentifier:@"CommonScannerSettingViewController"];
+        UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:gunVC] ;
+        
+        
+        
+        
+        
+        //    [self hackModalSheetSize:CGSizeMake(450, 200) ofVC:navi];
+        navi.modalInPresentation = true;
+        navi.modalPresentationStyle = UIModalPresentationFullScreen;//有三种状态,自己看看是哪种
+        [self presentViewController:navi animated:YES completion:^{
+            
+            //        navi.view.superview.bounds = CGRectMake(0, 0, 480, 320);
+            
+            DebugLog(@"about present.........");
+            
+            //   self.btop = false;
+            //  <#code#>
+        }];
+#endif
+        
+#endif
+        
     }
     else if([title isEqualToString:@"Offline Setting"])
     {

+ 44 - 114
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -5637,6 +5637,48 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
 {
     
     
+    
+#ifdef QUERY_BY_UPC
+    
+    {
+        [RANetwork request_addto_cart_byupc:modelname withScreen:ScreenCodeCamScan completionHandler:^(NSMutableDictionary *result) {
+            NSDictionary* return_json = result;
+            
+            
+            
+            
+            if([[return_json valueForKey:@"result"] intValue]==2)
+            {
+                
+                
+                
+                
+                
+    #ifdef RA_NOTIFICATION
+                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
+    #else
+                
+                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
+                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
+    #endif
+                
+                
+            }
+            else
+            {
+                
+                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
+            }
+            
+            
+            
+            
+            
+        }];
+    }
+#else
+    
     [RANetwork request_addto_cart_byname:modelname withScreen:ScreenCodeCart completionHandler:^(NSMutableDictionary *result) {
         
         
@@ -5746,121 +5788,9 @@ commitEditingStyle:(UITableViewCellEditingStyle)editingStyle  forRowAtIndexPath:
         
         
     }];
+
     
-//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//
-//        NSDictionary* return_json = [RANetwork add_toCart_byName: modelname withScreen:ScreenCodeCart];
-//
-//        dispatch_async(dispatch_get_main_queue(), ^{
-//
-//
-//
-//            if([[return_json valueForKey:@"result"] intValue]==2)
-//            {
-//                NSDictionary* newitem = [return_json objectForKey:@"item_0"];
-//                NSString* item_id = [newitem valueForKey:@"cart_item_id"];
-//                //  bool isnew=false;
-////
-//                //                [((MainViewController*)appDelegate.main_vc) reloadWish:true immediately:false];
-//
-//                if (self.back_order_flag) {
-//
-//                    NSInteger section_count = [self sectionCount];
-//                    for (int i = 0; i < section_count; i++) {
-//                        NSInteger item_count = [self itemCountInSection:i];
-//                        BOOL ready_break = NO;
-//                        for (int j = 0; j < item_count; j++) {
-//                            NSIndexPath *indexPath = [NSIndexPath indexPathForRow:j inSection:i];
-//                            NSDictionary* obj_json = [self itemJsonAtIndexPath:indexPath];
-//                            NSString* _id =[obj_json valueForKey:@"cart_item_id"];
-//                            if([_id isEqualToString:item_id])
-//                            {
-//                                [self updateItemJson:nil atIndexPath:indexPath];
-//                                ready_break = YES;
-//                                break;
-//                            }
-//                        }
-//                        if (ready_break) {
-//                            break;
-//                        }
-//
-//
-//                    }
-//
-//                } else {
-//
-//                    for(int i=0;i<self.content_arr.count;i++)
-//                    {
-//                        NSDictionary* obj_json = self.content_arr[i];
-//                        NSString* _id =[obj_json valueForKey:@"cart_item_id"];
-//                        if([_id isEqualToString:item_id])
-//                        {
-//                            //                        self.content_arr[i] = newitem;
-//
-//
-//                            [self.content_arr removeObjectAtIndex:i];
-//
-//                            break;
-//                            //                        [self.content_arr removeObjectAtIndex:i];
-//                            //                        [self.itemListTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];
-//                            //                        appDelegate.cart_count--;
-//                            //                        [appDelegate update_count_mark];
-//                        }
-//
-//
-//                    }
-//                }
-//
-//                AppDelegate *appDelegate =nil;
-//                appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
-//#ifdef OFFLINE_MODE
-//
-//                if(appDelegate.offline_mode)
-//                {
-//
-//                    [self ReloadData];
-//
-//                }
-//                else
-//#endif
-//                {
-//
-//                    if (self.back_order_flag) {
-//                        [self ReloadData];
-//                    } else {
-//                        [self.content_arr insertObject:newitem atIndex:0];
-//
-//                        [self.itemListTable reloadData];
-//                        [self refresh_total];
-//                    }
-//
-//                }
-//
-//                //                AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//
-//
-//
-//
-//#ifdef RA_NOTIFICATION
-//                [ActiveViewController Notify:@"CartViewController,OrderListViewController" Message:RA_NOTIFICATION_RELOAD_DATA];
-//#else
-//                [((MainViewController*)appDelegate.main_vc) reloadCart:true immediately:false];
-//                [((MainViewController*)appDelegate.main_vc) reloadOrder:true immediately:false];
-//#endif
-//
-//
-//            }
-//            else
-//            {
-//
-//                [RAUtils message_alert:[return_json valueForKey:@"err_msg"] title:@"Add To Cart" controller:self] ;
-//            }
-//
-//
-//
-//
-//        });
-//    });
+#endif
     
     
 }

+ 17 - 0
RedAnt ERP Mobile/common/common Scanner/CommonScannerSettingViewController.h

@@ -0,0 +1,17 @@
+//
+//  CommonScannerSettingViewController.h
+//  iSales-CONTRAST
+//
+//  Created by Rui Zhang on 12/9/22.
+//  Copyright © 2022 United Software Applications, Inc. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "ActiveViewController.h"
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CommonScannerSettingViewController : ActiveViewController
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 239 - 0
RedAnt ERP Mobile/common/common Scanner/CommonScannerSettingViewController.m

@@ -0,0 +1,239 @@
+//
+//  CommonScannerSettingViewController.m
+//  iSales-CONTRAST
+//
+//  Created by Rui Zhang on 12/9/22.
+//  Copyright © 2022 United Software Applications, Inc. All rights reserved.
+//
+
+#import "CommonScannerSettingViewController.h"
+#import "AppDelegate.h"
+#import <UserNotifications/UserNotifications.h>
+
+@interface CommonScannerSettingViewController ()
+@property (weak, nonatomic) IBOutlet UIButton *btnConnect;
+@property (weak, nonatomic) IBOutlet UILabel *labelDevice;
+@property (weak, nonatomic) IBOutlet UITableView *tableDiscover;
+@property (weak, nonatomic) IBOutlet UITextView *tvLog;
+@property (weak, nonatomic) IBOutlet UISwitch *swEnable;
+@property (weak, nonatomic) IBOutlet UISwitch *swAuto;
+//@property (strong, nonatomic)  NSString *needVerifyUUID;
+@end
+
+@implementation CommonScannerSettingViewController
+- (IBAction)onDisconnect:(id)sender {
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if(appDelegate.peripheral)
+    {
+        
+        [appDelegate.manager cancelPeripheralConnection:appDelegate.peripheral];
+        appDelegate.peripheral = nil;
+    }
+    [appDelegate setBLEAutoReconnect:false];
+}
+
+- (void)onCloseClick:(UIButton *)sender {
+    
+
+    [self dismissViewControllerAnimated:true completion:^{
+//            if(self.onDismissVC)
+//            self.onDismissVC();
+    }];
+}
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    self.btnConnect.enabled = false;
+    self.support_scanner = true;
+    
+    UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
+                                                                    style:UIBarButtonItemStylePlain
+                                                                   target:self
+                                                                   action:@selector( onCloseClick:)];
+    self.navigationItem.rightBarButtonItem = closeButton;
+
+//    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
+//    // CFShow(infoDictionary);
+//    // app名称
+//    NSString *app_Name = [infoDictionary objectForKey:@"CFBundleName"];
+//    // app版本
+//    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
+//    // app build版本
+//    NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];
+//
+//
+//    NSString* appinfo =[NSString stringWithFormat:@"App info: %@   %@ build%@",app_Name,app_Version,app_build];
+//    self.appinfoLabel.text = appinfo;
+    self.tvLog.layer.borderWidth=1 ; //边框粗细
+    self.tvLog.layer.borderColor=[UIColor darkGrayColor].CGColor; //边框颜色
+    
+    
+    
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    self.tvLog.text = appDelegate.log;
+    
+    
+    [self.swAuto setOn:appDelegate.bAutoConnect];
+    [self.swEnable setOn:appDelegate.bAppBTOn];
+    
+    
+    self.btnConnect.enabled = (appDelegate.peripheral!=nil);
+    self.labelDevice.text =appDelegate.peripheral.name;
+
+    // Do any additional setup after loading the view.
+}
+- (void)viewDidAppear:(BOOL)animated {
+    [super viewDidAppear:animated];
+    if (@available(iOS 10.0, *)) {
+        
+        AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        
+        if(appDelegate.bBTAuthorize==false)
+            [self opentBT];
+    }
+}
+/** 跳转系统设置方法*/
+- (void)opentBT {
+    /**< 弹出框 */
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"App authorize"
+                                                                             message:@"Please turn on Bluetooth access in the system setting"
+                                                                      preferredStyle:UIAlertControllerStyleAlert];
+    [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        
+    }]];
+    [alertController addAction:[UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
+        //            if (@available(iOS 10.0, *)) {
+                        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
+        //            } else {
+        //                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=NOTIFICATIONS_ID&path=com.xxx.xxx"]];//prefs:root=服务&path=项目bundleID     }
+        
+    }]];
+    [self presentViewController:alertController animated:YES completion:nil];
+    
+    
+}
+/*
+#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.
+}
+*/
+- (IBAction)onEnable:(id)sender {
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    UISwitch* sw = sender;
+    
+    [appDelegate enableBLE:sw.isOn];
+//    if(sw.isOn)
+//    {
+//
+//
+//        [appDelegate scanBLE];
+//    }
+//    else
+//    {
+//        [appDelegate stopScanBLE];
+//
+//    }
+}
+- (IBAction)onReconnect:(id)sender {
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    UISwitch* sw = sender;
+//    if(sw.isOn)
+//    {
+//
+//        [appDelegate setBLEAutoReconnect:sw.isOn]
+//    }
+//    else
+//    {
+//        appDelegate.bAutoConnect=false;
+//
+//    }
+    [appDelegate setBLEAutoReconnect:sw.isOn];
+}
+
+
+
+#pragma mark tableview
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    return appDelegate.nDevices.count;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    static NSString *CellIdentifier = @"Cell";
+  //      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
+    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+    if (!cell) {
+        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
+    }
+
+    CBPeripheral *p=appDelegate.nDevices[indexPath.item];
+    NSString* name = p.name;
+    if(name.length==0)
+        name=@"NO Name";
+    cell.textLabel.text = name;
+    
+    return cell;
+}
+-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath
+{
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    CBPeripheral *p=appDelegate.nDevices[indexPath.item];
+//    self.needVerifyUUID=p.identifier.UUIDString;
+    appDelegate.peripheral = p;
+        [appDelegate.manager connectPeripheral:appDelegate.peripheral options:nil];
+}
+
+
+#pragma mark scanner event
+
+-(void) OnUpdateDevicesList
+{
+    [self.tableDiscover reloadData];
+}
+-(void) onDecodedData:(NSString*) value
+{
+    
+}
+-(void) onErrorInfo:(NSString*) errorInfo
+{
+    
+}
+-(void) onStatusChanged:(NSString*) status
+{
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    if([status isEqualToString:@"Connected"])
+    {
+        
+        self.btnConnect.enabled = true;
+        self.labelDevice.text =appDelegate.peripheral.name;
+        
+        [appDelegate setBLEAutoReconnect:true];
+    }
+    else     if([status isEqualToString:@"Disconnected"])
+    {
+        self.labelDevice.text = nil;
+        self.btnConnect.enabled = false;
+    }
+    else if([status isEqualToString:@"Unauthorized"])
+    {
+        [self opentBT];
+    }
+        
+}
+-(void) onLogUpdate
+{
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    self.tvLog.text = appDelegate.log;
+    NSRange range = NSMakeRange(self.tvLog.text.length, 0);
+    [self.tvLog scrollRangeToVisible:range];
+}
+@end

+ 168 - 0
RedAnt ERP Mobile/common/common Scanner/commonScanner.storyboard

@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="ipad9_7" orientation="portrait" layout="fullscreen" appearance="light"/>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="System colors in document resources" minToolsVersion="11.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <scenes>
+        <!--Common Scanner Setting View Controller-->
+        <scene sceneID="s0d-6b-0kx">
+            <objects>
+                <viewController storyboardIdentifier="CommonScannerSettingViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="Y6W-OH-hqX" customClass="CommonScannerSettingViewController" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
+                        <rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" title="Enable Scanner" translatesAutoresizingMaskIntoConstraints="NO" id="Enn-7S-8EQ">
+                                <rect key="frame" x="359.5" y="45" width="51" height="31"/>
+                                <connections>
+                                    <action selector="onEnable:" destination="Y6W-OH-hqX" eventType="valueChanged" id="FLI-cY-fnB"/>
+                                </connections>
+                            </switch>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Enable Scanner" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bhD-lD-vEi">
+                                <rect key="frame" x="30" y="50" width="119" height="21"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Automatic Reconnect" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7d0-gV-ut7">
+                                <rect key="frame" x="30" y="91" width="164" height="21"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <switch hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8co-AI-UzM">
+                                <rect key="frame" x="359.5" y="86" width="51" height="31"/>
+                                <connections>
+                                    <action selector="onReconnect:" destination="Y6W-OH-hqX" eventType="valueChanged" id="BDp-7N-E0s"/>
+                                </connections>
+                            </switch>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="Current Device:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Igu-bv-WHz">
+                                <rect key="frame" x="30" y="132" width="119" height="21"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pyH-kj-OdQ">
+                                <rect key="frame" x="159" y="132" width="155" height="21"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="DUn-Sa-41P">
+                                <rect key="frame" x="324" y="125" width="120" height="35"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="120" id="HLJ-WQ-pps"/>
+                                </constraints>
+                                <state key="normal" title="Button"/>
+                                <buttonConfiguration key="configuration" style="plain" title="Disconnect"/>
+                                <connections>
+                                    <action selector="onDisconnect:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="i6f-CH-cCx"/>
+                                </connections>
+                            </button>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Discovered Device" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uLx-lt-ypQ">
+                                <rect key="frame" x="30" y="193" width="142" height="21"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" translatesAutoresizingMaskIntoConstraints="NO" id="ajA-cg-Bq5">
+                                <rect key="frame" x="30" y="224" width="708" height="349.5"/>
+                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                <prototypes>
+                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="983-SP-dfI">
+                                        <rect key="frame" x="0.0" y="50" width="708" height="43.5"/>
+                                        <autoresizingMask key="autoresizingMask"/>
+                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="983-SP-dfI" id="6qQ-0v-tSA">
+                                            <rect key="frame" x="0.0" y="0.0" width="708" height="43.5"/>
+                                            <autoresizingMask key="autoresizingMask"/>
+                                        </tableViewCellContentView>
+                                    </tableViewCell>
+                                </prototypes>
+                                <connections>
+                                    <outlet property="dataSource" destination="Y6W-OH-hqX" id="NH0-Zb-RP5"/>
+                                    <outlet property="delegate" destination="Y6W-OH-hqX" id="G27-ls-d5E"/>
+                                </connections>
+                            </tableView>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Log" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1IE-zh-6xD">
+                                <rect key="frame" x="30" y="613.5" width="29" height="21"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="zeG-uA-OZf">
+                                <rect key="frame" x="30" y="644.5" width="708" height="349.5"/>
+                                <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                <color key="textColor" systemColor="labelColor"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+                            </textView>
+                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="xqg-nr-rkc">
+                                <rect key="frame" x="635" y="50" width="103" height="103"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" secondItem="xqg-nr-rkc" secondAttribute="height" multiplier="1:1" id="f4t-kD-0ff"/>
+                                </constraints>
+                            </imageView>
+                        </subviews>
+                        <viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
+                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                        <constraints>
+                            <constraint firstItem="bhD-lD-vEi" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" constant="30" id="0gW-go-g0F"/>
+                            <constraint firstItem="DUn-Sa-41P" firstAttribute="centerY" secondItem="Igu-bv-WHz" secondAttribute="centerY" id="1B8-n4-D0y"/>
+                            <constraint firstItem="ajA-cg-Bq5" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" constant="30" id="2vi-nB-7l0"/>
+                            <constraint firstItem="1IE-zh-6xD" firstAttribute="top" secondItem="ajA-cg-Bq5" secondAttribute="bottom" constant="40" id="3El-YN-ahA"/>
+                            <constraint firstItem="xqg-nr-rkc" firstAttribute="bottom" secondItem="Igu-bv-WHz" secondAttribute="bottom" id="6YZ-Cu-6kx"/>
+                            <constraint firstItem="zeG-uA-OZf" firstAttribute="leading" secondItem="ajA-cg-Bq5" secondAttribute="leading" id="76f-it-aS0"/>
+                            <constraint firstItem="pyH-kj-OdQ" firstAttribute="leading" secondItem="Igu-bv-WHz" secondAttribute="trailing" constant="10" id="BMg-uM-TLJ"/>
+                            <constraint firstItem="Enn-7S-8EQ" firstAttribute="centerY" secondItem="bhD-lD-vEi" secondAttribute="centerY" id="BVJ-6i-VLk"/>
+                            <constraint firstItem="7d0-gV-ut7" firstAttribute="leading" secondItem="bhD-lD-vEi" secondAttribute="leading" id="CF1-Ua-qPc"/>
+                            <constraint firstItem="bhD-lD-vEi" firstAttribute="top" secondItem="vDu-zF-Fre" secondAttribute="top" constant="30" id="Ee9-VU-PDl"/>
+                            <constraint firstItem="vDu-zF-Fre" firstAttribute="bottom" secondItem="zeG-uA-OZf" secondAttribute="bottom" constant="30" id="GF6-cF-mLj"/>
+                            <constraint firstItem="xqg-nr-rkc" firstAttribute="top" secondItem="bhD-lD-vEi" secondAttribute="top" id="Gel-fe-262"/>
+                            <constraint firstItem="xqg-nr-rkc" firstAttribute="trailing" secondItem="ajA-cg-Bq5" secondAttribute="trailing" id="JaD-Lc-WzS"/>
+                            <constraint firstItem="zeG-uA-OZf" firstAttribute="top" secondItem="1IE-zh-6xD" secondAttribute="bottom" constant="10" id="L1e-vN-P99"/>
+                            <constraint firstItem="zeG-uA-OZf" firstAttribute="trailing" secondItem="ajA-cg-Bq5" secondAttribute="trailing" id="M8L-YR-arV"/>
+                            <constraint firstItem="zeG-uA-OZf" firstAttribute="height" secondItem="ajA-cg-Bq5" secondAttribute="height" id="Mo5-58-efu"/>
+                            <constraint firstItem="8co-AI-UzM" firstAttribute="centerX" secondItem="DUn-Sa-41P" secondAttribute="centerX" id="Moj-oM-5uF"/>
+                            <constraint firstItem="8co-AI-UzM" firstAttribute="centerY" secondItem="7d0-gV-ut7" secondAttribute="centerY" id="Nnd-9f-7hC"/>
+                            <constraint firstItem="pyH-kj-OdQ" firstAttribute="centerY" secondItem="Igu-bv-WHz" secondAttribute="centerY" id="OIk-Xy-Dqg"/>
+                            <constraint firstItem="7d0-gV-ut7" firstAttribute="top" secondItem="bhD-lD-vEi" secondAttribute="bottom" constant="20" id="Og1-f7-Jtk"/>
+                            <constraint firstItem="Enn-7S-8EQ" firstAttribute="centerX" secondItem="DUn-Sa-41P" secondAttribute="centerX" id="P7F-uv-pM6"/>
+                            <constraint firstItem="Igu-bv-WHz" firstAttribute="top" secondItem="7d0-gV-ut7" secondAttribute="bottom" constant="20" id="Qhs-oI-m0n"/>
+                            <constraint firstItem="DUn-Sa-41P" firstAttribute="centerX" secondItem="5EZ-qb-Rvc" secondAttribute="centerX" id="TKe-uh-iFC"/>
+                            <constraint firstItem="1IE-zh-6xD" firstAttribute="leading" secondItem="ajA-cg-Bq5" secondAttribute="leading" id="XGC-GY-hfT"/>
+                            <constraint firstItem="Igu-bv-WHz" firstAttribute="leading" secondItem="bhD-lD-vEi" secondAttribute="leading" id="eT1-xH-wjF"/>
+                            <constraint firstItem="uLx-lt-ypQ" firstAttribute="top" secondItem="Igu-bv-WHz" secondAttribute="bottom" constant="40" id="hNF-5z-hfU"/>
+                            <constraint firstItem="DUn-Sa-41P" firstAttribute="leading" secondItem="pyH-kj-OdQ" secondAttribute="trailing" constant="10" id="hRz-w3-fbM"/>
+                            <constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="ajA-cg-Bq5" secondAttribute="trailing" constant="30" id="kGq-gK-BF1"/>
+                            <constraint firstItem="uLx-lt-ypQ" firstAttribute="leading" secondItem="Igu-bv-WHz" secondAttribute="leading" id="s1R-CU-RIf"/>
+                            <constraint firstItem="ajA-cg-Bq5" firstAttribute="top" secondItem="uLx-lt-ypQ" secondAttribute="bottom" constant="10" id="xpB-ek-ha9"/>
+                        </constraints>
+                    </view>
+                    <connections>
+                        <outlet property="btnConnect" destination="DUn-Sa-41P" id="dQR-hv-87i"/>
+                        <outlet property="labelDevice" destination="pyH-kj-OdQ" id="Tfo-PR-p7w"/>
+                        <outlet property="swAuto" destination="8co-AI-UzM" id="ccb-3L-4ll"/>
+                        <outlet property="swEnable" destination="Enn-7S-8EQ" id="WUD-Be-txR"/>
+                        <outlet property="tableDiscover" destination="ajA-cg-Bq5" id="lLj-dc-5li"/>
+                        <outlet property="tvLog" destination="zeG-uA-OZf" id="75x-lU-lPo"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="131.25" y="-55.664062499999993"/>
+        </scene>
+    </scenes>
+    <resources>
+        <systemColor name="labelColor">
+            <color red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
+        <systemColor name="systemBackgroundColor">
+            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
+    </resources>
+</document>

+ 25 - 26
RedAnt ERP Mobile/iSales-CONTRAST.xcodeproj/project.pbxproj

@@ -8,6 +8,8 @@
 
 /* Begin PBXBuildFile section */
 		3C2F99B8237BE1790000808F /* PortfolioListTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C2F99B6237BE1790000808F /* PortfolioListTableViewCell.m */; };
+		3C3300B729430F3E005CFE7C /* commonScanner.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C3300B629430F3E005CFE7C /* commonScanner.storyboard */; };
+		3C3300BA29431141005CFE7C /* CommonScannerSettingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C3300B929431141005CFE7C /* CommonScannerSettingViewController.m */; };
 		3C3C92772906874A00EC3500 /* createContact.json in Resources */ = {isa = PBXBuildFile; fileRef = 3C3C92762906874A00EC3500 /* createContact.json */; };
 		3C3C92792907BF4B00EC3500 /* editContact.json in Resources */ = {isa = PBXBuildFile; fileRef = 3C3C92782907BF4B00EC3500 /* editContact.json */; };
 		3C3C927B2907C0C400EC3500 /* customer_info_template.json in Resources */ = {isa = PBXBuildFile; fileRef = 3C3C927A2907C0C400EC3500 /* customer_info_template.json */; };
@@ -65,7 +67,6 @@
 		3C69618323C7156D0075172A /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C69617F23C7156D0075172A /* WebViewController.m */; };
 		3C69618423C7156D0075172A /* wkweb.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C69618023C7156D0075172A /* wkweb.storyboard */; };
 		3C7E5A8E237BDB0C006D0105 /* PortfolioListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C7E5A8C237BDB0C006D0105 /* PortfolioListViewController.m */; };
-		3C872A242797F1C800BE1FC8 /* scan_cart.json in Resources */ = {isa = PBXBuildFile; fileRef = 3C872A212797F1C800BE1FC8 /* scan_cart.json */; };
 		3CA6DDBE28E54B72003655FF /* ContrastModelItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CA6DDBC28E54B72003655FF /* ContrastModelItemCell.m */; };
 		3CA6DDC428E575FB003655FF /* ModelItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CA6DDC328E575FB003655FF /* ModelItemCell.m */; };
 		3CDDB25C273A564200681F78 /* DefaultTableHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3CDDB25A273A564200681F78 /* DefaultTableHeaderView.m */; };
@@ -98,11 +99,6 @@
 		4295AE1C1FE74D46007BE365 /* CommonEditorAutoCompleteView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4295AE1A1FE74D46007BE365 /* CommonEditorAutoCompleteView.m */; };
 		4295AE1D1FE74D46007BE365 /* CommonEditorAutoCompleteView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4295AE1B1FE74D46007BE365 /* CommonEditorAutoCompleteView.xib */; };
 		42B309791E45BA32007AFC62 /* status_filter_cadedate_po.json in Resources */ = {isa = PBXBuildFile; fileRef = 42B309781E45BA32007AFC62 /* status_filter_cadedate_po.json */; };
-		42BEF34F1E89FE1100632AB6 /* FirebaseAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF3241E89FE1100632AB6 /* FirebaseAnalytics.framework */; };
-		42BEF3501E89FE1100632AB6 /* FirebaseCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF3271E89FE1100632AB6 /* FirebaseCore.framework */; };
-		42BEF3521E89FE1200632AB6 /* FirebaseInstanceID.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF32B1E89FE1100632AB6 /* FirebaseInstanceID.framework */; };
-		42BEF3541E89FE1200632AB6 /* GGLAnalytics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF32F1E89FE1100632AB6 /* GGLAnalytics.framework */; };
-		42BEF3551E89FE1200632AB6 /* GGLCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF3301E89FE1100632AB6 /* GGLCore.framework */; };
 		42BEF3571E89FE1200632AB6 /* libGoogleAnalytics.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF33C1E89FE1100632AB6 /* libGoogleAnalytics.a */; };
 		42BEF3581E89FE1200632AB6 /* GTMNSData+zlib.m in Sources */ = {isa = PBXBuildFile; fileRef = 42BEF34B1E89FE1100632AB6 /* GTMNSData+zlib.m */; };
 		42BEF35D1E89FECD00632AB6 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42BEF35C1E89FECD00632AB6 /* SystemConfiguration.framework */; };
@@ -315,6 +311,9 @@
 /* Begin PBXFileReference section */
 		3C2F99B6237BE1790000808F /* PortfolioListTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PortfolioListTableViewCell.m; path = common/Functions/portfolio/PortfolioListTableViewCell.m; sourceTree = SOURCE_ROOT; };
 		3C2F99B7237BE1790000808F /* PortfolioListTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PortfolioListTableViewCell.h; path = common/Functions/portfolio/PortfolioListTableViewCell.h; sourceTree = SOURCE_ROOT; };
+		3C3300B629430F3E005CFE7C /* commonScanner.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = commonScanner.storyboard; sourceTree = "<group>"; };
+		3C3300B829431141005CFE7C /* CommonScannerSettingViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CommonScannerSettingViewController.h; sourceTree = "<group>"; };
+		3C3300B929431141005CFE7C /* CommonScannerSettingViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CommonScannerSettingViewController.m; sourceTree = "<group>"; };
 		3C3C92762906874A00EC3500 /* createContact.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = createContact.json; sourceTree = "<group>"; };
 		3C3C92782907BF4B00EC3500 /* editContact.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = editContact.json; sourceTree = "<group>"; };
 		3C3C927A2907C0C400EC3500 /* customer_info_template.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = customer_info_template.json; sourceTree = "<group>"; };
@@ -404,7 +403,6 @@
 		3C69618123C7156D0075172A /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebViewController.h; path = "../../common/WK PDF+Web/WebViewController.h"; sourceTree = "<group>"; };
 		3C7E5A8C237BDB0C006D0105 /* PortfolioListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PortfolioListViewController.m; path = common/Functions/portfolio/PortfolioListViewController.m; sourceTree = SOURCE_ROOT; };
 		3C7E5A8D237BDB0C006D0105 /* PortfolioListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PortfolioListViewController.h; path = common/Functions/portfolio/PortfolioListViewController.h; sourceTree = SOURCE_ROOT; };
-		3C872A212797F1C800BE1FC8 /* scan_cart.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = scan_cart.json; path = common/Functions/OLO/scan_cart.json; sourceTree = SOURCE_ROOT; };
 		3CA6DDBC28E54B72003655FF /* ContrastModelItemCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContrastModelItemCell.m; sourceTree = "<group>"; };
 		3CA6DDBD28E54B72003655FF /* ContrastModelItemCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContrastModelItemCell.h; sourceTree = "<group>"; };
 		3CA6DDC228E575FB003655FF /* ModelItemCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ModelItemCell.h; path = common/Functions/cart/ModelItemCell.h; sourceTree = SOURCE_ROOT; };
@@ -871,20 +869,15 @@
 				42BEF35D1E89FECD00632AB6 /* SystemConfiguration.framework in Frameworks */,
 				71BBA2291CEAC17E00C91DED /* libz.tbd in Frameworks */,
 				7187162C1C43428100F25860 /* libScanApiCore.a in Frameworks */,
-				42BEF3551E89FE1200632AB6 /* GGLCore.framework in Frameworks */,
 				718716291C433DA400F25860 /* AVFoundation.framework in Frameworks */,
 				718716271C433D9700F25860 /* AudioToolbox.framework in Frameworks */,
-				42BEF3541E89FE1200632AB6 /* GGLAnalytics.framework in Frameworks */,
-				42BEF3501E89FE1100632AB6 /* FirebaseCore.framework in Frameworks */,
 				718716251C433D8B00F25860 /* ExternalAccessory.framework in Frameworks */,
 				716961B519594E1000B19FB4 /* libsqlite3.dylib in Frameworks */,
-				42BEF3521E89FE1200632AB6 /* FirebaseInstanceID.framework in Frameworks */,
 				71DEE876192DE00E003F645F /* Accelerate.framework in Frameworks */,
 				71DEE874192DE003003F645F /* QuartzCore.framework in Frameworks */,
 				713F76AC1929F4A7006A7305 /* CoreGraphics.framework in Frameworks */,
 				713F76AE1929F4A7006A7305 /* UIKit.framework in Frameworks */,
 				713F76AA1929F4A7006A7305 /* Foundation.framework in Frameworks */,
-				42BEF34F1E89FE1100632AB6 /* FirebaseAnalytics.framework in Frameworks */,
 				42BEF3571E89FE1200632AB6 /* libGoogleAnalytics.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -892,6 +885,17 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		3C3300B529430F0A005CFE7C /* common Scanner */ = {
+			isa = PBXGroup;
+			children = (
+				3C3300B629430F3E005CFE7C /* commonScanner.storyboard */,
+				3C3300B829431141005CFE7C /* CommonScannerSettingViewController.h */,
+				3C3300B929431141005CFE7C /* CommonScannerSettingViewController.m */,
+			);
+			name = "common Scanner";
+			path = "common/common Scanner";
+			sourceTree = SOURCE_ROOT;
+		};
 		3C514975273E07C400F78617 /* EnumSelectAndSort */ = {
 			isa = PBXGroup;
 			children = (
@@ -955,14 +959,6 @@
 			path = ../../common/HUD;
 			sourceTree = "<group>";
 		};
-		3C872A1F2797F1AD00BE1FC8 /* Scaner Order */ = {
-			isa = PBXGroup;
-			children = (
-				3C872A212797F1C800BE1FC8 /* scan_cart.json */,
-			);
-			name = "Scaner Order";
-			sourceTree = "<group>";
-		};
 		3C88558E27E1D233005DC3FA /* upload */ = {
 			isa = PBXGroup;
 			children = (
@@ -1354,8 +1350,8 @@
 		713F76AF1929F4A7006A7305 /* iSales-CONTRAST */ = {
 			isa = PBXGroup;
 			children = (
+				3C3300B529430F0A005CFE7C /* common Scanner */,
 				3C88558E27E1D233005DC3FA /* upload */,
-				3C872A1F2797F1AD00BE1FC8 /* Scaner Order */,
 				71DF74311C5757C800F2789C /* CommonUI */,
 				71DF742C1C57567800F2789C /* CONTRAST */,
 				712AFEE31DBDAEA000254965 /* PDFResource */,
@@ -2109,7 +2105,6 @@
 				3C68316B2396094200AD5BD7 /* iPadCommonEditorCellSwitch.xib in Resources */,
 				3C6831582396082800AD5BD7 /* ERP_Mobile_Model.storyboard in Resources */,
 				7143E20C202FCEEC00451903 /* OLM.storyboard in Resources */,
-				3C872A242797F1C800BE1FC8 /* scan_cart.json in Resources */,
 				7143E20D202FCEEC00451903 /* Main.storyboard in Resources */,
 				7142E87E1DC300690077EFA2 /* DejaVuSans-Bold.ttf in Resources */,
 				3C6831682396094200AD5BD7 /* iPadCommonEditorCellImg.xib in Resources */,
@@ -2158,6 +2153,7 @@
 				7111E5721C76C557004763B3 /* customer_info_template_edit.json in Resources */,
 				7161FEB61D61B24900157EE1 /* normalpayment.html in Resources */,
 				3C68316C2396094200AD5BD7 /* iPadCommonEditorCellEnum.xib in Resources */,
+				3C3300B729430F3E005CFE7C /* commonScanner.storyboard in Resources */,
 				7143E214202FCFC000451903 /* debug_category_filter.json in Resources */,
 				7143E220202FD28900451903 /* TearSheet.json in Resources */,
 				71DF74961C57614C00F2789C /* PhotoBorder@2x.png in Resources */,
@@ -2356,6 +2352,7 @@
 				71DF748D1C57608F00F2789C /* TouchLabel.m in Sources */,
 				3C68314E239607B500AD5BD7 /* RAYTPlayer.m in Sources */,
 				3C514932273D092A00F78617 /* EnumSelectViewController.m in Sources */,
+				3C3300BA29431141005CFE7C /* CommonScannerSettingViewController.m in Sources */,
 				428980171E24924D005F1BD8 /* SortItemViewController.m in Sources */,
 				7162A5711C58728D00AB630E /* DetailImageCell.m in Sources */,
 				7141DD511C57459B00F7DF59 /* qrencode.c in Sources */,
@@ -2549,7 +2546,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 221108;
+				CURRENT_PROJECT_VERSION = 2211221;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2561,7 +2558,8 @@
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = "iSales-CONTRAST/iSales-CONTRAST-Prefix.pch";
 				INFOPLIST_FILE = "$(SRCROOT)/iSales-CONTRAST/iSales-CONTRAST-Info.plist";
-				IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+				INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.shopping";
+				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LIBRARY_SEARCH_PATHS = (
 					"$(PROJECT_DIR)/ScanApiSDK-10.2.227-2/lib",
 					"$(PROJECT_DIR)/GoogleAnalytics/GoogleAnalytics/Libraries",
@@ -2597,7 +2595,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
-				CURRENT_PROJECT_VERSION = 221108;
+				CURRENT_PROJECT_VERSION = 2211221;
 				DEVELOPMENT_TEAM = HXWLAA5YN5;
 				FRAMEWORK_SEARCH_PATHS = (
 					"$(inherited)",
@@ -2609,7 +2607,8 @@
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = "iSales-CONTRAST/iSales-CONTRAST-Prefix.pch";
 				INFOPLIST_FILE = "$(SRCROOT)/iSales-CONTRAST/iSales-CONTRAST-Info.plist";
-				IPHONEOS_DEPLOYMENT_TARGET = 12.0;
+				INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.shopping";
+				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LIBRARY_SEARCH_PATHS = (
 					"$(PROJECT_DIR)/ScanApiSDK-10.2.227-2/lib",
 					"$(PROJECT_DIR)/GoogleAnalytics/GoogleAnalytics/Libraries",

+ 1 - 1
RedAnt ERP Mobile/iSales-CONTRAST.xcodeproj/xcuserdata/ruizhang.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -7,7 +7,7 @@
 		<key>iSales-CONTRAST.xcscheme_^#shared#^_</key>
 		<dict>
 			<key>orderHint</key>
-			<integer>2</integer>
+			<integer>1</integer>
 		</dict>
 		<key>iSales-USAI.xcscheme_^#shared#^_</key>
 		<dict>

+ 6 - 2
RedAnt ERP Mobile/iSales-CONTRAST/AppDelegate.m

@@ -10,8 +10,12 @@
 @implementation AppDelegate
 
 
-
+//SoftKeyboardManager.shared.disabled = false
 //@synthesize devices;
-
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+    [super application:application didFinishLaunchingWithOptions:launchOptions];
+    return YES;
+}
 
 @end

+ 3 - 0
RedAnt ERP Mobile/iSales-CONTRAST/config.h

@@ -9,11 +9,14 @@
 #ifndef RedAnt_ERP_Mobile_config_h
 #define RedAnt_ERP_Mobile_config_h
 #define BUILD_CONTRAST
+#define QUERY_BY_UPC
 #define BACKORDER_PROCESS // 允许backorder process
 #define JSON_TIMEOUT 30
 
 //#define IGNORE_SOLD_IN_QTY
 
+#define USE_BLE_SCANNER
+
 #define RA_NOTIFICATION
 
 # ifdef DEBUG

+ 2 - 0
RedAnt ERP Mobile/iSales-CONTRAST/iSales-CONTRAST-Info.plist

@@ -2,6 +2,8 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+	<key>NSBluetoothAlwaysUsageDescription</key>
+	<string>Connect to BT scanner</string>
 	<key>CFBundleDevelopmentRegion</key>
 	<string>en</string>
 	<key>CFBundleDisplayName</key>

+ 2 - 0
RedAnt ERP Mobile/iSales-NPD/config.h

@@ -15,6 +15,8 @@
 //#define GOOGLE_ANALYTICS
 #define BACKORDER_PROCESS // 允许backorder process
 
+#define USE_MFI_SCANNER // stock mobile mfi 扫描枪
+
 # ifdef DEBUG
 //#define test_server
 # endif

+ 3 - 0
Redant Drivers/Apex And Drivers/config.h

@@ -17,6 +17,9 @@
 #define ApexDriverWhiteColor UIColorFromRGB(0xffffff)
 #define ApexDriverRedColor UIColorFromRGB(0xAE2838)
 
+
+#define GET_JSON
+
 # ifdef DEBUG
 #define test_server
 # endif

+ 212 - 208
common/NetworkUtils.m

@@ -41,217 +41,221 @@
 
 +(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params file:(NSString*)file_path err_recorder:(NSString* )recorder_url result_handler:(resultBlock)resultBlock decrypt_handler:(decryptBlock)decryptBlock
 {
-//    int retry = 0;
-    
+
+#ifndef GET_JSON
 
     NSAssert(false, @"The get_json is obsolete, use the request_interface instead");
     return nil;
-//    
-//repeat:
-//    {
-//        
-//        //    return [self fake_json:url];
-//        
-//        //    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-//        //分界线的标识符
-//        NSString *TWITTERFON_FORM_BOUNDARY = @"AaB03x";
-//        //根据url初始化request
-//        NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
-//                                                               cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
-//                                                           timeoutInterval:JSON_TIMEOUT];
-//
-//        //分界线 --AaB03x
-//        NSString *MPboundary=[[NSString alloc]initWithFormat:@"--%@",TWITTERFON_FORM_BOUNDARY];
-//        //结束符 AaB03x--
-//        NSString *endMPboundary=[[NSString alloc]initWithFormat:@"%@--",MPboundary];
-//        //要上传的图片
-//        //    UIImage *image=[params objectForKey:@"pic"];
-//        //得到图片的data
-//            NSData* data = [NSData dataWithContentsOfFile:file_path];
-//        //http body的字符串
-//        NSMutableString *body=[[NSMutableString alloc]init];
-//        
-//        //    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
-//        //     [params setValue:@"handset_login" forKey:@"action"];
-//        //    [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
-//        
-//        //    [params setValue:appDelegate.sessionid forKey:@"sessionid"];
-//        //   [params setValue:password forKey:@"password"];
-//        //    [params setValue:[NSString stringWithFormat:@"%d",ver]  forKey:@"auth_ver"];
-//        
-//        
-//        
-//        //    [headers setValue:headQuerlString forKey:@"param"];
-//        
-//        //参数的集合的所有key的集合
-//        NSArray *keys= [params allKeys];
-//        DebugLog(@"================parms==================");
-//        //遍历keys
-//        for(int i=0;i<[keys count];i++)
-//        {
-//            //得到当前key
-//            NSString *key=[keys objectAtIndex:i];
-//            //如果key不是pic,说明value是字符类型,比如name:Boris
-//            if(![key isEqualToString:@"pic"])
-//            {
-//                //添加分界线,换行
-//                [body appendFormat:@"%@\r\n",MPboundary];
-//                //添加字段名称,换2行
-//                [body appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",key];
-//                //添加字段的值
-//                [body appendFormat:@"%@\r\n",[params objectForKey:key]];
-//                DebugLog(@"parameter: key=%@   value=%@",key,[params objectForKey:key]);
-//            }
-//        }
-//        DebugLog(@"================parms==================");
-//        ////添加分界线,换行
-//        [body appendFormat:@"%@\r\n",MPboundary];
-//        //声明pic字段,文件名为boris.png
-//        
-//        NSString * file_format=[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upfile\"; filename=\"%@\"\r\n", [file_path lastPathComponent]];
-//
-//        
-//        
-//        [body appendFormat:@"%@", file_format];
-//        //声明上传文件的格式
-//        [body appendFormat:@"Content-Type: application/zip\r\n\r\n"];
-//        
-//        //声明结束符:--AaB03x--
-//        NSString *end=[[NSString alloc]initWithFormat:@"\r\n%@",endMPboundary];
-//        //声明myRequestData,用来放入http body
-//        NSMutableData *myRequestData=[NSMutableData data];
-//        //将body字符串转化为UTF8格式的二进制
-//        [myRequestData appendData:[body dataUsingEncoding:NSUTF8StringEncoding]];
-//        //将image的data加入
-//            [myRequestData appendData:data];
-//        //加入结束符--AaB03x--
-//        [myRequestData appendData:[end dataUsingEncoding:NSUTF8StringEncoding]];
-//        
-//        //设置HTTPHeader中Content-Type的值
-//        NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",TWITTERFON_FORM_BOUNDARY];
-//        //设置HTTPHeader
-//        [request setValue:content forHTTPHeaderField:@"Content-Type"];
-//        
-//        [request setValue:@"multipart/form-data" forHTTPHeaderField:@"enctype"];
-//        
-//        // 关闭keep alive
-//        [request setValue:@"close" forHTTPHeaderField:@"Connection"];
-//        //设置Content-Length
-//        [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[myRequestData length]] forHTTPHeaderField:@"Content-Length"];
-//        //设置http body
-//        [request setHTTPBody:myRequestData];
-//        //http method
-//        [request setHTTPMethod:@"POST"];
-//        
-//        NSLog(@"%@", [[NSString alloc] initWithData:myRequestData encoding:NSUTF8StringEncoding]);
-//        NSHTTPURLResponse* urlResponse = nil;
-//        
-//        NSError *error = nil;
-//        NSLog(@"begin request %@",url);
-//
-//        NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
-//        
-//        
-//        DebugLog(@"url: %@",url);
-//        
-//        DebugLog(@"response: %@",[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
-//        
-//        
-//        NSLog(@"get response");
-//        if (responseData==nil) {
-//            
-//            //            DebugLog(@"response error:%@", [error localizedDescription]);
-//            
-//            
-//            NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
-//            //#define RESULT_FALSE 0
-//            //#define RESULT_TRUE		 2
-//            //#define RESULT_NET_ERROR			 -3
-//            //#define RESULT_NET_NOTAVAILABLE		  -4
-//            //#define RESULT_ERROR				 -5
-//            //#define RESULT_LOCALFILE_ERROR			 -7
-//            //#define RESULT_USERAUTH_ERROR			 -9
-//            //#define RESULT_UPDATE_USERAUTH_ERROR	 -11
-//            //#define RESULT_SESSION_EXPIRED			  -13
-//            //#define RESULT_VER_LOW
-//            
-//            //     NSString * moreinfo = error.description ;
-//            
-//            NSString* err_msg = [error localizedDescription];
-//            
-//            
-//            //-----------------retry 3 times for error code -1005------------------------
-//            if(error.code==-1005&&retry<3)
-//            {
-//                retry++;
-//                goto repeat;
-//                
-//            }
-//            //-----------------end retry 3 times for error code -1005------------------------
-//            
-//            NSDictionary* error_json = [RAUtils error_dict:error];
-//            [ret setObject:error_json forKey:@"err_obj"];
-//            NSString* resp_msg= nil;
-//            
-//            if(err_msg.length==0)
-//            {
-//                err_msg =[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode];
-//                resp_msg = err_msg;
-//            }
-//            [ret setValue:[NSString stringWithFormat:@"%d",RESULT_NET_ERROR] forKey:@"result"];
-//            [ret setValue:err_msg forKey:@"err_msg"];
-//            [ret setValue:resp_msg forKey:@"resp_msg"];
-//            [ret setValue:[NSString stringWithFormat:@"%ld",(long)urlResponse.statusCode] forKey:@"resp_code"];
-//            
-//            
-//            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ret
-//                                                               options:0
-//                                                                 error:nil];
-//            if(![url isEqualToString:recorder_url])
-//            {
-//                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:[RAConvertor dict2string:ret]] module:url code:RESULT_NET_ERROR];
-//            }
-//            return jsonData;
-//            
-//        }
-//        else
-//        {
-//          //  NSString* err_msg = [error localizedDescription];
-//            NSMutableString *str = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
-//            
-//            DebugLog(@"data string: %@",str);
-//            NSError *error1 = nil;
-//            
-//            NSMutableDictionary* jsobj = [[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error1] mutableCopy];
-//            
-//            if(jsobj==nil)// 服务器返回不是json
-//            {
-//                
-//                jsobj=[[NSMutableDictionary alloc] init];
-//                [jsobj setValue:[NSNumber numberWithInt:RESULT_NO_RESPONSE] forKey:@"result"];
-//                
-//            }
-//            if([jsobj[@"encrypt"] boolValue]==true)
-//            {
-//                jsobj = decryptBlock(jsobj);
-//            }
-//            if (resultBlock) {
-//                jsobj = resultBlock(jsobj);
-//            }
-//            
-//            int result=[[jsobj valueForKey:@"result"] intValue];
-//            if(![url isEqualToString:recorder_url]&&/*![url isEqualToString:URL_DOWNLOAD_OFFLINE]&&*/result!=2&&result!=99)
-//            {
-//                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:str] module:url code:result];
-//            }
-//            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsobj
-//                                                               options:0
-//                                                                 error:nil];
-//            return jsonData;
-//            
-//        }
-//        return responseData;
-//    }
+#else
+    
+    
+        int retry = 0;
+repeat:
+    {
+        
+        //    return [self fake_json:url];
+        
+        //    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        //分界线的标识符
+        NSString *TWITTERFON_FORM_BOUNDARY = @"AaB03x";
+        //根据url初始化request
+        NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
+                                                               cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
+                                                           timeoutInterval:JSON_TIMEOUT];
+
+        //分界线 --AaB03x
+        NSString *MPboundary=[[NSString alloc]initWithFormat:@"--%@",TWITTERFON_FORM_BOUNDARY];
+        //结束符 AaB03x--
+        NSString *endMPboundary=[[NSString alloc]initWithFormat:@"%@--",MPboundary];
+        //要上传的图片
+        //    UIImage *image=[params objectForKey:@"pic"];
+        //得到图片的data
+            NSData* data = [NSData dataWithContentsOfFile:file_path];
+        //http body的字符串
+        NSMutableString *body=[[NSMutableString alloc]init];
+        
+        //    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+        //     [params setValue:@"handset_login" forKey:@"action"];
+        //    [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
+        
+        //    [params setValue:appDelegate.sessionid forKey:@"sessionid"];
+        //   [params setValue:password forKey:@"password"];
+        //    [params setValue:[NSString stringWithFormat:@"%d",ver]  forKey:@"auth_ver"];
+        
+        
+        
+        //    [headers setValue:headQuerlString forKey:@"param"];
+        
+        //参数的集合的所有key的集合
+        NSArray *keys= [params allKeys];
+        DebugLog(@"================parms==================");
+        //遍历keys
+        for(int i=0;i<[keys count];i++)
+        {
+            //得到当前key
+            NSString *key=[keys objectAtIndex:i];
+            //如果key不是pic,说明value是字符类型,比如name:Boris
+            if(![key isEqualToString:@"pic"])
+            {
+                //添加分界线,换行
+                [body appendFormat:@"%@\r\n",MPboundary];
+                //添加字段名称,换2行
+                [body appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",key];
+                //添加字段的值
+                [body appendFormat:@"%@\r\n",[params objectForKey:key]];
+                DebugLog(@"parameter: key=%@   value=%@",key,[params objectForKey:key]);
+            }
+        }
+        DebugLog(@"================parms==================");
+        ////添加分界线,换行
+        [body appendFormat:@"%@\r\n",MPboundary];
+        //声明pic字段,文件名为boris.png
+        
+        NSString * file_format=[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upfile\"; filename=\"%@\"\r\n", [file_path lastPathComponent]];
+
+        
+        
+        [body appendFormat:@"%@", file_format];
+        //声明上传文件的格式
+        [body appendFormat:@"Content-Type: application/zip\r\n\r\n"];
+        
+        //声明结束符:--AaB03x--
+        NSString *end=[[NSString alloc]initWithFormat:@"\r\n%@",endMPboundary];
+        //声明myRequestData,用来放入http body
+        NSMutableData *myRequestData=[NSMutableData data];
+        //将body字符串转化为UTF8格式的二进制
+        [myRequestData appendData:[body dataUsingEncoding:NSUTF8StringEncoding]];
+        //将image的data加入
+            [myRequestData appendData:data];
+        //加入结束符--AaB03x--
+        [myRequestData appendData:[end dataUsingEncoding:NSUTF8StringEncoding]];
+        
+        //设置HTTPHeader中Content-Type的值
+        NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",TWITTERFON_FORM_BOUNDARY];
+        //设置HTTPHeader
+        [request setValue:content forHTTPHeaderField:@"Content-Type"];
+        
+        [request setValue:@"multipart/form-data" forHTTPHeaderField:@"enctype"];
+        
+        // 关闭keep alive
+        [request setValue:@"close" forHTTPHeaderField:@"Connection"];
+        //设置Content-Length
+        [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[myRequestData length]] forHTTPHeaderField:@"Content-Length"];
+        //设置http body
+        [request setHTTPBody:myRequestData];
+        //http method
+        [request setHTTPMethod:@"POST"];
+        
+        NSLog(@"%@", [[NSString alloc] initWithData:myRequestData encoding:NSUTF8StringEncoding]);
+        NSHTTPURLResponse* urlResponse = nil;
+        
+        NSError *error = nil;
+        NSLog(@"begin request %@",url);
+
+        NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
+        
+        
+        DebugLog(@"url: %@",url);
+        
+        DebugLog(@"response: %@",[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
+        
+        
+        NSLog(@"get response");
+        if (responseData==nil) {
+            
+            //            DebugLog(@"response error:%@", [error localizedDescription]);
+            
+            
+            NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
+            //#define RESULT_FALSE 0
+            //#define RESULT_TRUE		 2
+            //#define RESULT_NET_ERROR			 -3
+            //#define RESULT_NET_NOTAVAILABLE		  -4
+            //#define RESULT_ERROR				 -5
+            //#define RESULT_LOCALFILE_ERROR			 -7
+            //#define RESULT_USERAUTH_ERROR			 -9
+            //#define RESULT_UPDATE_USERAUTH_ERROR	 -11
+            //#define RESULT_SESSION_EXPIRED			  -13
+            //#define RESULT_VER_LOW
+            
+            //     NSString * moreinfo = error.description ;
+            
+            NSString* err_msg = [error localizedDescription];
+            
+            
+            //-----------------retry 3 times for error code -1005------------------------
+            if(error.code==-1005&&retry<3)
+            {
+                retry++;
+                goto repeat;
+                
+            }
+            //-----------------end retry 3 times for error code -1005------------------------
+            
+            NSDictionary* error_json = [RAUtils error_dict:error];
+            [ret setObject:error_json forKey:@"err_obj"];
+            NSString* resp_msg= nil;
+            
+            if(err_msg.length==0)
+            {
+                err_msg =[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode];
+                resp_msg = err_msg;
+            }
+            [ret setValue:[NSString stringWithFormat:@"%d",RESULT_NET_ERROR] forKey:@"result"];
+            [ret setValue:err_msg forKey:@"err_msg"];
+            [ret setValue:resp_msg forKey:@"resp_msg"];
+            [ret setValue:[NSString stringWithFormat:@"%ld",(long)urlResponse.statusCode] forKey:@"resp_code"];
+            
+            
+            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ret
+                                                               options:0
+                                                                 error:nil];
+            if(![url isEqualToString:recorder_url])
+            {
+                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:[RAConvertor dict2string:ret]] module:url code:RESULT_NET_ERROR];
+            }
+            return jsonData;
+            
+        }
+        else
+        {
+          //  NSString* err_msg = [error localizedDescription];
+            NSMutableString *str = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
+            
+            DebugLog(@"data string: %@",str);
+            NSError *error1 = nil;
+            
+            NSMutableDictionary* jsobj = [[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error1] mutableCopy];
+            
+            if(jsobj==nil)// 服务器返回不是json
+            {
+                
+                jsobj=[[NSMutableDictionary alloc] init];
+                [jsobj setValue:[NSNumber numberWithInt:RESULT_NO_RESPONSE] forKey:@"result"];
+                
+            }
+            if([jsobj[@"encrypt"] boolValue]==true)
+            {
+                jsobj = decryptBlock(jsobj);
+            }
+            if (resultBlock) {
+                jsobj = resultBlock(jsobj);
+            }
+            
+            int result=[[jsobj valueForKey:@"result"] intValue];
+            if(![url isEqualToString:recorder_url]&&/*![url isEqualToString:URL_DOWNLOAD_OFFLINE]&&*/result!=2&&result!=99)
+            {
+                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:str] module:url code:result];
+            }
+            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsobj
+                                                               options:0
+                                                                 error:nil];
+            return jsonData;
+            
+        }
+        return responseData;
+    }
+#endif
 }
 
 +(NSDictionary*)err_log:(NSString*) up_params result:(NSString*)result module:(NSString*) module code:(int) code//device:(NSString*) device