Kaynağa Gözat

蓝牙链接Bug

leon 3 yıl önce
ebeveyn
işleme
ae4124e326
25 değiştirilmiş dosya ile 957 ekleme ve 922 silme
  1. BIN
      .DS_Store
  2. 17 17
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/BTDataProcess.h
  3. 135 154
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/BTDataProcess.mm
  4. 4 0
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/LEONBLManager.h
  5. 41 4
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/LEONBLManager.m
  6. 1 1
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/pub.h
  7. 3 3
      DanceGame/Unity-iPhone.xcodeproj/project.pbxproj
  8. BIN
      DanceGame/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate
  9. 2 0
      RunGame/Classes/UnityAppController.mm
  10. 5 10
      RunGame/Info.plist
  11. 14 14
      RunGame/SDK/BLE/BTDataProcess.h
  12. 135 154
      RunGame/SDK/BLE/BTDataProcess.mm
  13. 4 0
      RunGame/SDK/BLE/LEONBLManager.h
  14. 16 0
      RunGame/SDK/BLE/LEONBLManager.m
  15. 5 2
      RunGame/SDK/HTTP/HTTPDataProcession.h
  16. 5 2
      RunGame/SDK/HTTP/HTTPDataProcession.m
  17. 156 156
      RunGame/SDK/Tool/GameObjc.h
  18. 367 367
      RunGame/SDK/Tool/GameObjc.mm
  19. 4 2
      RunGame/SDK/shoes_sdk/FootStep.cpp
  20. 1 5
      RunGame/SDK/shoes_sdk/Game.cpp
  21. 3 1
      RunGame/SDK/shoes_sdk/InertialTrajProcess.cpp
  22. 1 3
      RunGame/SDK/shoes_sdk/RunGame.cpp
  23. 31 27
      RunGame/Unity-iPhone.xcodeproj/project.pbxproj
  24. 7 0
      RunGame/Unity-iPhone.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  25. BIN
      RunGame/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate

BIN
.DS_Store


+ 17 - 17
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/BTDataProcess.h

@@ -19,23 +19,23 @@ typedef NS_ENUM(int, GAME_TYPE){
     GAME_TYPE_SDAER, //
 };
 
-//动作数据
-typedef NS_ENUM(NSInteger, GAME_MOTION){
-    MOTION_STOP =0,
-    MOTION_RUN,// 跑
-    MOTION_JUMP, // 跳
-    MOTION_DOWN, // 蹲
-    MOTION_LEFT, // 滑左
-    MOTION_RIGHT, // 滑右
-    MOTION_FRONT, // 滑前
-    MOTION_BACK, // 滑后
-    MOTION_LEFT_UP, // 点击-左上
-    MOTION_LEFT_DOWN, // 点击-左下
-    MOTION_RIGHT_UP, // 点击-右上
-    MOTION_RIGHT_DOWN, // 点击-右下
-    MOTION_STEP, // 点击-原地踩
-    NUMBERS_OF_MOTION
-};
+////动作数据
+//typedef NS_ENUM(NSInteger, GAME_MOTION){
+//    MOTION_STOP =0,
+//    MOTION_RUN,// 跑
+//    MOTION_JUMP, // 跳
+//    MOTION_DOWN, // 蹲
+//    MOTION_LEFT, // 滑左
+//    MOTION_RIGHT, // 滑右
+//    MOTION_FRONT, // 滑前
+//    MOTION_BACK, // 滑后
+//    MOTION_LEFT_UP, // 点击-左上
+//    MOTION_LEFT_DOWN, // 点击-左下
+//    MOTION_RIGHT_UP, // 点击-右上
+//    MOTION_RIGHT_DOWN, // 点击-右下
+//    MOTION_STEP, // 点击-原地踩
+//    NUMBERS_OF_MOTION
+//};
 
 //蓝牙状态
 typedef NS_ENUM(NSInteger, BLETOOTH_STUTAS){

+ 135 - 154
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/BTDataProcess.mm

@@ -8,13 +8,21 @@
 
 #import "BTDataProcess.h"
 #import "IOSPlatformSDK.h"
+#include "Game.h"
 #define NSLog(format, ...) printf("TIME:%s FILE:%s(%d行) FUNCTION:%s %s\n",__TIME__, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String])
 @interface BTDataProcess ()<NSURLSessionDataDelegate>
 
+{
+@private
+    Game *game;
+}
+
 @property (strong, nonatomic)NSMutableArray  * deviceArray;/**< 蓝牙设备个数 */
 @property (nonatomic,strong)IOSPlatformSDK * sdk;//ios_sdk
-@property (nonatomic,strong)GameObjc * game ;//主设备蓝牙算法sdk
-@property (nonatomic,strong)GameObjc * viceDeviceGame ;//副设备设备蓝牙算法sdk
+
+//@property (nonatomic,strong)GameObjc * game ;//主设备蓝牙算法sdk
+
+//@property (nonatomic,strong)GameObjc * viceDeviceGame ;//副设备设备蓝牙算法sdk
 @property(nonatomic,weak)NSTimer * timer;//定时器 定时请求主、副设备电量
 @property(nonatomic,assign)BOOL gameModel;//是否开启游戏模式
 
@@ -27,9 +35,9 @@
 @property (nonatomic,assign)int  tempTs;
 @property (nonatomic,assign)int  loss;
 @property (nonatomic,assign)int  totalPackages;
-@property (nonatomic,strong)NSString * dataString;//缓存plist
+//@property (nonatomic,strong)NSString * dataString;//缓存plist
 @property (nonatomic,strong)NSString * tempStepString;//缓存plist
-
+@property(nonatomic,assign) NSNumber *RSSI;//威严要的测试数据
 /*****测试*******/
 
 @end
@@ -230,7 +238,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                     if (self.deviceArray.count == 0){//数据源为0
                         
         //                    NSLog(@"add 扫描发现蓝牙设备  %@",peripheral.name);
-                           
+//                        peripheral.RSSI
                             [self.deviceArray addObject:peripheral];
                             //判断扫描到外设之后是否要链接蓝牙
                             [self ifAppJumpWithIdentifier:peripheral];
@@ -310,10 +318,10 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         //初始化运轨sdk
         if (self.deviceType==DEVICETYPE_MAIN){
             LEManager.peripheral = peripheral;
-            self.game = [[GameObjc alloc] initWithGametype:self.game_id];
+            game = new Game(self.game_id);
         }else if (self.deviceType == DEVICETYPE_VICE){
             LEManager.vicePeripheral = peripheral;
-            self.viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
+//            self.viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
         }
         
         //根据ios_sdk传入deviceType 链接 主/副 设备
@@ -379,6 +387,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         if ([characteristic.UUID.UUIDString isEqualToString:@"6E400003-B5A3-F393-E0A9-E50E24DCCA9E"]){//判断是不是我们设备的特征值
 //            NSLog(@"characteristic.UUID.UUIDString = %@",characteristic.UUID.UUIDString);
                 [self verifyData:characteristic deviceType:type];
+                [peripheral readRSSI];
          }
     };
 
@@ -386,21 +395,33 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     LEManager.writeToCharacteristicBlock = ^(CBPeripheral * _Nonnull peripheral,CBCharacteristic * _Nonnull characteristic, NSError * _Nonnull error, DEVICE_TYPE type){
     };
     
+    //
+    LEManager.rssiBlock = ^(NSNumber * _Nonnull RSSI){
+        self.RSSI = RSSI;
+//        NSLog(@"self.RSSI  = %@",self.RSSI );
+    };
+    
     //蓝牙连接成功
     LEManager.successfulBlock = ^(CBPeripheral * _Nonnull peripheral){
 //        if (peripheral == LEManager.peripheral){
             [[AnimationView shanreAnimationView] stopAnimation];
     };
 
-//    //蓝牙连接失败
-//    LEManager.connectFailureBlock = ^(NSError * _Nonnull error){
+    //蓝牙连接失败
+    LEManager.connectFailureBlock = ^(NSError * _Nonnull error){
+        NSLog(@"蓝牙链接失败");
 //        if (peripheral == LEManager.peripheral){
-//            [[AnimationView shanreAnimationView] addAnimation];
-//        }
-//    };
 //
+//        }
+    };
+
     //蓝牙连接丢失
     LEManager.disConnectBlock = ^(CBPeripheral * _Nonnull peripheral, NSError * _Nonnull error){
+        
+        NSLog(@"蓝牙链接丢失");
+        //断线重连
+        [self initCBCentralManager];
+
         if (peripheral == LEManager.peripheral){
             if (LEManager.peripheral!=nil){
                 
@@ -427,7 +448,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
 #pragma mark ===============================================>> 读取特征后 鞋子打开游戏模式 & 激光开关 &查询鞋子蓝牙状态 & 主设备初始化缓存游戏步数
 -(void)initGameAction:(DEVICE_TYPE)deviceType{
     
-    
     //初始化缓存动作数据
     if (deviceType==DEVICETYPE_MAIN){
         
@@ -575,20 +595,16 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                    
 //                   NSLog(@"主设备 接收到 鞋子动作数据 data = %@",characteristic);
                    //调取鞋子SDK
-                   [self shoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press];
+                   [self shoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press characteristic:characteristic];
                    
                }else if (deviceType==DEVICETYPE_VICE){//副设备动作数据
                    
 //                   NSLog(@"副设备 接收到 鞋子动作数据 data = %@",characteristic);
-                   //调取鞋子SDK
-                   [self viceShoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press];
+//                   //调取鞋子SDK
+//                   [self viceShoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press];
                    
                }
-          
-              //开启剑波sdk数据字符串存储
-              [self ocGetGameDataStr:characteristic];
-          
-      
+              
         }else if (dataType == -95){//获取的是查询的数据 char-->int a1 = -95
 
             if (characteristic.length == 74){//A1+0  >> 0: 设备基本信息 ==>> 预留参数 趣动app用 sdk暂未调用
@@ -609,7 +625,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
 //                int rightPressure = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(17, 4)]];
 //                int rightStepCount = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(21, 4)]];
                 
-                
                 if (deviceType==DEVICETYPE_MAIN){//主设备
                     
                     NSLog(@"主设备 接收到 鞋子硬件数据 data 26 = %@  电量 %d %d",characteristic,leftElectricity,rightElectricity);
@@ -655,38 +670,37 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                     rssi:(int)rssi
                girlShoes:(int)girlShoes
              right_press:(int)right_press
-              left_press:(int)left_press{
+              left_press:(int)left_press
+          characteristic:(NSData*)characteristic{
     
     /********************初始化 运动轨迹算法 SDK *****************/
-    [self.game gameProcess:ts
-      rightPos:right_pos
-      rightAtt:right_att
-      rightAcc:right_acc
-     rightZupt:rightZupt
-   right_press:right_press
-       leftPos:left_pos
-       leftAtt:left_att
-       leftAcc:left_acc
-      leftZupt:leftZupt
-    left_press:left_press
-          jump:jump
-          down:down
-          rssi:rssi
-          girl_shoes:girlShoes];
+    //游戏数据
+    NSData * validData= [characteristic subdataWithRange:NSMakeRange(4, characteristic.length-4)];
+    Byte * buff = (Byte*)[validData bytes];
+    game->GameProcessBuf(buff, (int)validData.length);
+    
     int length = 4;
     int result[length];
-    [self.game getGameResult:result];
-//   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
+    game->getGameResult(result);
+    //   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
         
-    /******************步频数据处理 + 回调*****************/
-    int leftStepStatus =  [self.game getStepStatus:LEFT_FOOT_OC];
-    int leftStepFreq =  [self.game getStepFreq:LEFT_FOOT_OC];
-    int leftStepCount =  [self.game getStepCount:LEFT_FOOT_OC];
-    int rightStepStatus =  [self.game getStepStatus:RIGHT_FOOT_OC];
-    int rightStepFreq =  [self.game getStepFreq:RIGHT_FOOT_OC];
-    int rightStepCount =  [self.game getStepCount:RIGHT_FOOT_OC];
+    NSString * aString = [NSString stringWithUTF8String:game->getGameDataStr().c_str()];
+//       NSLog(@"aString == %@",aString);
+
+    self.tempStepString = [NSString stringWithFormat:@"%@\n",aString];
+    if (self.tempStepString!=nil && self.tempStepString.length>1){
+        [self writeFileToplist];
+    }
     
-    /******************左右脚动作数据处理 + 回调*****************/
+    /******************步频数据处理 + 回调*****************/
+    int leftStepStatus =  game->getStepStatus(LEFT_FOOT);
+    int leftStepFreq =  game->getStepFreq(LEFT_FOOT);
+    int leftStepCount =  game->getStepCount(LEFT_FOOT);
+    int rightStepStatus =  game->getStepStatus(RIGHT_FOOT);
+    int rightStepFreq =  game->getStepFreq(RIGHT_FOOT);
+    int rightStepCount =  game->getStepCount(RIGHT_FOOT);
+        
+//    *****************左右脚动作数据处理 + 回调****************
     int motionLeft = result[0];//左脚的动作
     int motionRight = result[1];//右脚的动作
     int motionJump = result[2];//jump
@@ -714,50 +728,39 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         self.step_count = leftStepCount+rightStepCount;
         self.allMotionCountBLock(self.jump_count, self.crouch_count, leftStepCount+rightStepCount);
     }
-    
-        //ios call unity
-        if (self.gameModel==YES){//当前是游戏模式
-            
+
+//        ios call unity
+//        if (self.gameModel==YES){//当前是游戏模式
+
             //跑酷才需要回调
             if (self.game_id == GAME_TYPE_RUN){
                 [self.sdk bridgingStepAction:DEVICETYPE_MAIN leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//左右脚速度 步频
             }
-            
-//            NSLog(@"主设备 当前是开启游戏模式 ===== >> %d",self.gameModel);
             [self.sdk bridgingMotionAction:DEVICETYPE_MAIN left:motionLeft right:motionRight];//左右脚动作
-            
-        }else{//当前是交互模式
-            
+
+//        }else{//当前是交互模式
+
 //            int interaction = [self.game getInteractionCMD];
 ////            NSLog(@"主设备 当前的脚步交互动作 ===== >> %d",interaction);
 //            [self.sdk bridgingInteraction:DEVICETYPE_MAIN code:interaction];
 //            if (self.getInteractionBlock){
 //                self.getInteractionBlock(interaction);
 //            }
-            
-        }
+//        }
     
+  
     //
     NSArray *aArray = [self.tempStepString componentsSeparatedByString:@","];
-    self.testLabel.text = [NSString stringWithFormat:@"right:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nleft:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nZupt:[%d,%d]  press:[%d,%d] \nj&d[%d %d]  rssi:%d  ts:%d \n脚步: %@ %@ \n步频: %d %d ",right_pos[0],right_pos[1],right_pos[2],right_att[0],right_att[1],right_att[2],right_acc[0],right_acc[1],right_acc[2],left_pos[0],left_pos[1],left_pos[2],left_att[0],left_att[1],left_att[2],left_acc[0],left_acc[1],left_acc[2],rightZupt,leftZupt,right_press,left_press,jump,down,rssi,ts,aArray[aArray.count-2],aArray.lastObject,leftStepFreq,rightStepFreq];
-    
-    
-    //       /******************测试丢包*****************/
-    //    int difference = abs(ts) - abs(self.tempTs);
-    //    //当前丢包数>2算作丢包
-    //    if (abs(difference)>=2){
-    //        self.loss = self.loss + abs(difference)-1;
-    //        self.totalPackages = self.totalPackages+abs(difference);
-    ////        NSLog(@"总数据包 1== >>  self.totalPackages %d",self.totalPackages);
-    //    }else{
-    //        self.totalPackages++;
-    ////        NSLog(@"总数据包 2== >>  self.totalPackages %d",self.totalPackages);
-    //    }
-    //    self.tempTs = abs(ts);
-    ////    NSLog(@"收到数据包 ===================>> ts: %d   当前包LOSS: %d    总包数: %d  总LOSS: %d",ts,abs(difference),self.totalPackages,self.loss);
+    self.testLabel.text = [NSString stringWithFormat:@"right:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nleft:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nZupt:[%d,%d]  press:[%d,%d] \nj&d[%d %d]  rssi:[%d %@] ts:%d \n脚步: %@ %@ \n步频: %d %d ",right_pos[0],right_pos[1],right_pos[2],right_att[0],right_att[1],right_att[2],right_acc[0],right_acc[1],right_acc[2],left_pos[0],left_pos[1],left_pos[2],left_att[0],left_att[1],left_att[2],left_acc[0],left_acc[1],left_acc[2],rightZupt,leftZupt,right_press,left_press,jump,down,rssi,self.RSSI,ts,aArray[aArray.count-2],aArray.lastObject,leftStepFreq,rightStepFreq];
     
 }
 
+//
+////读取剑波sdk返回字符串数据
+//-(void)ocGetGameDataStr:(NSData*)characteristic{
+//
+//}
+
 #pragma mark ===============================================>>副设备 报文数据解析后 -- 调用蓝牙鞋子SDK装换数据 -- ios call unity 更新游戏动作
 -(void)viceShoseSDKRight_pos:(int[3])right_pos
                    Right_att:(int[3])right_att
@@ -774,64 +777,64 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                    girlShoes:(int)girlShoes
                  right_press:(int)right_press
                   left_press:(int)left_press{
-        
-        /********************初始化 运动轨迹算法 SDK *****************/
-        [self.viceDeviceGame gameProcess:ts
-                              rightPos:right_pos
-                              rightAtt:right_att
-                              rightAcc:right_acc
-                             rightZupt:rightZupt
-                           right_press:right_press
-                               leftPos:left_pos
-                               leftAtt:left_att
-                               leftAcc:left_acc
-                              leftZupt:leftZupt
-                            left_press:left_press
-                                  jump:jump
-                                  down:down
-                                  rssi:rssi
-                                  girl_shoes:girlShoes];
-   int length = 4;
-   int result[length];
-   [self.viceDeviceGame getGameResult:result];
-//   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
-    
-    /********************蓝牙sdk返回的鞋子 状态 步频 步数*****************/
-   int leftStepStatus =  [self.viceDeviceGame getStepStatus:LEFT_FOOT_OC];
-   int leftStepFreq =  [self.viceDeviceGame getStepFreq:LEFT_FOOT_OC];
-//   int leftStepCount =  [self.viceDeviceGame getStepCount:LEFT_FOOT_OC];
-    int rightStepStatus =  [self.viceDeviceGame getStepStatus:RIGHT_FOOT_OC];
-    int rightStepFreq =  [self.viceDeviceGame getStepFreq:RIGHT_FOOT_OC];
-//    int rightStepCount =  [self.viceDeviceGame getStepCount:RIGHT_FOOT_OC];
-    //ios call unity
-//    if (self.game_id == GAME_TYPE_RUN){//跑酷才需要回调
-        [self.sdk bridgingStepAction:DEVICETYPE_VICE leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//副设备左右脚速度 步频
+//
+//        /********************初始化 运动轨迹算法 SDK *****************/
+//        [self.viceDeviceGame gameProcess:ts
+//                              rightPos:right_pos
+//                              rightAtt:right_att
+//                              rightAcc:right_acc
+//                             rightZupt:rightZupt
+//                           right_press:right_press
+//                               leftPos:left_pos
+//                               leftAtt:left_att
+//                               leftAcc:left_acc
+//                              leftZupt:leftZupt
+//                            left_press:left_press
+//                                  jump:jump
+//                                  down:down
+//                                  rssi:rssi
+//                                  girl_shoes:girlShoes];
+//   int length = 4;
+//   int result[length];
+//   [self.viceDeviceGame getGameResult:result];
+////   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
+//
+//    /********************蓝牙sdk返回的鞋子 状态 步频 步数*****************/
+//   int leftStepStatus =  [self.viceDeviceGame getStepStatus:LEFT_FOOT_OC];
+//   int leftStepFreq =  [self.viceDeviceGame getStepFreq:LEFT_FOOT_OC];
+////   int leftStepCount =  [self.viceDeviceGame getStepCount:LEFT_FOOT_OC];
+//    int rightStepStatus =  [self.viceDeviceGame getStepStatus:RIGHT_FOOT_OC];
+//    int rightStepFreq =  [self.viceDeviceGame getStepFreq:RIGHT_FOOT_OC];
+////    int rightStepCount =  [self.viceDeviceGame getStepCount:RIGHT_FOOT_OC];
+//    //ios call unity
+////    if (self.game_id == GAME_TYPE_RUN){//跑酷才需要回调
+//        [self.sdk bridgingStepAction:DEVICETYPE_VICE leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//副设备左右脚速度 步频
+////    }
+//
+//    /********************蓝牙sdk返回的鞋子 动作*****************/
+//    int motionLeft = result[0];//左脚的动作
+//    int motionRight = result[1];//右脚的动作
+//    int ivce_motionJump = result[2];//jump
+//    int ivce_motionDown = result[3];//down
+//    if (motionLeft==-1 && motionRight == -1&& ivce_motionJump == -1&& ivce_motionDown == -1){//无效动作
+//        return;
+//    }else{
+//        //跳跃和蹲下的动作 双脚是同步的
+//        if (ivce_motionJump == MOTION_JUMP){
+//            motionLeft = ivce_motionJump;
+//            motionRight = ivce_motionJump;
+//            NSLog(@"副设备 ======================================== 跳起来 jump_count = %d ",self.jump_count);
+//        }
+//        if (ivce_motionDown == MOTION_DOWN){
+//            motionLeft = ivce_motionDown;
+//            motionRight = ivce_motionDown;
+//            NSLog(@"副设备 ========================================= 蹲下去 crouch_count = %d ",self.crouch_count);
+//        }
+//        //ios call unity as相互NX你·
+//        [self.sdk bridgingMotionAction:DEVICETYPE_VICE left:motionLeft right:motionRight];//副设备左右脚动作
+//
 //    }
-    
-    /********************蓝牙sdk返回的鞋子 动作*****************/
-    int motionLeft = result[0];//左脚的动作
-    int motionRight = result[1];//右脚的动作
-    int ivce_motionJump = result[2];//jump
-    int ivce_motionDown = result[3];//down
-    if (motionLeft==-1 && motionRight == -1&& ivce_motionJump == -1&& ivce_motionDown == -1){//无效动作
-        return;
-    }else{
-        //跳跃和蹲下的动作 双脚是同步的
-        if (ivce_motionJump == MOTION_JUMP){
-            motionLeft = ivce_motionJump;
-            motionRight = ivce_motionJump;
-            NSLog(@"副设备 ======================================== 跳起来 jump_count = %d ",self.jump_count);
-        }
-        if (ivce_motionDown == MOTION_DOWN){
-            motionLeft = ivce_motionDown;
-            motionRight = ivce_motionDown;
-            NSLog(@"副设备 ========================================= 蹲下去 crouch_count = %d ",self.crouch_count);
-        }
-        //ios call unity as相互NX你·
-        [self.sdk bridgingMotionAction:DEVICETYPE_VICE left:motionLeft right:motionRight];//副设备左右脚动作
-        
-    }
-    
+//
 }
 
 #pragma mark ===============================================>> 蓝牙发送各类数据
@@ -1023,28 +1026,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
 }
 
 #pragma mark ===============================================>> 存储和上传数据
-//读取剑波sdk返回字符串数据
--(void)ocGetGameDataStr:(NSData*)characteristic{
-    
-    //剑波数据测试组
-    NSData * validData= [characteristic subdataWithRange:NSMakeRange(4, characteristic.length-4)];
-    Byte * buff = (Byte*)[validData bytes];
-      [self.game GameProcessBuf:buff length:(int)validData.length];
-//      self.tempStepString = [self.game getGameDataStr];
-    self.tempStepString = [NSString stringWithFormat:@"%@\n",[self.game getGameDataStr]];
-
-//    if (self.dataString.length<2){
-//        self.dataString = [self.game getGameDataStr];
-//    }else{
-//        self.dataString = [NSString stringWithFormat:@"%@\n%@",self.dataString,[self.game getGameDataStr]];
-//    }
-//              NSLog(@"剑波需要的 ===================>> %@",self.dataString);
-    
-    if (self.tempStepString!=nil && self.tempStepString.length>1){
-        [self writeFileToplist];
-    }
-    
-}
 
 - (void)clearCacheWithFilePath{
     

+ 4 - 0
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/LEONBLManager.h

@@ -47,6 +47,9 @@ typedef void(^LEReadValueForCharacteristicBlock)(CBPeripheral *peripheral,CBChar
 /** 往特性中写入数据的回调 */
 typedef void(^LEWriteToCharacteristicBlock)(CBPeripheral *peripheral,CBCharacteristic *characteristic, NSError *error,DEVICE_TYPE type);
 
+/** RSSI*/
+typedef void(^RSSIBlock)(NSNumber *RSSI);
+
 @interface LEONBLManager : NSObject
 
 //蓝牙外设
@@ -60,6 +63,7 @@ typedef void(^LEWriteToCharacteristicBlock)(CBPeripheral *peripheral,CBCharacter
 @property(nonatomic,copy)LEDiscoverCharacteristicsBlock  discoverCharacteristicsBlock;
 @property(nonatomic,copy)LEReadValueForCharacteristicBlock  readValueForCharacteristicBlock;
 @property(nonatomic,copy)LEWriteToCharacteristicBlock  writeToCharacteristicBlock;//
+@property(nonatomic,copy)RSSIBlock rssiBlock;//
 
 @property (strong, nonatomic)CBCentralManager * centralManager;/**< 蓝牙中心管理器 */
 

+ 41 - 4
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/LEONBLManager.m

@@ -55,10 +55,12 @@ static LEONBLManager * instance;
  初始外设管理类
  */
 -(void)initCBCentralManager{
+    
     //蓝牙没打开时alert提示框
 //    NSDictionary *options = @{CBCentralManagerOptionShowPowerAlertKey:@(YES)};
     NSDictionary *options = @{CBCentralManagerScanOptionAllowDuplicatesKey:@(YES)};
     self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue() options:options];
+    
 }
 
 #pragma mark ---------------- public methon ==>> 外部 操作蓝牙外设
@@ -69,7 +71,7 @@ static LEONBLManager * instance;
  */
 - (void)scanForPeripheralsWithServices:(nullable NSArray<CBUUID *> *)serviceUUIDs options:(nullable NSDictionary<NSString *, id> *)options{
     [self.centralManager scanForPeripheralsWithServices:serviceUUIDs options:options];
-    NSLog(@"开始扫描外设");
+//    NSLog(@"开始扫描外设");
 }
 
 /**
@@ -226,9 +228,15 @@ static LEONBLManager * instance;
     }
     
     if (peripheral == self.peripheral){
-        NSLog(@"主设备 查找 %@ 的特征",peripheral.name);
+        
+        for (CBService * service in peripheral.services){
+                
+            NSLog(@"主设备发现 %@ 的服务值:%@ 开始查找它的特征",peripheral.name,service);
+
+        }
+        
     }else if (peripheral == self.vicePeripheral){
-        NSLog(@"副设备 查找 %@ 的特征",peripheral.name);
+        NSLog(@"副设备发现 %@ 的服务值:%@ 开始查找它的特征",peripheral.name,peripheral.services);
     }
     
     //扫描所有的特征
@@ -248,7 +256,20 @@ static LEONBLManager * instance;
         if (peripheral==self.peripheral){
             
             _discoverCharacteristicsBlock(peripheral,service,service.characteristics,error);
-            NSLog(@"主设备 发现 %@ 服务+特征",peripheral.name);
+            
+            for (CBCharacteristic * cha in service.characteristics){
+                
+                if (cha.properties == 12){//写
+                    
+                    NSLog(@"主设备发现 %@ 写的特征值:%@",peripheral.name,cha.UUID);
+
+                }else if (cha.properties == 16){//读
+                    
+                    NSLog(@"主设备发现 %@ 读的特征值:%@",peripheral.name,cha.UUID);
+
+                }
+
+            }
 
         }else if (peripheral == self.vicePeripheral){
             
@@ -306,4 +327,20 @@ static LEONBLManager * instance;
 }
 
 
+/*!
+ *  @method peripheral:didReadRSSI:error:
+ *
+ *  @param peripheral    The peripheral providing this update.
+ *  @param RSSI            The current RSSI of the link.
+ *  @param error        If an error occurred, the cause of the failure.
+ *
+ *  @discussion            This method returns the result of a @link readRSSI: @/link call.
+ */
+- (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(nullable NSError *)error{
+    if (_rssiBlock){
+        _rssiBlock(RSSI);
+    }
+}
+
+
 @end

+ 1 - 1
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/pub.h

@@ -84,4 +84,4 @@ struct FootActionState {
     uint32_t Triggering_time;
 };
 
-#endif
+#endif

+ 3 - 3
DanceGame/Unity-iPhone.xcodeproj/project.pbxproj

@@ -1481,12 +1481,12 @@
 		933F31E3273BA1E70084CFD5 /* BLE */ = {
 			isa = PBXGroup;
 			children = (
-				933F31E4273BA1E70084CFD5 /* CBPeripheral+ADName.m */,
-				933F31E5273BA1E70084CFD5 /* LEONBLManager.h */,
 				933F31E6273BA1E70084CFD5 /* BTDataProcess.h */,
 				933F31E7273BA1E70084CFD5 /* BTDataProcess.mm */,
-				933F31E8273BA1E70084CFD5 /* LEONBLManager.m */,
 				933F31E9273BA1E70084CFD5 /* CBPeripheral+ADName.h */,
+				933F31E4273BA1E70084CFD5 /* CBPeripheral+ADName.m */,
+				933F31E5273BA1E70084CFD5 /* LEONBLManager.h */,
+				933F31E8273BA1E70084CFD5 /* LEONBLManager.m */,
 			);
 			path = BLE;
 			sourceTree = "<group>";

BIN
DanceGame/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate


+ 2 - 0
RunGame/Classes/UnityAppController.mm

@@ -344,6 +344,8 @@ extern "C" void UnityCleanupTrampoline()
          NSLog(@"打开方式 手动点击打开");
          [IOSPlatformSDK sharedInstance];
      }
+    
+//    NSLog(@"hhhhhhhhhhhhhhhhh = %@",[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]);
     return YES;
     
 }

+ 5 - 10
RunGame/Info.plist

@@ -34,7 +34,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>3</string>
+	<string>$(CURRENT_PROJECT_VERSION)</string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>NSAppTransportSecurity</key>
@@ -42,6 +42,10 @@
 		<key>NSAllowsArbitraryLoads</key>
 		<true/>
 	</dict>
+	<key>NSBluetoothAlwaysUsageDescription</key>
+	<string>App 需要您的同意,才能访问蓝牙连接智能鞋</string>
+	<key>NSBluetoothPeripheralUsageDescription</key>
+	<string>App 需要您的同意,才能访问蓝牙连接智能鞋</string>
 	<key>UIBackgroundModes</key>
 	<array>
 		<string>bluetooth-central</string>
@@ -73,14 +77,5 @@
 	<string></string>
 	<key>Unity_LoadingActivityIndicatorStyle</key>
 	<integer>-1</integer>
-    <key>NSAppTransportSecurity</key>
-    <dict>
-    <key>NSAllowsArbitraryLoads</key>
-    <true/>
-    </dict>
-    <key>NSBluetoothAlwaysUsageDescription</key>
-    <string>App 需要您的同意,才能访问蓝牙连接智能鞋</string>
-    <key>NSBluetoothPeripheralUsageDescription</key>
-    <string>App 需要您的同意,才能访问蓝牙连接智能鞋</string>
 </dict>
 </plist>

+ 14 - 14
RunGame/SDK/BLE/BTDataProcess.h

@@ -21,20 +21,20 @@ typedef NS_ENUM(int, GAME_TYPE){
 
 //动作数据
 typedef NS_ENUM(NSInteger, GAME_MOTION){
-    MOTION_STOP =0,
-    MOTION_RUN,// 跑
-    MOTION_JUMP, // 跳
-    MOTION_DOWN, // 蹲
-    MOTION_LEFT, // 滑左
-    MOTION_RIGHT, // 滑右
-    MOTION_FRONT, // 滑前
-    MOTION_BACK, // 滑后
-    MOTION_LEFT_UP, // 点击-左上
-    MOTION_LEFT_DOWN, // 点击-左下
-    MOTION_RIGHT_UP, // 点击-右上
-    MOTION_RIGHT_DOWN, // 点击-右下
-    MOTION_STEP, // 点击-原地踩
-    NUMBERS_OF_MOTION
+    CO_MOTION_STOP =0,
+    CO_MOTION_RUN,// 跑
+    CO_MOTION_JUMP, // 跳
+    CO_MOTION_DOWN, // 蹲
+    CO_MOTION_LEFT, // 滑左
+    CO_MOTION_RIGHT, // 滑右
+    CO_MOTION_FRONT, // 滑前
+    CO_MOTION_BACK, // 滑后
+    CO_MOTION_LEFT_UP, // 点击-左上
+    CO_MOTION_LEFT_DOWN, // 点击-左下
+    CO_MOTION_RIGHT_UP, // 点击-右上
+    CO_MOTION_RIGHT_DOWN, // 点击-右下
+    CO_MOTION_STEP, // 点击-原地踩
+    CO_NUMBERS_OF_MOTION
 };
 
 //蓝牙状态

+ 135 - 154
RunGame/SDK/BLE/BTDataProcess.mm

@@ -8,13 +8,21 @@
 
 #import "BTDataProcess.h"
 #import "IOSPlatformSDK.h"
+#include "Game.h"
 #define NSLog(format, ...) printf("TIME:%s FILE:%s(%d行) FUNCTION:%s %s\n",__TIME__, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String])
 @interface BTDataProcess ()<NSURLSessionDataDelegate>
 
+{
+@private
+    Game *game;
+}
+
 @property (strong, nonatomic)NSMutableArray  * deviceArray;/**< 蓝牙设备个数 */
 @property (nonatomic,strong)IOSPlatformSDK * sdk;//ios_sdk
-@property (nonatomic,strong)GameObjc * game ;//主设备蓝牙算法sdk
-@property (nonatomic,strong)GameObjc * viceDeviceGame ;//副设备设备蓝牙算法sdk
+
+//@property (nonatomic,strong)GameObjc * game ;//主设备蓝牙算法sdk
+
+//@property (nonatomic,strong)GameObjc * viceDeviceGame ;//副设备设备蓝牙算法sdk
 @property(nonatomic,weak)NSTimer * timer;//定时器 定时请求主、副设备电量
 @property(nonatomic,assign)BOOL gameModel;//是否开启游戏模式
 
@@ -27,9 +35,9 @@
 @property (nonatomic,assign)int  tempTs;
 @property (nonatomic,assign)int  loss;
 @property (nonatomic,assign)int  totalPackages;
-@property (nonatomic,strong)NSString * dataString;//缓存plist
+//@property (nonatomic,strong)NSString * dataString;//缓存plist
 @property (nonatomic,strong)NSString * tempStepString;//缓存plist
-
+@property(nonatomic,assign) NSNumber *RSSI;//威严要的测试数据
 /*****测试*******/
 
 @end
@@ -230,7 +238,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                     if (self.deviceArray.count == 0){//数据源为0
                         
         //                    NSLog(@"add 扫描发现蓝牙设备  %@",peripheral.name);
-                           
+//                        peripheral.RSSI
                             [self.deviceArray addObject:peripheral];
                             //判断扫描到外设之后是否要链接蓝牙
                             [self ifAppJumpWithIdentifier:peripheral];
@@ -310,10 +318,10 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         //初始化运轨sdk
         if (self.deviceType==DEVICETYPE_MAIN){
             LEManager.peripheral = peripheral;
-            self.game = [[GameObjc alloc] initWithGametype:self.game_id];
+            game = new Game(self.game_id);
         }else if (self.deviceType == DEVICETYPE_VICE){
             LEManager.vicePeripheral = peripheral;
-            self.viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
+//            self.viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
         }
         
         //根据ios_sdk传入deviceType 链接 主/副 设备
@@ -379,6 +387,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         if ([characteristic.UUID.UUIDString isEqualToString:@"6E400003-B5A3-F393-E0A9-E50E24DCCA9E"]){//判断是不是我们设备的特征值
 //            NSLog(@"characteristic.UUID.UUIDString = %@",characteristic.UUID.UUIDString);
                 [self verifyData:characteristic deviceType:type];
+                [peripheral readRSSI];
          }
     };
 
@@ -386,21 +395,33 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     LEManager.writeToCharacteristicBlock = ^(CBPeripheral * _Nonnull peripheral,CBCharacteristic * _Nonnull characteristic, NSError * _Nonnull error, DEVICE_TYPE type){
     };
     
+    //
+    LEManager.rssiBlock = ^(NSNumber * _Nonnull RSSI){
+        self.RSSI = RSSI;
+//        NSLog(@"self.RSSI  = %@",self.RSSI );
+    };
+    
     //蓝牙连接成功
     LEManager.successfulBlock = ^(CBPeripheral * _Nonnull peripheral){
 //        if (peripheral == LEManager.peripheral){
             [[AnimationView shanreAnimationView] stopAnimation];
     };
 
-//    //蓝牙连接失败
-//    LEManager.connectFailureBlock = ^(NSError * _Nonnull error){
+    //蓝牙连接失败
+    LEManager.connectFailureBlock = ^(NSError * _Nonnull error){
+        NSLog(@"蓝牙链接失败");
 //        if (peripheral == LEManager.peripheral){
-//            [[AnimationView shanreAnimationView] addAnimation];
-//        }
-//    };
 //
+//        }
+    };
+
     //蓝牙连接丢失
     LEManager.disConnectBlock = ^(CBPeripheral * _Nonnull peripheral, NSError * _Nonnull error){
+        
+        NSLog(@"蓝牙链接丢失");
+        //断线重连
+        [self initCBCentralManager];
+
         if (peripheral == LEManager.peripheral){
             if (LEManager.peripheral!=nil){
                 
@@ -427,7 +448,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
 #pragma mark ===============================================>> 读取特征后 鞋子打开游戏模式 & 激光开关 &查询鞋子蓝牙状态 & 主设备初始化缓存游戏步数
 -(void)initGameAction:(DEVICE_TYPE)deviceType{
     
-    
     //初始化缓存动作数据
     if (deviceType==DEVICETYPE_MAIN){
         
@@ -575,20 +595,16 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                    
 //                   NSLog(@"主设备 接收到 鞋子动作数据 data = %@",characteristic);
                    //调取鞋子SDK
-                   [self shoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press];
+                   [self shoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press characteristic:characteristic];
                    
                }else if (deviceType==DEVICETYPE_VICE){//副设备动作数据
                    
 //                   NSLog(@"副设备 接收到 鞋子动作数据 data = %@",characteristic);
-                   //调取鞋子SDK
-                   [self viceShoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press];
+//                   //调取鞋子SDK
+//                   [self viceShoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press];
                    
                }
-          
-              //开启剑波sdk数据字符串存储
-              [self ocGetGameDataStr:characteristic];
-          
-      
+              
         }else if (dataType == -95){//获取的是查询的数据 char-->int a1 = -95
 
             if (characteristic.length == 74){//A1+0  >> 0: 设备基本信息 ==>> 预留参数 趣动app用 sdk暂未调用
@@ -609,7 +625,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
 //                int rightPressure = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(17, 4)]];
 //                int rightStepCount = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(21, 4)]];
                 
-                
                 if (deviceType==DEVICETYPE_MAIN){//主设备
                     
                     NSLog(@"主设备 接收到 鞋子硬件数据 data 26 = %@  电量 %d %d",characteristic,leftElectricity,rightElectricity);
@@ -655,38 +670,37 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                     rssi:(int)rssi
                girlShoes:(int)girlShoes
              right_press:(int)right_press
-              left_press:(int)left_press{
+              left_press:(int)left_press
+          characteristic:(NSData*)characteristic{
     
     /********************初始化 运动轨迹算法 SDK *****************/
-    [self.game gameProcess:ts
-      rightPos:right_pos
-      rightAtt:right_att
-      rightAcc:right_acc
-     rightZupt:rightZupt
-   right_press:right_press
-       leftPos:left_pos
-       leftAtt:left_att
-       leftAcc:left_acc
-      leftZupt:leftZupt
-    left_press:left_press
-          jump:jump
-          down:down
-          rssi:rssi
-          girl_shoes:girlShoes];
+    //游戏数据
+    NSData * validData= [characteristic subdataWithRange:NSMakeRange(4, characteristic.length-4)];
+    Byte * buff = (Byte*)[validData bytes];
+    game->GameProcessBuf(buff, (int)validData.length);
+    
     int length = 4;
     int result[length];
-    [self.game getGameResult:result];
-//   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
+    game->getGameResult(result);
+    //   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
         
-    /******************步频数据处理 + 回调*****************/
-    int leftStepStatus =  [self.game getStepStatus:LEFT_FOOT_OC];
-    int leftStepFreq =  [self.game getStepFreq:LEFT_FOOT_OC];
-    int leftStepCount =  [self.game getStepCount:LEFT_FOOT_OC];
-    int rightStepStatus =  [self.game getStepStatus:RIGHT_FOOT_OC];
-    int rightStepFreq =  [self.game getStepFreq:RIGHT_FOOT_OC];
-    int rightStepCount =  [self.game getStepCount:RIGHT_FOOT_OC];
+    NSString * aString = [NSString stringWithUTF8String:game->getGameDataStr().c_str()];
+//       NSLog(@"aString == %@",aString);
+
+    self.tempStepString = [NSString stringWithFormat:@"%@\n",aString];
+    if (self.tempStepString!=nil && self.tempStepString.length>1){
+        [self writeFileToplist];
+    }
     
-    /******************左右脚动作数据处理 + 回调*****************/
+    /******************步频数据处理 + 回调*****************/
+    int leftStepStatus =  game->getStepStatus(LEFT_FOOT);
+    int leftStepFreq =  game->getStepFreq(LEFT_FOOT);
+    int leftStepCount =  game->getStepCount(LEFT_FOOT);
+    int rightStepStatus =  game->getStepStatus(RIGHT_FOOT);
+    int rightStepFreq =  game->getStepFreq(RIGHT_FOOT);
+    int rightStepCount =  game->getStepCount(RIGHT_FOOT);
+        
+//    *****************左右脚动作数据处理 + 回调****************
     int motionLeft = result[0];//左脚的动作
     int motionRight = result[1];//右脚的动作
     int motionJump = result[2];//jump
@@ -714,50 +728,39 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         self.step_count = leftStepCount+rightStepCount;
         self.allMotionCountBLock(self.jump_count, self.crouch_count, leftStepCount+rightStepCount);
     }
-    
-        //ios call unity
-        if (self.gameModel==YES){//当前是游戏模式
-            
+
+//        ios call unity
+//        if (self.gameModel==YES){//当前是游戏模式
+
             //跑酷才需要回调
             if (self.game_id == GAME_TYPE_RUN){
                 [self.sdk bridgingStepAction:DEVICETYPE_MAIN leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//左右脚速度 步频
             }
-            
-//            NSLog(@"主设备 当前是开启游戏模式 ===== >> %d",self.gameModel);
             [self.sdk bridgingMotionAction:DEVICETYPE_MAIN left:motionLeft right:motionRight];//左右脚动作
-            
-        }else{//当前是交互模式
-            
+
+//        }else{//当前是交互模式
+
 //            int interaction = [self.game getInteractionCMD];
 ////            NSLog(@"主设备 当前的脚步交互动作 ===== >> %d",interaction);
 //            [self.sdk bridgingInteraction:DEVICETYPE_MAIN code:interaction];
 //            if (self.getInteractionBlock){
 //                self.getInteractionBlock(interaction);
 //            }
-            
-        }
+//        }
     
+  
     //
     NSArray *aArray = [self.tempStepString componentsSeparatedByString:@","];
-    self.testLabel.text = [NSString stringWithFormat:@"right:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nleft:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nZupt:[%d,%d]  press:[%d,%d] \nj&d[%d %d]  rssi:%d  ts:%d \n脚步: %@ %@ \n步频: %d %d ",right_pos[0],right_pos[1],right_pos[2],right_att[0],right_att[1],right_att[2],right_acc[0],right_acc[1],right_acc[2],left_pos[0],left_pos[1],left_pos[2],left_att[0],left_att[1],left_att[2],left_acc[0],left_acc[1],left_acc[2],rightZupt,leftZupt,right_press,left_press,jump,down,rssi,ts,aArray[aArray.count-2],aArray.lastObject,leftStepFreq,rightStepFreq];
-    
-    
-    //       /******************测试丢包*****************/
-    //    int difference = abs(ts) - abs(self.tempTs);
-    //    //当前丢包数>2算作丢包
-    //    if (abs(difference)>=2){
-    //        self.loss = self.loss + abs(difference)-1;
-    //        self.totalPackages = self.totalPackages+abs(difference);
-    ////        NSLog(@"总数据包 1== >>  self.totalPackages %d",self.totalPackages);
-    //    }else{
-    //        self.totalPackages++;
-    ////        NSLog(@"总数据包 2== >>  self.totalPackages %d",self.totalPackages);
-    //    }
-    //    self.tempTs = abs(ts);
-    ////    NSLog(@"收到数据包 ===================>> ts: %d   当前包LOSS: %d    总包数: %d  总LOSS: %d",ts,abs(difference),self.totalPackages,self.loss);
+    self.testLabel.text = [NSString stringWithFormat:@"right:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nleft:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nZupt:[%d,%d]  press:[%d,%d] \nj&d[%d %d]  rssi:[%d %@] ts:%d \n脚步: %@ %@ \n步频: %d %d ",right_pos[0],right_pos[1],right_pos[2],right_att[0],right_att[1],right_att[2],right_acc[0],right_acc[1],right_acc[2],left_pos[0],left_pos[1],left_pos[2],left_att[0],left_att[1],left_att[2],left_acc[0],left_acc[1],left_acc[2],rightZupt,leftZupt,right_press,left_press,jump,down,rssi,self.RSSI,ts,aArray[aArray.count-2],aArray.lastObject,leftStepFreq,rightStepFreq];
     
 }
 
+//
+////读取剑波sdk返回字符串数据
+//-(void)ocGetGameDataStr:(NSData*)characteristic{
+//
+//}
+
 #pragma mark ===============================================>>副设备 报文数据解析后 -- 调用蓝牙鞋子SDK装换数据 -- ios call unity 更新游戏动作
 -(void)viceShoseSDKRight_pos:(int[3])right_pos
                    Right_att:(int[3])right_att
@@ -774,64 +777,64 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                    girlShoes:(int)girlShoes
                  right_press:(int)right_press
                   left_press:(int)left_press{
-        
-        /********************初始化 运动轨迹算法 SDK *****************/
-        [self.viceDeviceGame gameProcess:ts
-                              rightPos:right_pos
-                              rightAtt:right_att
-                              rightAcc:right_acc
-                             rightZupt:rightZupt
-                           right_press:right_press
-                               leftPos:left_pos
-                               leftAtt:left_att
-                               leftAcc:left_acc
-                              leftZupt:leftZupt
-                            left_press:left_press
-                                  jump:jump
-                                  down:down
-                                  rssi:rssi
-                                  girl_shoes:girlShoes];
-   int length = 4;
-   int result[length];
-   [self.viceDeviceGame getGameResult:result];
-//   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
-    
-    /********************蓝牙sdk返回的鞋子 状态 步频 步数*****************/
-   int leftStepStatus =  [self.viceDeviceGame getStepStatus:LEFT_FOOT_OC];
-   int leftStepFreq =  [self.viceDeviceGame getStepFreq:LEFT_FOOT_OC];
-//   int leftStepCount =  [self.viceDeviceGame getStepCount:LEFT_FOOT_OC];
-    int rightStepStatus =  [self.viceDeviceGame getStepStatus:RIGHT_FOOT_OC];
-    int rightStepFreq =  [self.viceDeviceGame getStepFreq:RIGHT_FOOT_OC];
-//    int rightStepCount =  [self.viceDeviceGame getStepCount:RIGHT_FOOT_OC];
-    //ios call unity
-//    if (self.game_id == GAME_TYPE_RUN){//跑酷才需要回调
-        [self.sdk bridgingStepAction:DEVICETYPE_VICE leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//副设备左右脚速度 步频
+//
+//        /********************初始化 运动轨迹算法 SDK *****************/
+//        [self.viceDeviceGame gameProcess:ts
+//                              rightPos:right_pos
+//                              rightAtt:right_att
+//                              rightAcc:right_acc
+//                             rightZupt:rightZupt
+//                           right_press:right_press
+//                               leftPos:left_pos
+//                               leftAtt:left_att
+//                               leftAcc:left_acc
+//                              leftZupt:leftZupt
+//                            left_press:left_press
+//                                  jump:jump
+//                                  down:down
+//                                  rssi:rssi
+//                                  girl_shoes:girlShoes];
+//   int length = 4;
+//   int result[length];
+//   [self.viceDeviceGame getGameResult:result];
+////   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
+//
+//    /********************蓝牙sdk返回的鞋子 状态 步频 步数*****************/
+//   int leftStepStatus =  [self.viceDeviceGame getStepStatus:LEFT_FOOT_OC];
+//   int leftStepFreq =  [self.viceDeviceGame getStepFreq:LEFT_FOOT_OC];
+////   int leftStepCount =  [self.viceDeviceGame getStepCount:LEFT_FOOT_OC];
+//    int rightStepStatus =  [self.viceDeviceGame getStepStatus:RIGHT_FOOT_OC];
+//    int rightStepFreq =  [self.viceDeviceGame getStepFreq:RIGHT_FOOT_OC];
+////    int rightStepCount =  [self.viceDeviceGame getStepCount:RIGHT_FOOT_OC];
+//    //ios call unity
+////    if (self.game_id == GAME_TYPE_RUN){//跑酷才需要回调
+//        [self.sdk bridgingStepAction:DEVICETYPE_VICE leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//副设备左右脚速度 步频
+////    }
+//
+//    /********************蓝牙sdk返回的鞋子 动作*****************/
+//    int motionLeft = result[0];//左脚的动作
+//    int motionRight = result[1];//右脚的动作
+//    int ivce_motionJump = result[2];//jump
+//    int ivce_motionDown = result[3];//down
+//    if (motionLeft==-1 && motionRight == -1&& ivce_motionJump == -1&& ivce_motionDown == -1){//无效动作
+//        return;
+//    }else{
+//        //跳跃和蹲下的动作 双脚是同步的
+//        if (ivce_motionJump == MOTION_JUMP){
+//            motionLeft = ivce_motionJump;
+//            motionRight = ivce_motionJump;
+//            NSLog(@"副设备 ======================================== 跳起来 jump_count = %d ",self.jump_count);
+//        }
+//        if (ivce_motionDown == MOTION_DOWN){
+//            motionLeft = ivce_motionDown;
+//            motionRight = ivce_motionDown;
+//            NSLog(@"副设备 ========================================= 蹲下去 crouch_count = %d ",self.crouch_count);
+//        }
+//        //ios call unity as相互NX你·
+//        [self.sdk bridgingMotionAction:DEVICETYPE_VICE left:motionLeft right:motionRight];//副设备左右脚动作
+//
 //    }
-    
-    /********************蓝牙sdk返回的鞋子 动作*****************/
-    int motionLeft = result[0];//左脚的动作
-    int motionRight = result[1];//右脚的动作
-    int ivce_motionJump = result[2];//jump
-    int ivce_motionDown = result[3];//down
-    if (motionLeft==-1 && motionRight == -1&& ivce_motionJump == -1&& ivce_motionDown == -1){//无效动作
-        return;
-    }else{
-        //跳跃和蹲下的动作 双脚是同步的
-        if (ivce_motionJump == MOTION_JUMP){
-            motionLeft = ivce_motionJump;
-            motionRight = ivce_motionJump;
-            NSLog(@"副设备 ======================================== 跳起来 jump_count = %d ",self.jump_count);
-        }
-        if (ivce_motionDown == MOTION_DOWN){
-            motionLeft = ivce_motionDown;
-            motionRight = ivce_motionDown;
-            NSLog(@"副设备 ========================================= 蹲下去 crouch_count = %d ",self.crouch_count);
-        }
-        //ios call unity as相互NX你·
-        [self.sdk bridgingMotionAction:DEVICETYPE_VICE left:motionLeft right:motionRight];//副设备左右脚动作
-        
-    }
-    
+//
 }
 
 #pragma mark ===============================================>> 蓝牙发送各类数据
@@ -1023,28 +1026,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
 }
 
 #pragma mark ===============================================>> 存储和上传数据
-//读取剑波sdk返回字符串数据
--(void)ocGetGameDataStr:(NSData*)characteristic{
-    
-    //剑波数据测试组
-    NSData * validData= [characteristic subdataWithRange:NSMakeRange(4, characteristic.length-4)];
-    Byte * buff = (Byte*)[validData bytes];
-      [self.game GameProcessBuf:buff length:(int)validData.length];
-//      self.tempStepString = [self.game getGameDataStr];
-    self.tempStepString = [NSString stringWithFormat:@"%@\n",[self.game getGameDataStr]];
-
-//    if (self.dataString.length<2){
-//        self.dataString = [self.game getGameDataStr];
-//    }else{
-//        self.dataString = [NSString stringWithFormat:@"%@\n%@",self.dataString,[self.game getGameDataStr]];
-//    }
-//              NSLog(@"剑波需要的 ===================>> %@",self.dataString);
-    
-    if (self.tempStepString!=nil && self.tempStepString.length>1){
-        [self writeFileToplist];
-    }
-    
-}
 
 - (void)clearCacheWithFilePath{
     

+ 4 - 0
RunGame/SDK/BLE/LEONBLManager.h

@@ -47,6 +47,9 @@ typedef void(^LEReadValueForCharacteristicBlock)(CBPeripheral *peripheral,CBChar
 /** 往特性中写入数据的回调 */
 typedef void(^LEWriteToCharacteristicBlock)(CBPeripheral *peripheral,CBCharacteristic *characteristic, NSError *error,DEVICE_TYPE type);
 
+/** RSSI*/
+typedef void(^RSSIBlock)(NSNumber *RSSI);
+
 @interface LEONBLManager : NSObject
 
 //蓝牙外设
@@ -60,6 +63,7 @@ typedef void(^LEWriteToCharacteristicBlock)(CBPeripheral *peripheral,CBCharacter
 @property(nonatomic,copy)LEDiscoverCharacteristicsBlock  discoverCharacteristicsBlock;
 @property(nonatomic,copy)LEReadValueForCharacteristicBlock  readValueForCharacteristicBlock;
 @property(nonatomic,copy)LEWriteToCharacteristicBlock  writeToCharacteristicBlock;//
+@property(nonatomic,copy)RSSIBlock rssiBlock;//
 
 @property (strong, nonatomic)CBCentralManager * centralManager;/**< 蓝牙中心管理器 */
 

+ 16 - 0
RunGame/SDK/BLE/LEONBLManager.m

@@ -327,4 +327,20 @@ static LEONBLManager * instance;
 }
 
 
+/*!
+ *  @method peripheral:didReadRSSI:error:
+ *
+ *  @param peripheral    The peripheral providing this update.
+ *  @param RSSI            The current RSSI of the link.
+ *  @param error        If an error occurred, the cause of the failure.
+ *
+ *  @discussion            This method returns the result of a @link readRSSI: @/link call.
+ */
+- (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(nullable NSError *)error{
+    if (_rssiBlock){
+        _rssiBlock(RSSI);
+    }
+}
+
+
 @end

+ 5 - 2
RunGame/SDK/HTTP/HTTPDataProcession.h

@@ -12,12 +12,15 @@
 #define RequestSerializerType_URLEncoded @"application/x-www-form-urlencoded"
 #define RequestSerializerType_FormData @"form-data"
 
+#define CFBundleVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]
+#define OS @"2"
+
 //#define BASE_URL @"http://shoes-api.hiyd.com"//正式环境
 #define BASE_URL @"http://test-shoes-api.hiyd.com"//测试环境
 #define GAME_INVITE [NSString stringWithFormat:@"%@%@",BASE_URL,@"/game/invite"]
 #define GAME_RECORD [NSString stringWithFormat:@"%@%@",BASE_URL,@"/gameRecord/addGame"]
-#define GAME_FRIENDS [NSString stringWithFormat:@"%@%@",BASE_URL,@"/forum/friends?limit=1000"]
-#define GAME_RANK [NSString stringWithFormat:@"%@%@",BASE_URL,@"/rank/game?ver=1.1.1&os=1"]
+#define GAME_FRIENDS [NSString stringWithFormat:@"%@%@",BASE_URL,@"/forum/friends"]
+#define GAME_RANK [NSString stringWithFormat:@"%@%@",BASE_URL,@"/rank/game"]
 #define GAME_START [NSString stringWithFormat:@"%@%@",BASE_URL,@"/game/start"]
 #define GAME_END [NSString stringWithFormat:@"%@%@",BASE_URL,@"/game/end"]
 

+ 5 - 2
RunGame/SDK/HTTP/HTTPDataProcession.m

@@ -145,8 +145,10 @@
 +(void)getFriendsList:(UserFriendsDataBlock)userFriendsDataBlock{
 
     NSLog(@"gameFriends token ===>> %@ ",IOSSDK_TOKEN);
+    
+    NSString *urlString =  [NSString stringWithFormat:@"%@?limit=%@&v=%@&os=%@",GAME_FRIENDS,@"1000",CFBundleVersion,OS];
 
-    [HTTPDataProcession getHTTPDataProcession:GAME_FRIENDS token:IOSSDK_TOKEN  success:^(id data){
+    [HTTPDataProcession getHTTPDataProcession:urlString token:IOSSDK_TOKEN  success:^(id data){
             // 网络访问成功
 //            NSLog(@"data=%@",[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
             NSError * error;
@@ -212,7 +214,8 @@
 
 
 + (void)inviteFriends:(int)friendid info:(char*)info inviteDataBlock:(InviteDataBlock)inviteDataBlock{
-
+    
+   
     NSDictionary * jsonDict = [IOS_NSUSERDEFAULT objectForKey:IOSSDK_USERINFO];
 
     NSString * token = [jsonDict objectForKey:@"token"];

+ 156 - 156
RunGame/SDK/Tool/GameObjc.h

@@ -1,157 +1,157 @@
-
-#import <Foundation/Foundation.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface GameObjc : NSObject
-+ (instancetype)new NS_UNAVAILABLE;
-- (instancetype)init NS_UNAVAILABLE;
-- (instancetype)initWithGametype:(int)gametype NS_DESIGNATED_INITIALIZER;
-
-- (void)gameProcess:(int)timeStamp
-           rightPos:(int *)rightPos
-           rightAtt:(int *)rightAtt
-           rightAcc:(int *)rightAcc
-          rightZupt:(int)rightZupt
-        right_press:(int)right_press
-            leftPos:(int *)leftPos
-            leftAtt:(int *)leftAtt
-           leftAcc:(int *)leftAcc
-           leftZupt:(int)leftZupt
-         left_press:(int)left_press
-               jump:(int)jump
-               down:(int)down
-               rssi:(int)rssi
-         girl_shoes:(int)girl_shoes;
-
-- (void)runGameProcess:(int)timeStamp
-              rightPos:(int *)rightPos
-              rightAtt:(int *)rightAtt
-              rightAcc:(int *)rightAcc
-             rightZupt:(int)rightZupt
-           right_press:(int)right_press
-               leftPos:(int *)leftPos
-               leftAtt:(int *)leftAtt
-              leftAcc:(int *)leftAcc
-              leftZupt:(int)leftZupt
-            left_press:(int)left_press
-                  jump:(int)jump
-                  down:(int)down
-            girl_shoes:(int)girl_shoes;
-
-- (void)getGameResult:(int *)matrix;
-
-- (int)getStepFreq:(int)leftOrRight;
-- (int)getStepStatus:(int)leftOrRight;
-- (int)getStepCount:(int)leftOrRight;
-
-- (float)getGamePos:(int)left_or_right index:(int)index;
-
-- (void)start;
-- (void)end;
-- (void)isBingo;
--(int)getInteractionCMD;
--(NSString*)getGameDataStr;
--(void)GameProcessBuf:(uint8_t*)buff length:(int)length;
-
-/// 向外提供,手动释放,如需要,可调用
-- (void)handRelease;
-
-@end
-
-@interface RunGameObjc : NSObject
-- (int)getResultLeftRight:(int *)pos
-                   devNum:(short)devNum;
-- (int)getResultJump:(short)jump;
-- (int)getResultDown:(short)down;
-- (void)setResultConLeft:(short)zupt;
-- (void)setResultConRight:(short)zupt;
-- (int)getResultLeft:(int *)pos girl_shoes:(int)girl_shoes;
-- (int)getResultRight:(int *)pos girl_shoes:(int)girl_shoes;
-- (void)process:(int)timeStamp
-       rightPos:(int *)rightPos
-       rightAtt:(int *)rightAtt
-       rightAcc:(int *)rightAcc
-      rightZupt:(int)rightZupt
-    right_press:(int)right_press
-        leftPos:(int *)leftPos
-        leftAtt:(int *)leftAtt
-       leftAcc:(int *)leftAcc
-       leftZupt:(int)leftZupt
-     left_press:(int)left_press
-           jump:(int)jump
-           down:(int)down
-     girl_shoes:(int)girl_shoes;
-- (void)getResult:(int *)dec;
-/// 向外提供,手动释放
-- (void)handRelease;
-@end
-
-@interface DanceGameObjc : NSObject
-//- (int)gamePositionProcess:(int *)pos
-//                   stepPos:(int *)stepPos
-//                      rssi:(int)rssi
-//               hostOrSlave:(short)hostOrSlave;
-//- (void)gameBoundary:(int *)globalPos;
-//- (int)getDirectionFloat:(float *)pos rssi:(int)rssi;
-//- (short)danceGameProcess:(int *)pos
-//                     zupt:(short)zupt
-//                     rssi:(int)rssi
-//              hostOrSlave:(short)hostOrSlave;
-- (void)process:(int *)rightPos
-       rightAtt:(int *)rightAtt
-      rightZupt:(int)rightZupt
-    right_press:(int)right_press
-        leftPos:(int *)leftPos
-        leftAtt:(int *)leftAtt
-       leftZupt:(int)leftZupt
-     left_press:(int)left_press
-           jump:(int)jump
-           down:(int)down
-           rssi:(int)rssi;
-
-- (void)getResult:(int *)matrix;
-//- (float)getRssiDistance:(int)rssi;
-//- (int)savePosAndRssi:(int *)pos
-//                 zupt:(short)zupt
-//                 rssi:(int)rssi
-//          hostOrSlave:(short)hostOrSlave;
-/// 向外提供,手动释放,如需要,可调用
-- (void)handRelease;
-@end
-
-
-@interface FootStepObjc : NSObject
-//pos开辟3个空间
-- (void)stepCal:(int)timeStamp posList:(int *)pos zupt:(int)zupt girl_shoes:(int)girl_shoes;
-- (int)getStepFreq;
-- (int)getStepStatus;
-- (int)getStepCount;
-/// 向外提供,手动释放,如需要,可调用
-- (void)handRelease;
-@end
-
-
-@interface InertialTrajProcessObjc : NSObject
-- (void)trajRotate:(int *)pos;
-//rotateMatrix只能开辟4个空间
-- (void)trajRotate:(int *)pos
-      rotateMatrix:(float *)rotateMatrix;
-- (void)resetHeading:(short)heading;
-/// 向外提供,手动释放
-- (void)handRelease;
-@end
-
-//@interface OriginTrajObj : NSObject
-//- (void)process:(int*)right_pos
-//        right_att:(int*)right_att
-//        right_zupt:(int)right_zupt
-//        left_pos:(int*)left_pos
-//        left_att:(int*)left_att
-//        left_zupt:(int) left_zupt;
-//
-//- (float)getGamePos:(int)left_or_right
-//               index:(int)index;
+//
+//#import <Foundation/Foundation.h>
+//
+//NS_ASSUME_NONNULL_BEGIN
+//
+//@interface GameObjc : NSObject
+//+ (instancetype)new NS_UNAVAILABLE;
+//- (instancetype)init NS_UNAVAILABLE;
+//- (instancetype)initWithGametype:(int)gametype NS_DESIGNATED_INITIALIZER;
+//
+//- (void)gameProcess:(int)timeStamp
+//           rightPos:(int *)rightPos
+//           rightAtt:(int *)rightAtt
+//           rightAcc:(int *)rightAcc
+//          rightZupt:(int)rightZupt
+//        right_press:(int)right_press
+//            leftPos:(int *)leftPos
+//            leftAtt:(int *)leftAtt
+//           leftAcc:(int *)leftAcc
+//           leftZupt:(int)leftZupt
+//         left_press:(int)left_press
+//               jump:(int)jump
+//               down:(int)down
+//               rssi:(int)rssi
+//         girl_shoes:(int)girl_shoes;
+//
+//- (void)runGameProcess:(int)timeStamp
+//              rightPos:(int *)rightPos
+//              rightAtt:(int *)rightAtt
+//              rightAcc:(int *)rightAcc
+//             rightZupt:(int)rightZupt
+//           right_press:(int)right_press
+//               leftPos:(int *)leftPos
+//               leftAtt:(int *)leftAtt
+//              leftAcc:(int *)leftAcc
+//              leftZupt:(int)leftZupt
+//            left_press:(int)left_press
+//                  jump:(int)jump
+//                  down:(int)down
+//            girl_shoes:(int)girl_shoes;
+//
+//- (void)getGameResult:(int *)matrix;
+//
+//- (int)getStepFreq:(int)leftOrRight;
+//- (int)getStepStatus:(int)leftOrRight;
+//- (int)getStepCount:(int)leftOrRight;
+//
+//- (float)getGamePos:(int)left_or_right index:(int)index;
+//
+//- (void)start;
+//- (void)end;
+//- (void)isBingo;
+//-(int)getInteractionCMD;
+//-(NSString*)getGameDataStr;
+//-(void)GameProcessBuf:(uint8_t*)buff length:(int)length;
+//
+///// 向外提供,手动释放,如需要,可调用
+//- (void)handRelease;
+//
+//@end
+//
+//@interface RunGameObjc : NSObject
+//- (int)getResultLeftRight:(int *)pos
+//                   devNum:(short)devNum;
+//- (int)getResultJump:(short)jump;
+//- (int)getResultDown:(short)down;
+//- (void)setResultConLeft:(short)zupt;
+//- (void)setResultConRight:(short)zupt;
+//- (int)getResultLeft:(int *)pos girl_shoes:(int)girl_shoes;
+//- (int)getResultRight:(int *)pos girl_shoes:(int)girl_shoes;
+//- (void)process:(int)timeStamp
+//       rightPos:(int *)rightPos
+//       rightAtt:(int *)rightAtt
+//       rightAcc:(int *)rightAcc
+//      rightZupt:(int)rightZupt
+//    right_press:(int)right_press
+//        leftPos:(int *)leftPos
+//        leftAtt:(int *)leftAtt
+//       leftAcc:(int *)leftAcc
+//       leftZupt:(int)leftZupt
+//     left_press:(int)left_press
+//           jump:(int)jump
+//           down:(int)down
+//     girl_shoes:(int)girl_shoes;
+//- (void)getResult:(int *)dec;
+///// 向外提供,手动释放
+//- (void)handRelease;
+//@end
+//
+//@interface DanceGameObjc : NSObject
+////- (int)gamePositionProcess:(int *)pos
+////                   stepPos:(int *)stepPos
+////                      rssi:(int)rssi
+////               hostOrSlave:(short)hostOrSlave;
+////- (void)gameBoundary:(int *)globalPos;
+////- (int)getDirectionFloat:(float *)pos rssi:(int)rssi;
+////- (short)danceGameProcess:(int *)pos
+////                     zupt:(short)zupt
+////                     rssi:(int)rssi
+////              hostOrSlave:(short)hostOrSlave;
+//- (void)process:(int *)rightPos
+//       rightAtt:(int *)rightAtt
+//      rightZupt:(int)rightZupt
+//    right_press:(int)right_press
+//        leftPos:(int *)leftPos
+//        leftAtt:(int *)leftAtt
+//       leftZupt:(int)leftZupt
+//     left_press:(int)left_press
+//           jump:(int)jump
+//           down:(int)down
+//           rssi:(int)rssi;
+//
+//- (void)getResult:(int *)matrix;
+////- (float)getRssiDistance:(int)rssi;
+////- (int)savePosAndRssi:(int *)pos
+////                 zupt:(short)zupt
+////                 rssi:(int)rssi
+////          hostOrSlave:(short)hostOrSlave;
+///// 向外提供,手动释放,如需要,可调用
+//- (void)handRelease;
+//@end
+//
+//
+//@interface FootStepObjc : NSObject
+////pos开辟3个空间
+//- (void)stepCal:(int)timeStamp posList:(int *)pos zupt:(int)zupt girl_shoes:(int)girl_shoes;
+//- (int)getStepFreq;
+//- (int)getStepStatus;
+//- (int)getStepCount;
+///// 向外提供,手动释放,如需要,可调用
+//- (void)handRelease;
+//@end
+//
+//
+//@interface InertialTrajProcessObjc : NSObject
+//- (void)trajRotate:(int *)pos;
+////rotateMatrix只能开辟4个空间
+//- (void)trajRotate:(int *)pos
+//      rotateMatrix:(float *)rotateMatrix;
+//- (void)resetHeading:(short)heading;
+///// 向外提供,手动释放
+//- (void)handRelease;
 //@end
-
-NS_ASSUME_NONNULL_END
+//
+////@interface OriginTrajObj : NSObject
+////- (void)process:(int*)right_pos
+////        right_att:(int*)right_att
+////        right_zupt:(int)right_zupt
+////        left_pos:(int*)left_pos
+////        left_att:(int*)left_att
+////        left_zupt:(int) left_zupt;
+////
+////- (float)getGamePos:(int)left_or_right
+////               index:(int)index;
+////@end
+//
+//NS_ASSUME_NONNULL_END

+ 367 - 367
RunGame/SDK/Tool/GameObjc.mm

@@ -1,387 +1,387 @@
-
-#import "GameObjc.h"
-#include "Game.h"
-#include "DanceGame.h"
-#include "FootStep.h"
-#include "InertialTrajProcess.h"
-//#include "OriginTraj.h"
-//#include <math.h>
-
-#define NSLog(format, ...) printf("TIME:%s FILE:%s(%d行) FUNCTION:%s \n %s\n\n",__TIME__, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String])
-
-
-@interface GameObjc()
-{
-@private
-    Game *game;
-    int gametype;
-}
-@end
-
-@implementation GameObjc
-
-- (instancetype)initWithGametype:(int)gametype{
-    self = [super init];
-    if (self){
-        gametype = gametype;
-        game = new Game(gametype);
-    }
-    return self;
-}
-
-- (void)gameProcess:(int)timeStamp
-           rightPos:(int *)rightPos
-           rightAtt:(int *)rightAtt
-           rightAcc:(int *)rightAcc
-          rightZupt:(int)rightZupt
-        right_press:(int)right_press
-            leftPos:(int *)leftPos
-            leftAtt:(int *)leftAtt
-           leftAcc:(int *)leftAcc
-           leftZupt:(int)leftZupt
-         left_press:(int)left_press
-               jump:(int)jump
-               down:(int)down
-               rssi:(int)rssi
-         girl_shoes:(int)girl_shoes{
-    game->GameProcess(timeStamp, rightPos, rightAtt, rightAcc,rightZupt,right_press,leftPos, leftAtt, leftAcc,leftZupt, left_press,jump,down, rssi,girl_shoes);
-}
-
-- (void)runGameProcess:(int)timeStamp
-              rightPos:(int *)rightPos
-              rightAtt:(int *)rightAtt
-              rightAcc:(int *)rightAcc
-             rightZupt:(int)rightZupt
-           right_press:(int)right_press
-               leftPos:(int *)leftPos
-               leftAtt:(int *)leftAtt
-              leftAcc:(int *)leftAcc
-              leftZupt:(int)leftZupt
-            left_press:(int)left_press
-                  jump:(int)jump
-                  down:(int)down
-            girl_shoes:(int)girl_shoes{
-    game->RunGameProcess(rightPos, rightAtt, rightAcc,rightZupt,right_press,leftPos, leftAtt, leftAcc,leftZupt, left_press,jump,down,girl_shoes);
-    
-}
-
-- (void)getGameResult:(int *)matrix{
-    game->getGameResult(matrix);
-}
-
-- (int)getStepFreq:(int)leftOrRight{
-    return game->getStepFreq(leftOrRight);
-}
-- (int)getStepStatus:(int)leftOrRight{
-    return game->getStepStatus(leftOrRight);
-}
-- (int)getStepCount:(int)leftOrRight{
-    return game->getStepCount(leftOrRight);
-}
-
-- (float)getGamePos:(int)left_or_right index:(int)index{
-    return game->getGamePos(left_or_right, index);
-}
-
-- (void)start{
-    game->start(nil);
-}
-- (void)end{
-    game->end();
-}
-
-- (void)isBingo{
-    game->isBingo();
-}
-
--(int)getInteractionCMD{
-    return game->getInteractionCMD();
-}
-
--(NSString*)getGameDataStr{
-    
-//    NSString * string =  [NSString stringWithCString:game->getGameDataStr().c_str() encoding:[NSString defaultCStringEncoding]];
-    NSString * aString = [NSString stringWithUTF8String:game->getGameDataStr().c_str()];
-//    NSLog(@"剑波需要的数据1 %@",string);
-//    NSLog(@"剑波需要的数据2 %@",aString);
-    return aString;
-    
-}
-
--(void)GameProcessBuf:(uint8_t*)buff length:(int)length{
-    
-    game->GameProcessBuf(buff, length);
-    
-}
-
-/// 向外提供,手动释放
-- (void)handRelease{
-    delete game;
-}
-- (void)dealloc{
-    delete game;
-}
-
-@end
-
-@interface RunGameObjc ()
-{
-    @private
-    RunGame * runGame;
-}
-@end
-
-@implementation RunGameObjc
-- (instancetype)init{
-    self = [super init];
-    if (self) {
-        runGame = new RunGame();
-    }
-    return self;
-}
-- (int)getResultLeftRight:(int *)pos
-                   devNum:(short)devNum{
-    return runGame->getResultLeftRight(pos, devNum);
-}
-- (int)getResultJump:(short)jump{
-    return runGame->getResultJump(jump);
-}
-- (int)getResultDown:(short)down{
-    return runGame->getResultDown(down);
-}
-- (void)setResultConLeft:(short)zupt{
-    runGame->setResultConLeft(zupt);
-}
-- (void)setResultConRight:(short)zupt{
-     runGame->setResultConRight(zupt);
-}
-- (int)getResultLeft:(int *)pos girl_shoes:(int)girl_shoes{
-    return runGame->getResultLeft(pos,girl_shoes);
-}
-- (int)getResultRight:(int *)pos girl_shoes:(int)girl_shoes{
-    return runGame->getResultRight(pos,girl_shoes);
-}
-
-- (void)process:(int)timeStamp
-       rightPos:(int *)rightPos
-       rightAtt:(int *)rightAtt
-       rightAcc:(int *)rightAcc
-      rightZupt:(int)rightZupt
-    right_press:(int)right_press
-        leftPos:(int *)leftPos
-        leftAtt:(int *)leftAtt
-       leftAcc:(int *)leftAcc
-       leftZupt:(int)leftZupt
-     left_press:(int)left_press
-           jump:(int)jump
-           down:(int)down
-     girl_shoes:(int)girl_shoes{
-    
-    runGame->Process(rightPos, rightAtt, rightAcc,rightZupt,right_press,leftPos, leftAtt, leftAcc,leftZupt, left_press,jump,down,girl_shoes);
-    
-//    Process(int* right_pos, int* right_att, int* right_acc, int right_zupt, int right_press,
-//                 int* left_pos, int* left_att, int* left_acc, int left_zupt, int left_press,
-//                 int jump, int down, int girl_shoes)
-    
-}
-
-- (void)getResult:(int *)dec{
-    runGame->getResult(dec);
-}
-
-/// 向外提供,手动释放
-- (void)handRelease{
-    delete runGame;
-}
-- (void)dealloc{
-    delete runGame;
-}
-@end
-
-@interface DanceGameObjc()
-{
-@private
-    DanceGame *danceGame;
-}
-@end
-
-@implementation DanceGameObjc
-- (instancetype)init{
-    self = [super init];
-    if (self) {
-        danceGame = new DanceGame();
-    }
-    return self;
-}
-
-//- (int)gamePositionProcess:(int *)pos
-//                   stepPos:(int *)stepPos
-//                      rssi:(int)rssi
-//               hostOrSlave:(short)hostOrSlave{
-//    //SInt16 ==> short*
-//    return  danceGame->game_position_process(pos, stepPos, rssi, hostOrSlave);
-//}
-
-//- (void)gameBoundary:(int *)globalPos{
-//    danceGame->game_boundary(globalPos);
-//}
-//- (int)getDirectionFloat:(float *)pos
-//                    rssi:(int)rssi{
-//    //float==>32位
-//    return  danceGame->getDirectionFloat(pos,rssi);
-//}
-//- (short)danceGameProcess:(int *)pos
-//                     zupt:(short)zupt
-//                     rssi:(int)rssi
-//              hostOrSlave:(short)hostOrSlave{
-//    return danceGame->dance_game_process(pos, zupt, rssi, hostOrSlave);
-//}
-
-- (void)process:(int *)rightPos
-       rightAtt:(int *)rightAtt
-       rightAcc:(int *)rightAcc
-      rightZupt:(int)rightZupt
-    right_press:(int)right_press
-        leftPos:(int *)leftPos
-        leftAtt:(int *)leftAtt
-       leftAcc:(int *)leftAcc
-       leftZupt:(int)leftZupt
-     left_press:(int)left_press
-           jump:(int)jump
-           down:(int)down
-           rssi:(int)rssi{
-    danceGame->Process(rightPos, rightAtt,rightAcc, rightZupt, right_press,leftPos, leftAtt,leftAtt, leftZupt, left_press,jump, down, rssi);
-}
-
-- (void)getResult:(int *)matrix{
-    danceGame->getResult(matrix);
-}
-//- (float)getRssiDistance:(int)rssi{
-//    return danceGame->getRssiDistance(rssi);
-//}
-//- (int)savePosAndRssi:(int *)pos
-//                 zupt:(short)zupt
-//                 rssi:(int)rssi
-//          hostOrSlave:(short)hostOrSlave{
-//    return danceGame->savePosAndRssi(pos, zupt, rssi, hostOrSlave);
-//}
-/// 向外提供,手动释放
-- (void)handRelease{
-    delete danceGame;
-}
-- (void)dealloc{
-    delete danceGame;
-}
-@end
-
-@interface FootStepObjc ()
-{
-@private
-    FootStep *footStep;
-}
-@end
-
-@implementation FootStepObjc
-
-- (instancetype)init{
-    self = [super init];
-    if (self) {
-        footStep = new FootStep();
-    }
-    return self;
-}
-//pos开辟3个空间
-- (void)stepCal:(int)timeStamp posList:(int *)pos zupt:(int)zupt girl_shoes:(int)girl_shoes{
-    footStep->stepCal(timeStamp, pos, zupt,girl_shoes);
-}
-- (int)getStepFreq{
-    return footStep->getStepFreq();
-}
-- (int)getStepStatus{
-    return footStep->getStepStatus();
-}
-- (int)getStepCount{
-    return footStep->getStepCount();
-}
-- (void)dealloc{
-    delete footStep;
-}
-/// 向外提供,手动释放
-- (void)handRelease{
-    delete footStep;
-}
-
-@end
-
-@interface InertialTrajProcessObjc ()
-{
-    @private
-    InertialTrajProcess * inertialTrajProcess;
-}
-@end
-@implementation InertialTrajProcessObjc
-- (instancetype)init{
-    self = [super init];
-    if (self) {
-        inertialTrajProcess = new InertialTrajProcess();
-    }
-    return self;
-}
-- (void)trajRotate:(int *)pos{
-    inertialTrajProcess->TrajRotate(pos);
-}
-//rotateMatrix只能开辟4个空间
-- (void)trajRotate:(int *)pos
-      rotateMatrix:(float *)rotateMatrix{
-    inertialTrajProcess->TrajRotate(pos,rotateMatrix);
-}
-- (void)resetHeading:(short)heading{
-    inertialTrajProcess->ResetHeading(heading);
-}
-/// 向外提供,手动释放
-- (void)handRelease{
-    delete inertialTrajProcess;
-}
-- (void)dealloc{
-    delete inertialTrajProcess;
-}
-@end
-
-
-//@interface OriginTrajObj ()
+//
+//#import "GameObjc.h"
+//#include "Game.h"
+//#include "DanceGame.h"
+//#include "FootStep.h"
+//#include "InertialTrajProcess.h"
+////#include "OriginTraj.h"
+////#include <math.h>
+//
+//#define NSLog(format, ...) printf("TIME:%s FILE:%s(%d行) FUNCTION:%s \n %s\n\n",__TIME__, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String])
+//
+//
+//@interface GameObjc()
+//{
+//@private
+//    Game *game;
+//    int gametype;
+//}
+//@end
+//
+//@implementation GameObjc
+//
+//- (instancetype)initWithGametype:(int)gametype{
+//    self = [super init];
+//    if (self){
+//        gametype = gametype;
+//        game = new Game(gametype);
+//    }
+//    return self;
+//}
+//
+//- (void)gameProcess:(int)timeStamp
+//           rightPos:(int *)rightPos
+//           rightAtt:(int *)rightAtt
+//           rightAcc:(int *)rightAcc
+//          rightZupt:(int)rightZupt
+//        right_press:(int)right_press
+//            leftPos:(int *)leftPos
+//            leftAtt:(int *)leftAtt
+//           leftAcc:(int *)leftAcc
+//           leftZupt:(int)leftZupt
+//         left_press:(int)left_press
+//               jump:(int)jump
+//               down:(int)down
+//               rssi:(int)rssi
+//         girl_shoes:(int)girl_shoes{
+//    game->GameProcess(timeStamp, rightPos, rightAtt, rightAcc,rightZupt,right_press,leftPos, leftAtt, leftAcc,leftZupt, left_press,jump,down, rssi,girl_shoes);
+//}
+//
+//- (void)runGameProcess:(int)timeStamp
+//              rightPos:(int *)rightPos
+//              rightAtt:(int *)rightAtt
+//              rightAcc:(int *)rightAcc
+//             rightZupt:(int)rightZupt
+//           right_press:(int)right_press
+//               leftPos:(int *)leftPos
+//               leftAtt:(int *)leftAtt
+//              leftAcc:(int *)leftAcc
+//              leftZupt:(int)leftZupt
+//            left_press:(int)left_press
+//                  jump:(int)jump
+//                  down:(int)down
+//            girl_shoes:(int)girl_shoes{
+//    game->RunGameProcess(rightPos, rightAtt, rightAcc,rightZupt,right_press,leftPos, leftAtt, leftAcc,leftZupt, left_press,jump,down,girl_shoes);
+//
+//}
+//
+//- (void)getGameResult:(int *)matrix{
+//    game->getGameResult(matrix);
+//}
+//
+//- (int)getStepFreq:(int)leftOrRight{
+//    return game->getStepFreq(leftOrRight);
+//}
+//- (int)getStepStatus:(int)leftOrRight{
+//    return game->getStepStatus(leftOrRight);
+//}
+//- (int)getStepCount:(int)leftOrRight{
+//    return game->getStepCount(leftOrRight);
+//}
+//
+//- (float)getGamePos:(int)left_or_right index:(int)index{
+//    return game->getGamePos(left_or_right, index);
+//}
+//
+//- (void)start{
+//    game->start(nil);
+//}
+//- (void)end{
+//    game->end();
+//}
+//
+//- (void)isBingo{
+//    game->isBingo();
+//}
+//
+//-(int)getInteractionCMD{
+//    return game->getInteractionCMD();
+//}
+//
+//-(NSString*)getGameDataStr{
+//
+////    NSString * string =  [NSString stringWithCString:game->getGameDataStr().c_str() encoding:[NSString defaultCStringEncoding]];
+//    NSString * aString = [NSString stringWithUTF8String:game->getGameDataStr().c_str()];
+////    NSLog(@"剑波需要的数据1 %@",string);
+////    NSLog(@"剑波需要的数据2 %@",aString);
+//    return aString;
+//
+//}
+//
+//-(void)GameProcessBuf:(uint8_t*)buff length:(int)length{
+//
+//    game->GameProcessBuf(buff, length);
+//
+//}
+//
+///// 向外提供,手动释放
+//- (void)handRelease{
+//    delete game;
+//}
+//- (void)dealloc{
+//    delete game;
+//}
+//
+//@end
+//
+//@interface RunGameObjc ()
 //{
 //    @private
-//    OriginTraj * originTraj;
+//    RunGame * runGame;
 //}
 //@end
-//@implementation OriginTrajObj
+//
+//@implementation RunGameObjc
 //- (instancetype)init{
 //    self = [super init];
-//    if (self){
-//        originTraj = new OriginTraj();
+//    if (self) {
+//        runGame = new RunGame();
+//    }
+//    return self;
+//}
+//- (int)getResultLeftRight:(int *)pos
+//                   devNum:(short)devNum{
+//    return runGame->getResultLeftRight(pos, devNum);
+//}
+//- (int)getResultJump:(short)jump{
+//    return runGame->getResultJump(jump);
+//}
+//- (int)getResultDown:(short)down{
+//    return runGame->getResultDown(down);
+//}
+//- (void)setResultConLeft:(short)zupt{
+//    runGame->setResultConLeft(zupt);
+//}
+//- (void)setResultConRight:(short)zupt{
+//     runGame->setResultConRight(zupt);
+//}
+//- (int)getResultLeft:(int *)pos girl_shoes:(int)girl_shoes{
+//    return runGame->getResultLeft(pos,girl_shoes);
+//}
+//- (int)getResultRight:(int *)pos girl_shoes:(int)girl_shoes{
+//    return runGame->getResultRight(pos,girl_shoes);
+//}
+//
+//- (void)process:(int)timeStamp
+//       rightPos:(int *)rightPos
+//       rightAtt:(int *)rightAtt
+//       rightAcc:(int *)rightAcc
+//      rightZupt:(int)rightZupt
+//    right_press:(int)right_press
+//        leftPos:(int *)leftPos
+//        leftAtt:(int *)leftAtt
+//       leftAcc:(int *)leftAcc
+//       leftZupt:(int)leftZupt
+//     left_press:(int)left_press
+//           jump:(int)jump
+//           down:(int)down
+//     girl_shoes:(int)girl_shoes{
+//
+//    runGame->Process(rightPos, rightAtt, rightAcc,rightZupt,right_press,leftPos, leftAtt, leftAcc,leftZupt, left_press,jump,down,girl_shoes);
+//
+////    Process(int* right_pos, int* right_att, int* right_acc, int right_zupt, int right_press,
+////                 int* left_pos, int* left_att, int* left_acc, int left_zupt, int left_press,
+////                 int jump, int down, int girl_shoes)
+//
+//}
+//
+//- (void)getResult:(int *)dec{
+//    runGame->getResult(dec);
+//}
+//
+///// 向外提供,手动释放
+//- (void)handRelease{
+//    delete runGame;
+//}
+//- (void)dealloc{
+//    delete runGame;
+//}
+//@end
+//
+//@interface DanceGameObjc()
+//{
+//@private
+//    DanceGame *danceGame;
+//}
+//@end
+//
+//@implementation DanceGameObjc
+//- (instancetype)init{
+//    self = [super init];
+//    if (self) {
+//        danceGame = new DanceGame();
 //    }
 //    return self;
 //}
 //
-//- (void)process:(int*)right_pos
-//        right_att:(int*)right_att
-//        right_zupt:(int)right_zupt
-//        left_pos:(int*)left_pos
-//        left_att:(int*)left_att
-//      left_zupt:(int) left_zupt{
-//    originTraj->Process(right_pos, right_att, right_zupt, left_pos, left_att, left_zupt);
+////- (int)gamePositionProcess:(int *)pos
+////                   stepPos:(int *)stepPos
+////                      rssi:(int)rssi
+////               hostOrSlave:(short)hostOrSlave{
+////    //SInt16 ==> short*
+////    return  danceGame->game_position_process(pos, stepPos, rssi, hostOrSlave);
+////}
+//
+////- (void)gameBoundary:(int *)globalPos{
+////    danceGame->game_boundary(globalPos);
+////}
+////- (int)getDirectionFloat:(float *)pos
+////                    rssi:(int)rssi{
+////    //float==>32位
+////    return  danceGame->getDirectionFloat(pos,rssi);
+////}
+////- (short)danceGameProcess:(int *)pos
+////                     zupt:(short)zupt
+////                     rssi:(int)rssi
+////              hostOrSlave:(short)hostOrSlave{
+////    return danceGame->dance_game_process(pos, zupt, rssi, hostOrSlave);
+////}
+//
+//- (void)process:(int *)rightPos
+//       rightAtt:(int *)rightAtt
+//       rightAcc:(int *)rightAcc
+//      rightZupt:(int)rightZupt
+//    right_press:(int)right_press
+//        leftPos:(int *)leftPos
+//        leftAtt:(int *)leftAtt
+//       leftAcc:(int *)leftAcc
+//       leftZupt:(int)leftZupt
+//     left_press:(int)left_press
+//           jump:(int)jump
+//           down:(int)down
+//           rssi:(int)rssi{
+//    danceGame->Process(rightPos, rightAtt,rightAcc, rightZupt, right_press,leftPos, leftAtt,leftAtt, leftZupt, left_press,jump, down, rssi);
+//}
+//
+//- (void)getResult:(int *)matrix{
+//    danceGame->getResult(matrix);
+//}
+////- (float)getRssiDistance:(int)rssi{
+////    return danceGame->getRssiDistance(rssi);
+////}
+////- (int)savePosAndRssi:(int *)pos
+////                 zupt:(short)zupt
+////                 rssi:(int)rssi
+////          hostOrSlave:(short)hostOrSlave{
+////    return danceGame->savePosAndRssi(pos, zupt, rssi, hostOrSlave);
+////}
+///// 向外提供,手动释放
+//- (void)handRelease{
+//    delete danceGame;
+//}
+//- (void)dealloc{
+//    delete danceGame;
+//}
+//@end
+//
+//@interface FootStepObjc ()
+//{
+//@private
+//    FootStep *footStep;
 //}
+//@end
 //
-//- (float)getGamePos:(int)left_or_right
-//              index:(int)index{
-//    return originTraj->getGamePos(left_or_right, index);
+//@implementation FootStepObjc
+//
+//- (instancetype)init{
+//    self = [super init];
+//    if (self) {
+//        footStep = new FootStep();
+//    }
+//    return self;
+//}
+////pos开辟3个空间
+////- (void)stepCal:(int)timeStamp posList:(int *)pos zupt:(int)zupt girl_shoes:(int)girl_shoes{
+//    footStep->stepCal(timeStamp, pos, zupt,girl_shoes);
+//}
+//- (int)getStepFreq{
+//    return footStep->getStepFreq();
+//}
+//- (int)getStepStatus{
+//    return footStep->getStepStatus();
+//}
+//- (int)getStepCount{
+//    return footStep->getStepCount();
+//}
+//- (void)dealloc{
+//    delete footStep;
+//}
+///// 向外提供,手动释放
+//- (void)handRelease{
+//    delete footStep;
 //}
 //
+//@end
+//
+//@interface InertialTrajProcessObjc ()
+//{
+//    @private
+//    InertialTrajProcess * inertialTrajProcess;
+//}
+//@end
+//@implementation InertialTrajProcessObjc
+//- (instancetype)init{
+//    self = [super init];
+//    if (self) {
+//        inertialTrajProcess = new InertialTrajProcess();
+//    }
+//    return self;
+//}
+//- (void)trajRotate:(int *)pos{
+//    inertialTrajProcess->TrajRotate(pos);
+//}
+////rotateMatrix只能开辟4个空间
+//- (void)trajRotate:(int *)pos
+//      rotateMatrix:(float *)rotateMatrix{
+//    inertialTrajProcess->TrajRotate(pos,rotateMatrix);
+//}
+//- (void)resetHeading:(short)heading{
+//    inertialTrajProcess->ResetHeading(heading);
+//}
 ///// 向外提供,手动释放
 //- (void)handRelease{
-//    delete originTraj;
+//    delete inertialTrajProcess;
 //}
 //- (void)dealloc{
-//    delete originTraj;
+//    delete inertialTrajProcess;
 //}
 //@end
+//
+//
+////@interface OriginTrajObj ()
+////{
+////    @private
+////    OriginTraj * originTraj;
+////}
+////@end
+////@implementation OriginTrajObj
+////- (instancetype)init{
+////    self = [super init];
+////    if (self){
+////        originTraj = new OriginTraj();
+////    }
+////    return self;
+////}
+////
+////- (void)process:(int*)right_pos
+////        right_att:(int*)right_att
+////        right_zupt:(int)right_zupt
+////        left_pos:(int*)left_pos
+////        left_att:(int*)left_att
+////      left_zupt:(int) left_zupt{
+////    originTraj->Process(right_pos, right_att, right_zupt, left_pos, left_att, left_zupt);
+////}
+////
+////- (float)getGamePos:(int)left_or_right
+////              index:(int)index{
+////    return originTraj->getGamePos(left_or_right, index);
+////}
+////
+/////// 向外提供,手动释放
+////- (void)handRelease{
+////    delete originTraj;
+////}
+////- (void)dealloc{
+////    delete originTraj;
+////}
+////@end

+ 4 - 2
RunGame/SDK/shoes_sdk/FootStep.cpp

@@ -76,13 +76,15 @@ void FootStep::stepCal(int timeStamp, int pos[3], int zupt, int girl_shoes)
 		//所以计算步频的话一分钟除以walkTime 再除以一个2
 
 		stepFreq = 60 * 1000 / walkTime;
+        
+        std::cout << "stepFreq: " << stepFreq <<  std::endl;
+
 
 		if (girl_shoes)
 		{
 			stepFreq *= 2;
 		}
 		
-
 		leaveFloorTime1 = localTime;
 		
 		stepTag = 0;
@@ -126,4 +128,4 @@ int FootStep::getStepStatus()
 int FootStep::getStepCount()
 {
 	return stepCount;
-}
+}

+ 1 - 5
RunGame/SDK/shoes_sdk/Game.cpp

@@ -68,21 +68,18 @@ int Game::getInteractionCMD()
 
 void Game::GameProcess(int timeStamp, int* right_pos, int* right_att, int *right_acc, int right_zupt, int right_press,
 	int* left_pos, int* left_att, int* left_acc, int left_zupt, int left_press, 
-	int jump, int down, int rssi, int girl_shoes)
-{
+	int jump, int down, int rssi, int girl_shoes){
 
 	leftFootStep.stepCal(timeStamp, left_pos, left_zupt, girl_shoes);
 
 	rightFootStep.stepCal(timeStamp, right_pos, right_zupt, girl_shoes);
 	
-	
 	interaction.Process(gameTime, right_pos, right_att, right_acc, right_zupt, right_press,
 		left_pos, left_att, left_acc, left_zupt, left_press,
 		jump, down, rssi);
 
 	InteractionCMD = interaction.get_motion_state();
 	
-	
 	if (GameType == RUNGAME)
 	{
 		//ÅÜ¿áÓÎÏ·´¦Àíº¯Êý
@@ -98,7 +95,6 @@ void Game::GameProcess(int timeStamp, int* right_pos, int* right_att, int *right
 			rotateTrajRight.ResetHeading(right_att[0]);
 		}
 		rotateTrajRight.TrajRotate(right_pos);
-		
 
 		rungame.Process(right_pos, right_att, right_acc, right_zupt, right_press,
 			left_pos, left_att, left_acc, left_zupt, left_press, jump, down, girl_shoes);

+ 3 - 1
RunGame/SDK/shoes_sdk/InertialTrajProcess.cpp

@@ -20,11 +20,12 @@ void InertialTrajProcess::TrajRotate(int *pos, float rotateMatrix[4])
 	posTemp[0] = rotateMatrix[0] * float(pos_f[0]) + rotateMatrix[1] * float(pos_f[1]);
 	posTemp[1] = rotateMatrix[2] * float(pos_f[0]) + rotateMatrix[3] * float(pos_f[1]);
 
-
 	pos[0] = (int)(posTemp[0] * 100.0f);
 	pos[1] = (int)(posTemp[1] * 100.0f);
 	pos[2] = (int)(posTemp[2] * 100.0f);
+    
 }
+
 void InertialTrajProcess::TrajRotate(int* pos)
 {
 	/*
@@ -49,6 +50,7 @@ void InertialTrajProcess::TrajRotate(int* pos)
 	pos[2] = (int)(posTemp[2] * 100.0f);
 
 	//std::cout << "DanceGame:Rotate : " << pos[0] << " " << pos[1] << " " << pos[2] << std::endl;
+    
 }
 
 void InertialTrajProcess::ResetHeading(int heading)

+ 1 - 3
RunGame/SDK/shoes_sdk/RunGame.cpp

@@ -35,12 +35,10 @@ void RunGame::Process(int* right_pos, int* right_att, int* right_acc, int right_
 	
 	if (left_zupt == 0)
 	{
-		std::cout << "rungame leftpos: " << left_pos_tmp[0] << " " << left_pos_tmp[1] << " " << left_pos_tmp[2] << std::endl;
+//		std::cout << "rungame leftpos: " << left_pos_tmp[0] << " " << left_pos_tmp[1] << " " << left_pos_tmp[2] << std::endl;
 	}
 	
 
-
-
 	left_acc_status =  getAccStatus(left_zupt, left_acc, left_acc_max, left_acc_min);
 
 	right_acc_status = getAccStatus(right_zupt, right_acc, right_acc_max, right_acc_min);

+ 31 - 27
RunGame/Unity-iPhone.xcodeproj/project.pbxproj

@@ -606,7 +606,7 @@
 		1B9D41B684740F98285DF269 /* mscorlib3.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mscorlib3.cpp; path = Classes/Native/mscorlib3.cpp; sourceTree = SOURCE_ROOT; };
 		1D18474D8980391ED763B574 /* Generics4.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Generics4.cpp; path = Classes/Native/Generics4.cpp; sourceTree = SOURCE_ROOT; };
 		1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
-		1D6058910D05DD3D006BFB54 /* Unity-Target-New.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = "Unity-Target-New.app"; path = petsurfer.app; sourceTree = BUILT_PRODUCTS_DIR; };
+		1D6058910D05DD3D006BFB54 /* petsurfer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = petsurfer.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		1E984680975D87668BD02022 /* UnityEngine.Physics2DModule.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = UnityEngine.Physics2DModule.cpp; path = Classes/Native/UnityEngine.Physics2DModule.cpp; sourceTree = SOURCE_ROOT; };
 		1F5F4BBD866AA26C808ADCA6 /* QFramework.Core_CodeGen.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = QFramework.Core_CodeGen.c; path = Classes/Native/QFramework.Core_CodeGen.c; sourceTree = SOURCE_ROOT; };
 		222B4F2ABDEF9E78E8C62172 /* UnityEngine.UI3.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = UnityEngine.UI3.cpp; path = Classes/Native/UnityEngine.UI3.cpp; sourceTree = SOURCE_ROOT; };
@@ -1125,7 +1125,7 @@
 		19C28FACFE9D520D11CA2CBB /* Products */ = {
 			isa = PBXGroup;
 			children = (
-				1D6058910D05DD3D006BFB54 /* Unity-Target-New.app */,
+				1D6058910D05DD3D006BFB54 /* petsurfer.app */,
 				5623C57317FDCB0800090B9E /* Unity-iPhone Tests.xctest */,
 				9D25AB9D213FB47800354C27 /* UnityFramework.framework */,
 			);
@@ -1593,12 +1593,12 @@
 		93FA55062750E1EE00AEAD33 /* BLE */ = {
 			isa = PBXGroup;
 			children = (
-				93FA55072750E1EE00AEAD33 /* CBPeripheral+ADName.m */,
-				93FA55082750E1EE00AEAD33 /* LEONBLManager.h */,
 				93FA55092750E1EE00AEAD33 /* BTDataProcess.h */,
 				93FA550A2750E1EE00AEAD33 /* BTDataProcess.mm */,
-				93FA550B2750E1EE00AEAD33 /* LEONBLManager.m */,
 				93FA550C2750E1EE00AEAD33 /* CBPeripheral+ADName.h */,
+				93FA55072750E1EE00AEAD33 /* CBPeripheral+ADName.m */,
+				93FA55082750E1EE00AEAD33 /* LEONBLManager.h */,
+				93FA550B2750E1EE00AEAD33 /* LEONBLManager.m */,
 			);
 			path = BLE;
 			sourceTree = "<group>";
@@ -1663,34 +1663,34 @@
 		93FA55282750E1EE00AEAD33 /* shoes_sdk */ = {
 			isa = PBXGroup;
 			children = (
-				93FA55292750E1EE00AEAD33 /* MonsterH5.h */,
 				93FA552A2750E1EE00AEAD33 /* DanceFoot.cpp */,
-				93FA552B2750E1EE00AEAD33 /* RunGame.h */,
-				93FA552C2750E1EE00AEAD33 /* FootStep.cpp */,
-				93FA552D2750E1EE00AEAD33 /* Tricycle.h */,
-				93FA552E2750E1EE00AEAD33 /* RuinsExplore.h */,
-				93FA552F2750E1EE00AEAD33 /* DanceGame.h */,
-				93FA55302750E1EE00AEAD33 /* OriginTraj.h */,
-				93FA55312750E1EE00AEAD33 /* MonsterH5.cpp */,
-				93FA55322750E1EE00AEAD33 /* Interaction.cpp */,
-				93FA55332750E1EE00AEAD33 /* SingleFootAction.h */,
-				93FA55342750E1EE00AEAD33 /* Interaction.h */,
-				93FA55352750E1EE00AEAD33 /* pub.h */,
 				93FA55362750E1EE00AEAD33 /* DanceFoot.h */,
-				93FA55372750E1EE00AEAD33 /* Tricycle.cpp */,
+				93FA553D2750E1EE00AEAD33 /* DanceGame.cpp */,
+				93FA552F2750E1EE00AEAD33 /* DanceGame.h */,
+				93FA552C2750E1EE00AEAD33 /* FootStep.cpp */,
 				93FA55382750E1EE00AEAD33 /* FootStep.h */,
-				93FA55392750E1EE00AEAD33 /* SingleFootAction.cpp */,
-				93FA553A2750E1EE00AEAD33 /* RuinsExplore.cpp */,
-				93FA553B2750E1EE00AEAD33 /* InertialTrajProcess.h */,
+				93FA55442750E1EE00AEAD33 /* Game.cpp */,
 				93FA553C2750E1EE00AEAD33 /* Game.h */,
-				93FA553D2750E1EE00AEAD33 /* DanceGame.cpp */,
+				93FA55422750E1EE00AEAD33 /* InertialTrajProcess.cpp */,
+				93FA553B2750E1EE00AEAD33 /* InertialTrajProcess.h */,
+				93FA55322750E1EE00AEAD33 /* Interaction.cpp */,
+				93FA55342750E1EE00AEAD33 /* Interaction.h */,
 				93FA553E2750E1EE00AEAD33 /* jumpH5.cpp */,
-				93FA553F2750E1EE00AEAD33 /* ReadMe.txt */,
+				93FA55432750E1EE00AEAD33 /* jumpH5.h */,
+				93FA55312750E1EE00AEAD33 /* MonsterH5.cpp */,
+				93FA55292750E1EE00AEAD33 /* MonsterH5.h */,
 				93FA55402750E1EE00AEAD33 /* OriginTraj.cpp */,
+				93FA55302750E1EE00AEAD33 /* OriginTraj.h */,
+				93FA55352750E1EE00AEAD33 /* pub.h */,
+				93FA553F2750E1EE00AEAD33 /* ReadMe.txt */,
+				93FA553A2750E1EE00AEAD33 /* RuinsExplore.cpp */,
+				93FA552E2750E1EE00AEAD33 /* RuinsExplore.h */,
 				93FA55412750E1EE00AEAD33 /* RunGame.cpp */,
-				93FA55422750E1EE00AEAD33 /* InertialTrajProcess.cpp */,
-				93FA55432750E1EE00AEAD33 /* jumpH5.h */,
-				93FA55442750E1EE00AEAD33 /* Game.cpp */,
+				93FA552B2750E1EE00AEAD33 /* RunGame.h */,
+				93FA55392750E1EE00AEAD33 /* SingleFootAction.cpp */,
+				93FA55332750E1EE00AEAD33 /* SingleFootAction.h */,
+				93FA55372750E1EE00AEAD33 /* Tricycle.cpp */,
+				93FA552D2750E1EE00AEAD33 /* Tricycle.h */,
 			);
 			path = shoes_sdk;
 			sourceTree = "<group>";
@@ -1924,7 +1924,7 @@
 			);
 			name = "Unity-iPhone";
 			productName = "iPhone-target";
-			productReference = 1D6058910D05DD3D006BFB54 /* Unity-Target-New.app */;
+			productReference = 1D6058910D05DD3D006BFB54 /* petsurfer.app */;
 			productType = "com.apple.product-type.application";
 		};
 		5623C57217FDCB0800090B9E /* Unity-iPhone Tests */ = {
@@ -2569,6 +2569,7 @@
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
 				COPY_PHASE_STRIP = NO;
+				CURRENT_PROJECT_VERSION = 1.0.1;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				GCC_DYNAMIC_NO_PIC = NO;
 				GCC_ENABLE_CPP_EXCEPTIONS = NO;
@@ -2619,6 +2620,7 @@
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
 				COPY_PHASE_STRIP = YES;
+				CURRENT_PROJECT_VERSION = 1.0.1;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				GCC_ENABLE_CPP_EXCEPTIONS = NO;
 				INFOPLIST_FILE = Info.plist;
@@ -2790,6 +2792,7 @@
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
 				COPY_PHASE_STRIP = YES;
+				CURRENT_PROJECT_VERSION = 1.0.1;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				GCC_ENABLE_CPP_EXCEPTIONS = NO;
@@ -2907,6 +2910,7 @@
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
 				COPY_PHASE_STRIP = YES;
+				CURRENT_PROJECT_VERSION = 1.0.1;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				GCC_ENABLE_CPP_EXCEPTIONS = NO;
 				INFOPLIST_FILE = Info.plist;

+ 7 - 0
RunGame/Unity-iPhone.xcodeproj/project.xcworkspace/contents.xcworkspacedata

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+   version = "1.0">
+   <FileRef
+      location = "self:">
+   </FileRef>
+</Workspace>

BIN
RunGame/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate