Ver Fonte

接入剑波sdk蹲跳次数

leon há 3 anos atrás
pai
commit
421736a5a5
31 ficheiros alterados com 1294 adições e 275 exclusões
  1. BIN
      .DS_Store
  2. 23 22
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/BTDataProcess.h
  3. 119 112
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/BTDataProcess.mm
  4. 123 0
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/BigFoot.cpp
  5. 39 0
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/BigFoot.h
  6. 98 0
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/Game.cpp
  7. 19 0
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/Game.h
  8. 0 1
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/InertialTrajProcess.cpp
  9. 3 2
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/pub.h
  10. 6 0
      DanceGame/Unity-iPhone.xcodeproj/project.pbxproj
  11. BIN
      DanceGame/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate
  12. 0 1
      RunGame/Classes/UnityAppController.mm
  13. 3 4
      RunGame/SDK/BLE/BTDataProcess.h
  14. 120 112
      RunGame/SDK/BLE/BTDataProcess.mm
  15. 42 0
      RunGame/SDK/BLE/MainShoesAnalysis.h
  16. 334 0
      RunGame/SDK/BLE/MainShoesAnalysis.mm
  17. 16 0
      RunGame/SDK/BLE/ViceShoesAnalysis.h
  18. 12 0
      RunGame/SDK/BLE/ViceShoesAnalysis.m
  19. 13 6
      RunGame/SDK/HTTP/HTTPDataProcession.h
  20. 4 4
      RunGame/SDK/HTTP/HTTPDataProcession.m
  21. 123 0
      RunGame/SDK/shoes_sdk/BigFoot.cpp
  22. 39 0
      RunGame/SDK/shoes_sdk/BigFoot.h
  23. 2 4
      RunGame/SDK/shoes_sdk/FootStep.cpp
  24. 103 1
      RunGame/SDK/shoes_sdk/Game.cpp
  25. 19 0
      RunGame/SDK/shoes_sdk/Game.h
  26. 1 4
      RunGame/SDK/shoes_sdk/InertialTrajProcess.cpp
  27. 3 1
      RunGame/SDK/shoes_sdk/RunGame.cpp
  28. 2 1
      RunGame/SDK/shoes_sdk/pub.h
  29. 22 0
      RunGame/Unity-iPhone.xcodeproj/project.pbxproj
  30. BIN
      RunGame/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate
  31. 6 0
      RunGame/Unity-iPhone.xcodeproj/xcuserdata/duowan123.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

BIN
.DS_Store


+ 23 - 22
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){
+    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
+};
 
 //蓝牙状态
 typedef NS_ENUM(NSInteger, BLETOOTH_STUTAS){
@@ -45,7 +45,8 @@ typedef NS_ENUM(NSInteger, BLETOOTH_STUTAS){
     CONNECT_LOST, // 丢失链接 /链接失败
 };
 
-#define JBSDKLog @"danceLog.txt"
+#define JBSDKLog @"runLog.txt"
+
 
 @interface BTDataProcess : UIViewController
     
@@ -58,13 +59,13 @@ typedef NS_ENUM(NSInteger, BLETOOTH_STUTAS){
 //蓝牙设备数据源回调给popSeaechView
 @property(copy,nonatomic)void (^deviceArrBLock)(NSMutableArray*arr);
 //主设备跳起 下蹲 步数 的总数
-@property(assign,nonatomic)int jump_count;
-@property(assign,nonatomic)int crouch_count;
-@property(assign,nonatomic)int step_count;
+@property(assign,nonatomic)int initial_jump_count;
+@property(assign,nonatomic)int initial_down_count;
 //步数回调缓存
 @property(copy,nonatomic)void (^allMotionCountBLock)(int jump_count,int crouch_count,int step_count);//蓝牙设备数据源
 //脚步交互数据
 @property(copy,nonatomic)void (^getInteractionBlock)(int interaction);//蓝牙设备数据源
+
 @property(assign,nonatomic)int isBackGround;//程序在前台还是后台
 
 //单例->初始化蓝牙
@@ -75,7 +76,7 @@ typedef NS_ENUM(NSInteger, BLETOOTH_STUTAS){
 -(void)connectPeripheral:(CBPeripheral*)peripheral;
 //unity或者趣动请求 外部断开蓝牙链接
 -(void)disConnedctBle;
-
+//监听程序从后台返回
 -(void)applicationWillEnterForeground;
 
 @end

+ 119 - 112
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/BLE/BTDataProcess.mm

@@ -9,20 +9,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>
 
+//#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;
+Game *game;
+Game *viceDeviceGame;
 }
 
 @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,weak)NSTimer * timer;//定时器 定时请求主、副设备电量
 @property(nonatomic,assign)BOOL gameModel;//是否开启游戏模式
 
@@ -35,9 +36,11 @@
 @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 * tempStepString;//缓存plist
+@property (nonatomic,strong)NSString * tempStepString;//剑波要的字符串数据 缓存plist
 @property(nonatomic,assign) NSNumber *RSSI;//威严要的测试数据
+//@property(nonatomic,weak)NSTimer * rssiTimer;//记录每秒的rssi峰值
+//@property(nonatomic,assign) NSNumber * currentPeakRSSI;//龙哥要的测试数据
+
 /*****测试*******/
 
 @end
@@ -111,14 +114,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
 -(void)applicationWillEnterForeground{
     
     NSLog(@"BTDataProcess 收到程序从后台返回 peripheral.state = %ld",LEManager.peripheral.state);
-//    if (LEManager.peripheral!=nil&&LEManager.peripheral.state!= CBPeripheralStateConnected){//蓝牙不为空 且蓝牙断开链接(有三种情况)
-//        [self connectPeripheral:LEManager.peripheral];//蓝牙重链接
-//    }
-//
-//    if (LEManager.vicePeripheral!=nil&&LEManager.vicePeripheral.state != CBPeripheralStateConnected){//蓝牙不为空 且蓝牙断开链接
-//        [self connectPeripheral:LEManager.vicePeripheral];//蓝牙重链接
-//    }
-    
     [self initCBCentralManager];
     
 }
@@ -319,9 +314,11 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         if (self.deviceType==DEVICETYPE_MAIN){
             LEManager.peripheral = peripheral;
             game = new Game(self.game_id);
+//            MainShoesAnalysis * instance = [MainShoesAnalysis sharedInstance];
+//            instance->game = new Game(self.game_id);
         }else if (self.deviceType == DEVICETYPE_VICE){
             LEManager.vicePeripheral = peripheral;
-//            self.viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
+//            viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
         }
         
         //根据ios_sdk传入deviceType 链接 主/副 设备
@@ -395,10 +392,10 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     LEManager.writeToCharacteristicBlock = ^(CBPeripheral * _Nonnull peripheral,CBCharacteristic * _Nonnull characteristic, NSError * _Nonnull error, DEVICE_TYPE type){
     };
     
-    //
+    //蓝牙更新RSSI
     LEManager.rssiBlock = ^(NSNumber * _Nonnull RSSI){
         self.RSSI = RSSI;
-//        NSLog(@"self.RSSI  = %@",self.RSSI );
+//        NSLog(@"self.RSSI  = %@",self.RSSI);
     };
     
     //蓝牙连接成功
@@ -410,9 +407,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     //蓝牙连接失败
     LEManager.connectFailureBlock = ^(NSError * _Nonnull error){
         NSLog(@"蓝牙链接失败");
-//        if (peripheral == LEManager.peripheral){
-//
-//        }
     };
 
     //蓝牙连接丢失
@@ -432,6 +426,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                                      electricity:0];
                 
             }
+            
             if (LEManager.vicePeripheral!=nil){
                 
                 [self.sdk bridgingDeviceAction:DEVICETYPE_VICE
@@ -451,9 +446,8 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     //初始化缓存动作数据
     if (deviceType==DEVICETYPE_MAIN){
         
-        self.jump_count = 0;
-        self.crouch_count = 0;
-        self.step_count = 0;
+        self.initial_down_count = 0;
+        self.initial_jump_count = 0;
         
         //读写到特征后 添加测试弹窗
         [self inittestLabel];
@@ -467,11 +461,11 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         [self timingDataTransmission:@"dispatch_after"];
     });
     
+    //定时开启游戏模式 & 查询设备信息 & 开启激光检测下蹲
     if (self.timer!=nil){
         [self.timer invalidate];
         self.timer = nil;
     }
-    //定时开启游戏模式 & 查询设备信息 & 开启激光检测下蹲
     self.timer = [NSTimer scheduledTimerWithTimeInterval:15 target:self selector:@selector(timingDataTransmission:) userInfo:nil repeats:YES];
     [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];
 
@@ -492,6 +486,8 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
 
 }
 
+
+
 #pragma mark ===============================================>> 校验 & 报文数据解析
 -(void)verifyData:(CBCharacteristic*)characteristic deviceType:(DEVICE_TYPE)deviceType{
     
@@ -600,8 +596,8 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                }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 characteristic:characteristic];
                    
                }
               
@@ -683,14 +679,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     int result[length];
     game->getGameResult(result);
     //   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
-        
-    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);
@@ -700,7 +689,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     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
@@ -712,44 +701,67 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         if (motionJump == MOTION_JUMP){
             motionLeft = motionJump;
             motionRight = motionJump;
-            self.jump_count++;
             NSLog(@" 主设备 ================================== 跳起来 ");
         }
+    
         if (motionDown == MOTION_DOWN){
             motionLeft = motionDown;
             motionRight = motionDown;
-            self.crouch_count++;
             NSLog(@" 主设备 =================================== 蹲下去 ");
         }
 //    }
+    
+    /****************** ios call unity*****************/
+        if (self.gameModel==YES){//当前是游戏模式
 
-    //数据回调缓存
-    if (self.allMotionCountBLock){
-        self.step_count = leftStepCount+rightStepCount;
-        self.allMotionCountBLock(self.jump_count, self.crouch_count, leftStepCount+rightStepCount);
-    }
-
-//        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];//左右脚速度 步频
+                [self.sdk bridgingStepAction:DEVICETYPE_MAIN leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];
             }
-            [self.sdk bridgingMotionAction:DEVICETYPE_MAIN left:motionLeft right:motionRight];//左右脚动作
+            //左右脚动作
+            [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);
-//            }
-//        }
+            int interaction = game->getInteractionCMD();
+//            NSLog(@"主设备 当前的脚步交互动作 ===== >> %d",interaction);
+            [self.sdk bridgingInteraction:DEVICETYPE_MAIN code:interaction];
+            if (self.getInteractionBlock){
+                self.getInteractionBlock(interaction);
+            }
+        }
+    
+    /******************数据回调缓存*****************/
+    //标记初始值
+    if (self.initial_jump_count==0){
+        self.initial_jump_count = game->getGameJumpCount();
+    }
+    if (self.initial_down_count==0) {
+        self.initial_down_count = game->getGameDownCount();
+    }
+    //总数
+    int total_jump_count = game->getGameJumpCount();
+    int total_dump_count = game->getGameDownCount();
+    //当局游戏次数
+    int current_jump_count = total_jump_count - self.initial_jump_count;
+    int current_dump_count = total_dump_count - self.initial_down_count;
+    //数据回调缓存
+    if (self.allMotionCountBLock){
+        self.allMotionCountBLock(current_jump_count, current_dump_count, leftStepCount + rightStepCount);
+    }
     
+    /********************剑波要的图表数据 *****************/
+    NSString * aString = [NSString stringWithUTF8String:game->getGameDataStr().c_str()];
+    if (self.RSSI==nil){
+        self.RSSI = 0;
+    }
+     aString = [NSString stringWithFormat:@"%@,%@",aString,self.RSSI];
+    self.tempStepString = [NSString stringWithFormat:@"%@\n",aString];
+    if (self.tempStepString!=nil && self.tempStepString.length>1){
+        [self writeFileToplist];
+    }
   
-    //
+    /********************调试窗数据 *****************/
     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,self.RSSI,ts,aArray[aArray.count-2],aArray.lastObject,leftStepFreq,rightStepFreq];
     
@@ -776,65 +788,60 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                         rssi:(int)rssi
                    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返回的鞋子 动作*****************/
-//    int motionLeft = result[0];//左脚的动作
-//    int motionRight = result[1];//右脚的动作
-//    int ivce_motionJump = result[2];//jump
-//    int ivce_motionDown = result[3];//down
+                  left_press:(int)left_press
+              characteristic:(NSData*)characteristic{
+
+        /********************初始化 运动轨迹算法 SDK *****************/
+    //游戏数据
+    NSData * validData= [characteristic subdataWithRange:NSMakeRange(4, characteristic.length-4)];
+    Byte * buff = (Byte*)[validData bytes];
+    viceDeviceGame->GameProcessBuf(buff, (int)validData.length);
+    
+    int length = 4;
+    int result[length];
+    viceDeviceGame->getGameResult(result);
+    //   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
+        
+
+    /********************蓝牙sdk返回的鞋子 状态 步频 步数*****************/
+    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);
+    
+
+    /********************蓝牙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];//副设备左右脚动作
-//
+        //跳跃和蹲下的动作 双脚是同步的
+        if (ivce_motionJump == MOTION_JUMP){
+            motionLeft = ivce_motionJump;
+            motionRight = ivce_motionJump;
+            NSLog(@"副设备 ======================================== 跳起来");
+        }
+        if (ivce_motionDown == MOTION_DOWN){
+            motionLeft = ivce_motionDown;
+            motionRight = ivce_motionDown;
+            NSLog(@"副设备 ========================================= 蹲下去");
+        }
+        
+        //ios call unity
+        if (self.game_id == GAME_TYPE_RUN){//跑酷才需要回调
+            [self.sdk bridgingStepAction:DEVICETYPE_VICE leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//副设备左右脚速度 步频
+        }
+        //ios call unity as相互NX你·
+        [self.sdk bridgingMotionAction:DEVICETYPE_VICE left:motionLeft right:motionRight];//副设备左右脚动作
+
 //    }
-//
+
 }
 
 #pragma mark ===============================================>> 蓝牙发送各类数据

+ 123 - 0
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/BigFoot.cpp

@@ -0,0 +1,123 @@
+#include "pub.h"
+
+#include "BigFoot.h"
+
+
+BigFoot::BigFoot()
+{
+	memset(result, 0, 4 * sizeof(int));
+
+	memset(left_min_acc, 0, 3 * sizeof(int));
+
+	memset(left_max_acc, 0, 3 * sizeof(int));
+
+	memset(right_min_acc, 0, 3 * sizeof(int));
+
+	memset(right_max_acc, 0, 3 * sizeof(int));
+
+	last_left_zupt = 1;
+
+	last_right_zupt = 1;
+}
+
+int BigFoot::station_acc(int* max_acc, int* min_acc)
+{
+	for (int i = 0; i < 3; i++)
+	{
+		if (max_acc[i] - min_acc[i] > 1024)
+		{
+			return 0;
+		}
+	}
+
+
+	return 1;
+}
+
+void BigFoot::getResult(int* matrix)
+{
+	memcpy(matrix, result, 4 * sizeof(int));
+}
+
+void BigFoot::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)
+{
+
+
+	//需要用加速度过滤伪触地,如果期间是小于0.5g的则视为伪触地,过滤掉
+	//station_acc 判断方法
+
+	if (left_zupt && last_left_zupt == 0 && !station_acc(left_max_acc, left_min_acc))
+	//if (left_zupt && last_left_zupt == 0 )
+	{
+		result[0] = 1;
+		std::cout << "左脚踩了" << std::endl;
+	}
+	else
+	{
+		result[0] = 0;
+	}
+
+	if (right_zupt && last_right_zupt == 0 && !station_acc(right_max_acc, right_min_acc))
+	{
+		result[1] = 1;
+		std::cout << "右脚踩了" << std::endl;
+	}
+	else
+	{
+		result[1] = 0;
+	}
+	
+
+	last_left_zupt = left_zupt;
+
+	last_right_zupt = right_zupt;
+
+
+	if (left_zupt)
+	{
+		memcpy(left_min_acc, left_acc, 3 * sizeof(int));
+
+		memcpy(left_max_acc, left_acc, 3 * sizeof(int));
+	}
+	else
+	{
+		for (int i = 0; i < 3; i++)
+		{
+			if (left_min_acc[i] > left_acc[i])
+			{
+				left_min_acc[i] = left_acc[i];
+			}
+
+			if (left_max_acc[i] < left_acc[i])
+			{
+				left_max_acc[i] = left_acc[i];
+			}
+		}
+	}
+
+	if (right_zupt)
+	{
+		memcpy(right_min_acc, right_acc, 3 * sizeof(int));
+
+		memcpy(right_max_acc, right_acc, 3 * sizeof(int));
+	}
+	else
+	{
+		for (int i = 0; i < 3; i++)
+		{
+			if (right_min_acc[i] > right_acc[i])
+			{
+				right_min_acc[i] = right_acc[i];
+			}
+
+			if (right_max_acc[i] < right_acc[i])
+			{
+				right_max_acc[i] = right_acc[i];
+			}
+		}
+	}
+
+
+}

+ 39 - 0
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/BigFoot.h

@@ -0,0 +1,39 @@
+#pragma once
+#ifndef _BigFoot_H_
+#define _BigFoot_H_
+
+class BigFoot {
+public:
+
+	BigFoot();
+
+	void 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);
+
+	int station_acc(int* max_acc, int* min_acc);
+
+
+private:
+
+	int result[4];
+
+	int left_min_acc[3];
+
+	int left_max_acc[3];
+	
+	int right_min_acc[3];
+
+	int right_max_acc[3];
+
+	int last_left_zupt;
+
+	int last_right_zupt;
+
+};
+
+
+#endif

+ 98 - 0
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/Game.cpp

@@ -21,6 +21,15 @@ Game::Game(int gametype)
 	leftRate = 0;
 	rightRate = 0;
 
+	last_down = 0;
+	last_jump = 0;
+
+	down_count = 0;
+	jump_count = 0;
+
+	down_wait = 0;
+	avoid_down_between_jump = 0;
+
 	interaction = Interaction();
 
 	InteractionCMD = -1;
@@ -57,6 +66,11 @@ Game::Game(int gametype)
 	{
 		tricycle = Tricycle();
 	}
+
+	else if (GameType == BIGFOOT)
+	{
+		bigfoot = BigFoot();
+	}
 	
 
 }
@@ -66,6 +80,77 @@ int Game::getInteractionCMD()
 	return InteractionCMD;
 }
 
+void Game::processCalorieData(int down, int jump)
+{
+
+	if (down)
+	{
+		down_wait = 20;
+	}
+
+	if (jump)
+	{
+		avoid_down_between_jump = 20;
+	}
+
+	if (avoid_down_between_jump > 0 && h_zupt == 0 && s_zupt == 0)
+	{
+		avoid_down_between_jump = 20;
+	}
+
+	if (avoid_down_between_jump > 0 && down == 1)
+	{
+		avoid_down_between_jump = 20;
+	}
+
+	if (avoid_down_between_jump > 0)
+	{
+		down_wait = 0;
+		down = 0;
+		last_down = 0;
+	}
+
+	if (down_wait > 0)
+	{
+		down = 1;
+
+		down_wait --;
+	}
+
+	if (avoid_down_between_jump)
+	{
+		avoid_down_between_jump--;
+	}
+	
+	if (down == 0 && last_down == 1)
+	{
+		down_count++;
+
+		std::cout << "蹲的次数 : " << down_count << endl;
+	}
+
+	if (last_jump == 0 && jump == 1)
+	{
+		jump_count++;
+		std::cout << "跳的次数 : " << jump_count << endl;
+
+	}
+
+	last_down = down;
+	last_jump = jump;
+}
+
+
+int Game::getGameDownCount()
+{
+	return down_count;
+}
+
+int Game::getGameJumpCount()
+{
+	return jump_count;
+}
+
 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)
@@ -81,6 +166,8 @@ void Game::GameProcess(int timeStamp, int* right_pos, int* right_att, int *right
 		jump, down, rssi);
 
 	InteractionCMD = interaction.get_motion_state();
+
+	processCalorieData(down, jump);
 	
 	
 	if (GameType == RUNGAME)
@@ -178,6 +265,16 @@ void Game::GameProcess(int timeStamp, int* right_pos, int* right_att, int *right
 		tricycle.getResult(resultMatrix);
 
 	}
+
+	else if (GameType == BIGFOOT)
+	{
+
+		bigfoot.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);
+
+		//跑酷游戏处理结果获取
+		bigfoot.getResult(resultMatrix);
+	}
 	
 	/*
 	if (foot_data_file.is_open()&& GameType == DANCEGAME)
@@ -338,6 +435,7 @@ void Game::GameProcessBuf(uint8_t* buf, int len) {
 
 	jump = (buf[48] & 0x01) >> 0;
 
+
 	rssi = (int)buf[49];
 
 	posTimeStamp = buf[50];

+ 19 - 0
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/Game.h

@@ -4,6 +4,7 @@
 
 #include "pub.h"
 #include "RunGame.h"
+
 #include "InertialTrajProcess.h"
 #include "DanceGame.h"
 
@@ -19,6 +20,8 @@
 
 #include "Tricycle.h"
 
+#include "BigFoot.h"
+
 #include <fstream>
 #include <time.h>
 #include <sstream>
@@ -56,6 +59,12 @@ class Game
 
 			int getInteractionCMD();
 
+			void processCalorieData(int down, int jump);
+
+			int getGameDownCount();
+
+			int getGameJumpCount();
+
 		private:
 
 			int GameType;
@@ -80,6 +89,7 @@ class Game
 
 			Tricycle tricycle;
 
+			BigFoot bigfoot;
 
 			int leftStepRate;
 			int rightStepRate;
@@ -135,6 +145,15 @@ class Game
 			uint32_t right_step;
 			uint32_t left_step;
 
+			int down_count;
+			int jump_count;
+			
+			int last_down;
+			int last_jump;
+
+			int down_wait;
+			int avoid_down_between_jump;
+
 };
 
 #endif

+ 0 - 1
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/KpSupport/SDK/shoes_sdk/InertialTrajProcess.cpp

@@ -42,7 +42,6 @@ void InertialTrajProcess::TrajRotate(int* pos)
 
 	posTemp[0] = cos(curheading) * float(pos_f[0]) + sin(curheading) * float(pos_f[1]);
 	posTemp[1] = -sin(curheading) * float(pos_f[0]) + cos(curheading) * float(pos_f[1]);
-
 	
 	pos[0] = (int)(posTemp[0] * 100.0f);
 	pos[1] = (int)(posTemp[1] * 100.0f);

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

@@ -24,6 +24,7 @@ using namespace std;
 #define MONSTER 4
 #define RUINS 5
 #define CYCLE 6
+#define BIGFOOT 7
 
 #define RSSI_LIMIT
 
@@ -33,7 +34,7 @@ using namespace std;
 
 #define PRESS_MIN 41000
 
-#define GAME_VERSION "0.3.28"
+#define GAME_VERSION "0.3.30"
 
 enum CMD_MOTION
 {
@@ -84,4 +85,4 @@ struct FootActionState {
     uint32_t Triggering_time;
 };
 
-#endif
+#endif

+ 6 - 0
DanceGame/Unity-iPhone.xcodeproj/project.pbxproj

@@ -291,6 +291,7 @@
 		933F32B1273BA1E80084CFD5 /* GameObjc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 933F3258273BA1E80084CFD5 /* GameObjc.mm */; };
 		933F32B2273BA1E80084CFD5 /* MYFactoryManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 933F3259273BA1E80084CFD5 /* MYFactoryManager.m */; };
 		933F32B3273BA1E80084CFD5 /* UIView+ST.m in Sources */ = {isa = PBXBuildFile; fileRef = 933F325A273BA1E80084CFD5 /* UIView+ST.m */; };
+		936820CE27620D86007B4D6B /* BigFoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 936820CC27620D86007B4D6B /* BigFoot.cpp */; };
 		93FA5171274CD2F000AEAD33 /* Tricycle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93FA516E274CD2EF00AEAD33 /* Tricycle.cpp */; };
 		93FA5172274CD2F000AEAD33 /* RuinsExplore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93FA5170274CD2F000AEAD33 /* RuinsExplore.cpp */; };
 		960391221D6CE46E003BF157 /* MediaToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 960391211D6CE46E003BF157 /* MediaToolbox.framework */; };
@@ -792,6 +793,8 @@
 		933F3258273BA1E80084CFD5 /* GameObjc.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GameObjc.mm; sourceTree = "<group>"; };
 		933F3259273BA1E80084CFD5 /* MYFactoryManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYFactoryManager.m; sourceTree = "<group>"; };
 		933F325A273BA1E80084CFD5 /* UIView+ST.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+ST.m"; sourceTree = "<group>"; };
+		936820CC27620D86007B4D6B /* BigFoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BigFoot.cpp; sourceTree = "<group>"; };
+		936820CD27620D86007B4D6B /* BigFoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BigFoot.h; sourceTree = "<group>"; };
 		939A4F0BB402A4FAF3B26D8D /* Bulk_UnityEngine.ScreenCaptureModule_0.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Bulk_UnityEngine.ScreenCaptureModule_0.cpp; path = Classes/Native/Bulk_UnityEngine.ScreenCaptureModule_0.cpp; sourceTree = SOURCE_ROOT; };
 		93FA516D274CD2EF00AEAD33 /* RuinsExplore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RuinsExplore.h; sourceTree = "<group>"; };
 		93FA516E274CD2EF00AEAD33 /* Tricycle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Tricycle.cpp; sourceTree = "<group>"; };
@@ -1551,6 +1554,8 @@
 		933F3205273BA1E70084CFD5 /* shoes_sdk */ = {
 			isa = PBXGroup;
 			children = (
+				936820CC27620D86007B4D6B /* BigFoot.cpp */,
+				936820CD27620D86007B4D6B /* BigFoot.h */,
 				933F3207273BA1E80084CFD5 /* DanceFoot.cpp */,
 				933F3211273BA1E80084CFD5 /* DanceFoot.h */,
 				933F3216273BA1E80084CFD5 /* DanceGame.cpp */,
@@ -2009,6 +2014,7 @@
 				8F1B4C76A363315DD52356E0 /* Bulk_System.Configuration_0.cpp in Sources */,
 				A4FA4EE69A19A1EC9B4D6EDA /* Bulk_System.Core_0.cpp in Sources */,
 				BE874A4691FF5DD0818A2FF1 /* Bulk_System.Xml_0.cpp in Sources */,
+				936820CE27620D86007B4D6B /* BigFoot.cpp in Sources */,
 				14AD4A3991412994D3F7AF30 /* Bulk_System.Xml_1.cpp in Sources */,
 				5DA94D729A4D7AF76E176C9B /* Bulk_System.Xml_2.cpp in Sources */,
 				DD2D4014B69B6A9A90FE1735 /* Bulk_System.Xml_3.cpp in Sources */,

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


+ 0 - 1
RunGame/Classes/UnityAppController.mm

@@ -506,7 +506,6 @@ extern "C" void UnityCleanupTrampoline()
 
 @end
 
-
 void AppController_SendNotification(NSString* name)
 {
     [[NSNotificationCenter defaultCenter] postNotificationName: name object: GetAppController()];

+ 3 - 4
RunGame/SDK/BLE/BTDataProcess.h

@@ -59,9 +59,8 @@ typedef NS_ENUM(NSInteger, BLETOOTH_STUTAS){
 //蓝牙设备数据源回调给popSeaechView
 @property(copy,nonatomic)void (^deviceArrBLock)(NSMutableArray*arr);
 //主设备跳起 下蹲 步数 的总数
-@property(assign,nonatomic)int jump_count;
-@property(assign,nonatomic)int crouch_count;
-@property(assign,nonatomic)int step_count;
+@property(assign,nonatomic)int initial_jump_count;
+@property(assign,nonatomic)int initial_down_count;
 //步数回调缓存
 @property(copy,nonatomic)void (^allMotionCountBLock)(int jump_count,int crouch_count,int step_count);//蓝牙设备数据源
 //脚步交互数据
@@ -77,7 +76,7 @@ typedef NS_ENUM(NSInteger, BLETOOTH_STUTAS){
 -(void)connectPeripheral:(CBPeripheral*)peripheral;
 //unity或者趣动请求 外部断开蓝牙链接
 -(void)disConnedctBle;
-//
+//监听程序从后台返回
 -(void)applicationWillEnterForeground;
 
 @end

+ 120 - 112
RunGame/SDK/BLE/BTDataProcess.mm

@@ -9,20 +9,22 @@
 #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>
+#import "MainShoesAnalysis.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;
+Game *game;
+Game *viceDeviceGame;
 }
 
 @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,weak)NSTimer * timer;//定时器 定时请求主、副设备电量
 @property(nonatomic,assign)BOOL gameModel;//是否开启游戏模式
 
@@ -35,9 +37,11 @@
 @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 * tempStepString;//缓存plist
+@property (nonatomic,strong)NSString * tempStepString;//剑波要的字符串数据 缓存plist
 @property(nonatomic,assign) NSNumber *RSSI;//威严要的测试数据
+//@property(nonatomic,weak)NSTimer * rssiTimer;//记录每秒的rssi峰值
+//@property(nonatomic,assign) NSNumber * currentPeakRSSI;//龙哥要的测试数据
+
 /*****测试*******/
 
 @end
@@ -111,14 +115,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
 -(void)applicationWillEnterForeground{
     
     NSLog(@"BTDataProcess 收到程序从后台返回 peripheral.state = %ld",LEManager.peripheral.state);
-//    if (LEManager.peripheral!=nil&&LEManager.peripheral.state!= CBPeripheralStateConnected){//蓝牙不为空 且蓝牙断开链接(有三种情况)
-//        [self connectPeripheral:LEManager.peripheral];//蓝牙重链接
-//    }
-//
-//    if (LEManager.vicePeripheral!=nil&&LEManager.vicePeripheral.state != CBPeripheralStateConnected){//蓝牙不为空 且蓝牙断开链接
-//        [self connectPeripheral:LEManager.vicePeripheral];//蓝牙重链接
-//    }
-    
     [self initCBCentralManager];
     
 }
@@ -319,9 +315,11 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         if (self.deviceType==DEVICETYPE_MAIN){
             LEManager.peripheral = peripheral;
             game = new Game(self.game_id);
+//            MainShoesAnalysis * instance = [MainShoesAnalysis sharedInstance];
+//            instance->game = new Game(self.game_id);
         }else if (self.deviceType == DEVICETYPE_VICE){
             LEManager.vicePeripheral = peripheral;
-//            self.viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
+//            viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
         }
         
         //根据ios_sdk传入deviceType 链接 主/副 设备
@@ -395,10 +393,10 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     LEManager.writeToCharacteristicBlock = ^(CBPeripheral * _Nonnull peripheral,CBCharacteristic * _Nonnull characteristic, NSError * _Nonnull error, DEVICE_TYPE type){
     };
     
-    //
+    //蓝牙更新RSSI
     LEManager.rssiBlock = ^(NSNumber * _Nonnull RSSI){
         self.RSSI = RSSI;
-//        NSLog(@"self.RSSI  = %@",self.RSSI );
+//        NSLog(@"self.RSSI  = %@",self.RSSI);
     };
     
     //蓝牙连接成功
@@ -410,9 +408,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     //蓝牙连接失败
     LEManager.connectFailureBlock = ^(NSError * _Nonnull error){
         NSLog(@"蓝牙链接失败");
-//        if (peripheral == LEManager.peripheral){
-//
-//        }
     };
 
     //蓝牙连接丢失
@@ -432,6 +427,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                                      electricity:0];
                 
             }
+            
             if (LEManager.vicePeripheral!=nil){
                 
                 [self.sdk bridgingDeviceAction:DEVICETYPE_VICE
@@ -451,9 +447,8 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     //初始化缓存动作数据
     if (deviceType==DEVICETYPE_MAIN){
         
-        self.jump_count = 0;
-        self.crouch_count = 0;
-        self.step_count = 0;
+        self.initial_down_count = 0;
+        self.initial_jump_count = 0;
         
         //读写到特征后 添加测试弹窗
         [self inittestLabel];
@@ -467,11 +462,11 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         [self timingDataTransmission:@"dispatch_after"];
     });
     
+    //定时开启游戏模式 & 查询设备信息 & 开启激光检测下蹲
     if (self.timer!=nil){
         [self.timer invalidate];
         self.timer = nil;
     }
-    //定时开启游戏模式 & 查询设备信息 & 开启激光检测下蹲
     self.timer = [NSTimer scheduledTimerWithTimeInterval:15 target:self selector:@selector(timingDataTransmission:) userInfo:nil repeats:YES];
     [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];
 
@@ -492,6 +487,8 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
 
 }
 
+
+
 #pragma mark ===============================================>> 校验 & 报文数据解析
 -(void)verifyData:(CBCharacteristic*)characteristic deviceType:(DEVICE_TYPE)deviceType{
     
@@ -600,8 +597,8 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                }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 characteristic:characteristic];
                    
                }
               
@@ -683,14 +680,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     int result[length];
     game->getGameResult(result);
     //   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
-        
-    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);
@@ -700,7 +690,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
     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
@@ -712,44 +702,67 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
         if (motionJump == MOTION_JUMP){
             motionLeft = motionJump;
             motionRight = motionJump;
-            self.jump_count++;
             NSLog(@" 主设备 ================================== 跳起来 ");
         }
+    
         if (motionDown == MOTION_DOWN){
             motionLeft = motionDown;
             motionRight = motionDown;
-            self.crouch_count++;
             NSLog(@" 主设备 =================================== 蹲下去 ");
         }
 //    }
+    
+    /****************** ios call unity*****************/
+        if (self.gameModel==YES){//当前是游戏模式
 
-    //数据回调缓存
-    if (self.allMotionCountBLock){
-        self.step_count = leftStepCount+rightStepCount;
-        self.allMotionCountBLock(self.jump_count, self.crouch_count, leftStepCount+rightStepCount);
-    }
-
-//        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];//左右脚速度 步频
+                [self.sdk bridgingStepAction:DEVICETYPE_MAIN leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];
             }
-            [self.sdk bridgingMotionAction:DEVICETYPE_MAIN left:motionLeft right:motionRight];//左右脚动作
+            //左右脚动作
+            [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);
-//            }
-//        }
+            int interaction = game->getInteractionCMD();
+//            NSLog(@"主设备 当前的脚步交互动作 ===== >> %d",interaction);
+            [self.sdk bridgingInteraction:DEVICETYPE_MAIN code:interaction];
+            if (self.getInteractionBlock){
+                self.getInteractionBlock(interaction);
+            }
+        }
+    
+    /******************数据回调缓存*****************/
+    //标记初始值
+    if (self.initial_jump_count==0){
+        self.initial_jump_count = game->getGameJumpCount();
+    }
+    if (self.initial_down_count==0) {
+        self.initial_down_count = game->getGameDownCount();
+    }
+    //总数
+    int total_jump_count = game->getGameJumpCount();
+    int total_dump_count = game->getGameDownCount();
+    //当局游戏次数
+    int current_jump_count = total_jump_count - self.initial_jump_count;
+    int current_dump_count = total_dump_count - self.initial_down_count;
+    //数据回调缓存
+    if (self.allMotionCountBLock){
+        self.allMotionCountBLock(current_jump_count, current_dump_count, leftStepCount + rightStepCount);
+    }
     
+    /********************剑波要的图表数据 *****************/
+    NSString * aString = [NSString stringWithUTF8String:game->getGameDataStr().c_str()];
+    if (self.RSSI==nil){
+        self.RSSI = 0;
+    }
+     aString = [NSString stringWithFormat:@"%@,%@",aString,self.RSSI];
+    self.tempStepString = [NSString stringWithFormat:@"%@\n",aString];
+    if (self.tempStepString!=nil && self.tempStepString.length>1){
+        [self writeFileToplist];
+    }
   
-    //
+    /********************调试窗数据 *****************/
     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,self.RSSI,ts,aArray[aArray.count-2],aArray.lastObject,leftStepFreq,rightStepFreq];
     
@@ -776,65 +789,60 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
                         rssi:(int)rssi
                    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返回的鞋子 动作*****************/
-//    int motionLeft = result[0];//左脚的动作
-//    int motionRight = result[1];//右脚的动作
-//    int ivce_motionJump = result[2];//jump
-//    int ivce_motionDown = result[3];//down
+                  left_press:(int)left_press
+              characteristic:(NSData*)characteristic{
+
+        /********************初始化 运动轨迹算法 SDK *****************/
+    //游戏数据
+    NSData * validData= [characteristic subdataWithRange:NSMakeRange(4, characteristic.length-4)];
+    Byte * buff = (Byte*)[validData bytes];
+    viceDeviceGame->GameProcessBuf(buff, (int)validData.length);
+    
+    int length = 4;
+    int result[length];
+    viceDeviceGame->getGameResult(result);
+    //   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
+        
+
+    /********************蓝牙sdk返回的鞋子 状态 步频 步数*****************/
+    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);
+    
+
+    /********************蓝牙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];//副设备左右脚动作
-//
+        //跳跃和蹲下的动作 双脚是同步的
+        if (ivce_motionJump == MOTION_JUMP){
+            motionLeft = ivce_motionJump;
+            motionRight = ivce_motionJump;
+            NSLog(@"副设备 ======================================== 跳起来");
+        }
+        if (ivce_motionDown == MOTION_DOWN){
+            motionLeft = ivce_motionDown;
+            motionRight = ivce_motionDown;
+            NSLog(@"副设备 ========================================= 蹲下去");
+        }
+        
+        //ios call unity
+        if (self.game_id == GAME_TYPE_RUN){//跑酷才需要回调
+            [self.sdk bridgingStepAction:DEVICETYPE_VICE leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//副设备左右脚速度 步频
+        }
+        //ios call unity as相互NX你·
+        [self.sdk bridgingMotionAction:DEVICETYPE_VICE left:motionLeft right:motionRight];//副设备左右脚动作
+
 //    }
-//
+
 }
 
 #pragma mark ===============================================>> 蓝牙发送各类数据

+ 42 - 0
RunGame/SDK/BLE/MainShoesAnalysis.h

@@ -0,0 +1,42 @@
+////
+////  MainShoesAnalysis.h
+////  Unity-iPhone
+////
+////  Created by duowan123 on 2021/12/4.
+////
+//
+//#import <Foundation/Foundation.h>
+//#import "MYFactoryManager.h"
+////#import "IOSPlatformSDK.h"
+//#include "Game.h"
+//
+//NS_ASSUME_NONNULL_BEGIN
+//
+//@interface MainShoesAnalysis : NSObject
+//{
+//@public
+//Game *game;
+//}
+//
+//+(instancetype)sharedInstance;
+//#pragma mark ===============================================>> 主设备 报文数据解析后 -- 调用蓝牙鞋子SDK装换数据 -- ios call unity 更新游戏动作
+//-(void)shoseSDKRight_pos:(int[_Nullable 3])right_pos
+//               Right_att:(int[_Nullable 3])right_att
+//               Right_acc:(int[_Nullable 3])right_acc
+//                 LeftPos:(int[_Nullable 3])left_pos
+//                Left_att:(int[_Nullable 3])left_att
+//                Left_acc:(int[_Nullable 3])left_acc
+//                      ts:(int)ts
+//               rightZupt:(int)rightZupt
+//                leftZupt:(int)leftZupt
+//                    jump:(int)jump
+//                    down:(int)down
+//                    rssi:(int)rssi
+//               girlShoes:(int)girlShoes
+//             right_press:(int)right_press
+//              left_press:(int)left_press
+//          characteristic:(NSData*)characteristic;
+//
+//@end
+//
+//NS_ASSUME_NONNULL_END

+ 334 - 0
RunGame/SDK/BLE/MainShoesAnalysis.mm

@@ -0,0 +1,334 @@
+////
+////  MainShoesAnalysis.m
+////  Unity-iPhone
+////
+////  Created by duowan123 on 2021/12/4.
+////
+//
+//#import "MainShoesAnalysis.h"
+//
+//
+//@implementation MainShoesAnalysis
+//
+////单例静态
+//static MainShoesAnalysis* instance = nil;
+//+(instancetype)sharedInstance{
+////    NSLog(@"创建单例一次 1");
+//     return [[self alloc] init];
+//}
+//
+//+ (instancetype)allocWithZone:(struct _NSZone *)zone{
+////    NSLog(@"创建单例一次 2");
+//  static dispatch_once_t onceToken;
+//  dispatch_once(&onceToken, ^{
+//      instance = [super allocWithZone:zone];
+//  });
+//  return instance;
+//}
+//
+//- (instancetype)init{
+////    NSLog(@"创建单例一次 3");
+//    static dispatch_once_t onceToken;
+//    dispatch_once(&onceToken, ^{
+//        instance = [super init];
+//    });
+//    return instance;
+//}
+//
+//#pragma mark ===============================================>> 校验 & 报文数据解析
+//-(void)verifyData:(CBCharacteristic*)characteristic deviceType:(DEVICE_TYPE)deviceType{
+//
+//     if (characteristic.value.length>3){
+//
+//         //带cmd位的有效数据  计算校验位
+//         if ([AlgorithmTool verificationRusult:characteristic.value]==YES){
+//
+//             [self analysisCharacteristic:characteristic.value deviceType:deviceType];
+//
+//         }
+//
+//     }else{
+//
+//         NSLog(@"无效报文");
+//
+//     }
+//
+//}
+//
+//-(void)analysisCharacteristic:(NSData*)characteristic deviceType:(DEVICE_TYPE)deviceType{
+//
+////        NSLog(@"接收到的数据data = %@",characteristic);
+//
+//    int frameHead = [AlgorithmTool dataToChar:[characteristic subdataWithRange:NSMakeRange(0, 1)]];//帧头数据aa
+//    int messageLength = [AlgorithmTool dataToChar:[characteristic subdataWithRange:NSMakeRange(1, 1)]];//报文长度
+//    int messageLengthNegation = ~messageLength;//报文长度取反
+//    int dataType = [AlgorithmTool dataToChar:[characteristic subdataWithRange:NSMakeRange(3, 1)]];//cmd类型
+//
+//      if (dataType == 4){//获取主动推过来的数据
+//            //右脚坐标数据
+//           int right_X = [AlgorithmTool dataToSwapBigIntToHost:characteristic andRange:NSMakeRange(4, 4)];
+//           int right_Y = [AlgorithmTool dataToSwapBigIntToHost:characteristic andRange:NSMakeRange(8, 4)];
+//           int right_Z = [AlgorithmTool dataToSwapBigIntToHost:characteristic andRange:NSMakeRange(12, 4)];
+//           int  right_pos[3] = {right_X,right_Y,right_Z};
+//          //左脚坐标数据
+//           int left_X = [AlgorithmTool dataToSwapBigIntToHost:characteristic andRange:NSMakeRange(16, 4)];
+//           int left_Y = [AlgorithmTool dataToSwapBigIntToHost:characteristic andRange:NSMakeRange(20, 4)];
+//           int left_Z = [AlgorithmTool dataToSwapBigIntToHost:characteristic andRange:NSMakeRange(24, 4)];
+//           int  left_pos[3] = {left_X,left_Y,left_Z};
+//           //右脚姿势数据
+//           short righrPosture_X = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(28, 2)];
+//           short righrPosture_Y = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(30, 2)];
+//           short righrPosture_Z = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(32, 2)];
+//           int  right_att[3] = {righrPosture_X,righrPosture_Y,righrPosture_Z};
+//           //左脚姿势数据
+//           short leftPosture_X = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(34, 2)];
+//           short leftPosture_Y = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(36, 2)];
+//           short leftPosture_Z = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(38, 2)];
+//           int  left_att[3] = {leftPosture_X,leftPosture_Y,leftPosture_Z};
+//           //右脚三维数据
+//           short righrAcc_x = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(40, 2)];
+//           short righrAcc_Y = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(42, 2)];
+//           short righrAcc_z = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(44, 2)];
+//           int  righrAcc[3] = {righrAcc_x,righrAcc_Y,righrAcc_z};
+//           //左脚三维数据
+//           short leftAcc_x = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(46, 2)];
+//           short leftAcc_y = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(48, 2)];
+//           short leftAcc_z = [AlgorithmTool dataToSwapBigShortToHost:characteristic andRange:NSMakeRange(50, 2)];
+//           int  left_acc[3] = {leftAcc_x,leftAcc_y,leftAcc_z};
+//           //左脚、右脚、蹲 、跳四个动作信息数据
+//           int actionInformation =  [AlgorithmTool dataToChar:[characteristic subdataWithRange:NSMakeRange(52, 1)]];;//0c 16进制字符串
+//                       int girlShoes  = actionInformation & 16;
+//                       if (girlShoes!=0){
+//                           girlShoes=1;
+//                       }else{
+//                           girlShoes=0;
+//                       }
+//                       int rightZupt  = actionInformation & 8;
+//                       if (rightZupt!=0){
+//                           rightZupt=1;
+//                       }else{
+//                           rightZupt=0;
+//                       }
+//                       int leftZupt = actionInformation & 4;
+//                       if (leftZupt!=0){
+//                            leftZupt=1;
+//                        }else{
+//                            leftZupt=0;
+//                        }
+//                       int down  = actionInformation & 2;
+//                       if (down!=0){
+//                            down=1;
+//                        }else{
+//                            down=0;
+//                        }
+//                       int jump  = actionInformation & 1;
+//                       if (jump!=0){
+//                            jump=1;
+//                        }else{
+//                            jump=0;
+//                        }
+//
+//            int rssi = [AlgorithmTool dataToChar:[characteristic subdataWithRange:NSMakeRange(53, 1)]];//rssi 信号强度
+//            int ts = [AlgorithmTool dataToChar:[characteristic subdataWithRange:NSMakeRange(54, 1)]];;//ts 时间戳
+//            int right_press = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(55, 2)]];//3 29新增 右鞋压力
+//            int left_press = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(57, 2)]];//3 29新增 左鞋压力
+//            int frameCheck =  [AlgorithmTool dataToChar:[characteristic subdataWithRange:NSMakeRange(59, 1)]];//校验位
+//
+//               if (deviceType==DEVICETYPE_MAIN){//主设备
+//
+////                   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 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];
+//
+//               }
+//
+//        }else if (dataType == -95){//获取的是查询的数据 char-->int a1 = -95
+//
+//            if (characteristic.length == 74){//A1+0  >> 0: 设备基本信息 ==>> 预留参数 趣动app用 sdk暂未调用
+//
+////                NSString *deviceModel = [[NSString alloc] initWithData:[characteristic subdataWithRange:NSMakeRange(5, 18)] encoding:NSUTF8StringEncoding];
+////                NSString *softwareVer = [AlgorithmTool hexadecimalString:[characteristic subdataWithRange:NSMakeRange(69, 2)]];//0102
+////                NSString *hardwareVer = [AlgorithmTool hexadecimalString:[characteristic subdataWithRange:NSMakeRange(71, 2)]];//0104
+//
+//            }else if (characteristic.length == 26){//A1+1 >> 1: 设备数据(左鞋,右鞋)  aa 14 eb a1 01 64 00 1a 0000981d 64 00 17 00000000 f9
+//
+//                int leftElectricity = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(5, 1)]];
+////                int leftTempreature = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(6, 1)]];
+////                int leftPressure = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(7, 4)]];
+////                int leftStepCount = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(11, 4)]];
+////                int rightElectricity = [self dataToInt:[characteristic subdataWithRange:NSMakeRange(12, 1)]];
+//                int rightElectricity = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(15, 1)]];//龙哥新协议
+////                int rightTempreature = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(16, 1)]];
+////                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);
+//
+//                    //主 设备定时器 60秒调一次   /******************ios call unity*****************/
+//                     [self.sdk bridgingDeviceAction:DEVICETYPE_MAIN
+//                                                 name:LEManager.peripheral.name
+//                                              address:LEManager.peripheral.identifier.UUIDString
+//                                               status:CONNECT_ED
+//                                          electricity:leftElectricity<=rightElectricity?leftElectricity:rightElectricity];
+//
+//                }else if (deviceType==DEVICETYPE_VICE){//副设备
+//
+//                    NSLog(@"副设备 接收到 鞋子硬件数据 26 = %@  电量 %d %d",characteristic,leftElectricity,rightElectricity);
+//
+//                    //副 设备定时器 60秒调一次   /******************ios call unity*****************/
+//                     [self.sdk bridgingDeviceAction:DEVICETYPE_VICE
+//                                                 name:LEManager.vicePeripheral.name
+//                                              address:LEManager.vicePeripheral.identifier.UUIDString
+//                                               status:CONNECT_ED
+//                                          electricity:leftElectricity<=rightElectricity?leftElectricity:rightElectricity];
+//
+//                }
+//
+//           }
+//
+//      }
+//
+//}
+//
+//#pragma mark ===============================================>> 主设备 报文数据解析后 -- 调用蓝牙鞋子SDK装换数据 -- ios call unity 更新游戏动作
+//-(void)shoseSDKRight_pos:(int[3])right_pos
+//               Right_att:(int[3])right_att
+//               Right_acc:(int[3])right_acc
+//                 LeftPos:(int[3])left_pos
+//                Left_att:(int[3])left_att
+//                Left_acc:(int[3])left_acc
+//                      ts:(int)ts
+//               rightZupt:(int)rightZupt
+//                leftZupt:(int)leftZupt
+//                    jump:(int)jump
+//                    down:(int)down
+//                    rssi:(int)rssi
+//               girlShoes:(int)girlShoes
+//             right_press:(int)right_press
+//              left_press:(int)left_press
+//          characteristic:(NSData*)characteristic{
+//
+//    /********************初始化 运动轨迹算法 SDK *****************/
+//    //游戏数据
+//    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];
+//    game->getGameResult(result);
+//    //   NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
+//
+//    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
+//    int motionDown = result[3];//down
+////    if (motionLeft==-1 && motionRight == -1&& motionJump == -1&& motionDown == -1){//无效动作
+////        return;
+////    }else{
+//        //跳跃和蹲下的动作 双脚是同步的
+//        if (motionJump == MOTION_JUMP){
+//            motionLeft = motionJump;
+//            motionRight = motionJump;
+//            self.jump_count++;
+//            NSLog(@" 主设备 ================================== 跳起来 ");
+//        }
+//        if (motionDown == MOTION_DOWN){
+//            motionLeft = motionDown;
+//            motionRight = motionDown;
+//            self.crouch_count++;
+//            NSLog(@" 主设备 =================================== 蹲下去 ");
+//        }
+////    }
+//
+//    //数据回调缓存
+//    if (self.allMotionCountBLock){
+//        self.step_count = leftStepCount+rightStepCount;
+//        self.allMotionCountBLock(self.jump_count, self.crouch_count, leftStepCount+rightStepCount);
+//    }
+//
+////        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];//左右脚速度 步频
+//            }
+//            [self.sdk bridgingMotionAction:DEVICETYPE_MAIN left:motionLeft right:motionRight];//左右脚动作
+//
+////        }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,self.RSSI,ts,aArray[aArray.count-2],aArray.lastObject,leftStepFreq,rightStepFreq];
+//
+//}
+//
+//
+////数据写入沙河
+//-(void)writeFileToplist{
+//
+//    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+//    //获取完整路径
+//    NSString *documentsDirectory = [paths objectAtIndex:0];
+//    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:JBSDKLog];//这里就是你将要存储的沙盒路径(.plist文件,名字自定义)
+//
+//    if(![[NSFileManager defaultManager] fileExistsAtPath:filePath]){//plistPath这个文件\文件夹是否存在
+//
+//        NSLog(@"-------文件不存在,写入文件----------");
+//
+//               NSError *error;
+//               if([self.tempStepString writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error]){
+//                   NSLog(@"------写入文件------success");
+//               }else{
+//                    NSLog(@"------写入文件------fail,error==%@",error);
+//               };
+//
+//    }else{
+//
+////        NSLog(@"-------文件存在,追加文件----------");
+//        NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:filePath];
+//       [fileHandle seekToEndOfFile];  //将节点跳到文件的末尾
+//       NSData* stringData  = [self.tempStepString dataUsingEncoding:NSUTF8StringEncoding];
+//       [fileHandle writeData:stringData]; //追加写入数据
+//        [fileHandle closeFile];
+//
+//    }
+//
+//}
+//
+//@end

+ 16 - 0
RunGame/SDK/BLE/ViceShoesAnalysis.h

@@ -0,0 +1,16 @@
+//
+//  ViceShoesAnalysis.h
+//  Unity-iPhone
+//
+//  Created by duowan123 on 2021/12/4.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface ViceShoesAnalysis : NSObject
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 12 - 0
RunGame/SDK/BLE/ViceShoesAnalysis.m

@@ -0,0 +1,12 @@
+//
+//  ViceShoesAnalysis.m
+//  Unity-iPhone
+//
+//  Created by duowan123 on 2021/12/4.
+//
+
+#import "ViceShoesAnalysis.h"
+
+@implementation ViceShoesAnalysis
+
+@end

+ 13 - 6
RunGame/SDK/HTTP/HTTPDataProcession.h

@@ -17,12 +17,19 @@
 
 //#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"]
-#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"]
+//#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"]
+//#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"]
+
+#define GAME_INVITE [NSString stringWithFormat:@"%@%@?v=%@&os=%@",BASE_URL,@"/game/invite",CFBundleVersion,OS]
+#define GAME_RECORD [NSString stringWithFormat:@"%@%@?v=%@&os=%@",BASE_URL,@"/gameRecord/addGame",CFBundleVersion,OS]
+#define GAME_FRIENDS [NSString stringWithFormat:@"%@%@?v=%@&os=%@",BASE_URL,@"/forum/friends",CFBundleVersion,OS]
+#define GAME_RANK [NSString stringWithFormat:@"%@%@?v=%@&os=%@",BASE_URL,@"/rank/game",CFBundleVersion,OS]
+#define GAME_START [NSString stringWithFormat:@"%@%@?v=%@&os=%@",BASE_URL,@"/game/start",CFBundleVersion,OS]
+#define GAME_END [NSString stringWithFormat:@"%@%@?v=%@&os=%@",BASE_URL,@"/game/end",CFBundleVersion,OS]
 
 typedef void(^SuccessBlock)(id data);
 typedef void(^FailBlock)(id errorDes);

+ 4 - 4
RunGame/SDK/HTTP/HTTPDataProcession.m

@@ -146,7 +146,7 @@
 
     NSLog(@"gameFriends token ===>> %@ ",IOSSDK_TOKEN);
     
-    NSString *urlString =  [NSString stringWithFormat:@"%@?limit=%@&v=%@&os=%@",GAME_FRIENDS,@"1000",CFBundleVersion,OS];
+    NSString *urlString =  [NSString stringWithFormat:@"%@&limit=%@&v=%@&os=%@",GAME_FRIENDS,@"1000",CFBundleVersion,OS];
 
     [HTTPDataProcession getHTTPDataProcession:urlString token:IOSSDK_TOKEN  success:^(id data){
             // 网络访问成功
@@ -224,7 +224,7 @@
     NSString * game_id = jsonDict[@"game_id"];
     NSLog(@"InviteFriend ===>> token:%@  friendid:%d  info:%s",token,friendid,info);
     
-    NSString *urlString = [NSString stringWithFormat:@"%@?invite_user_id=%@&invite=%@&game_id=%@",GAME_INVITE,invite_user_id,invite,game_id];
+    NSString *urlString = [NSString stringWithFormat:@"%@&invite_user_id=%@&invite=%@&game_id=%@",GAME_INVITE,invite_user_id,invite,game_id];
     [HTTPDataProcession getHTTPDataProcession:urlString token:token  success:^(id data){
         
             NSError * error;
@@ -350,7 +350,7 @@
 */
 +(void)gameStart{
 
-    NSString *urlString = [NSString stringWithFormat:@"%@?id=%@",GAME_START,IOSSDK_GAMEID];
+    NSString *urlString = [NSString stringWithFormat:@"%@&id=%@",GAME_START,IOSSDK_GAMEID];
     [HTTPDataProcession getHTTPDataProcession:urlString token:IOSSDK_TOKEN  success:^(id data){
         
             NSError * error;
@@ -384,7 +384,7 @@
 */
 +(void)gameEnd{
     
-    NSString *urlString = [NSString stringWithFormat:@"%@?id=%@",GAME_END,IOSSDK_GAMEID];
+    NSString *urlString = [NSString stringWithFormat:@"%@&id=%@",GAME_END,IOSSDK_GAMEID];
     [HTTPDataProcession getHTTPDataProcession:urlString token:IOSSDK_TOKEN  success:^(id data){
         
             NSError * error;

+ 123 - 0
RunGame/SDK/shoes_sdk/BigFoot.cpp

@@ -0,0 +1,123 @@
+#include "pub.h"
+
+#include "BigFoot.h"
+
+
+BigFoot::BigFoot()
+{
+	memset(result, 0, 4 * sizeof(int));
+
+	memset(left_min_acc, 0, 3 * sizeof(int));
+
+	memset(left_max_acc, 0, 3 * sizeof(int));
+
+	memset(right_min_acc, 0, 3 * sizeof(int));
+
+	memset(right_max_acc, 0, 3 * sizeof(int));
+
+	last_left_zupt = 1;
+
+	last_right_zupt = 1;
+}
+
+int BigFoot::station_acc(int* max_acc, int* min_acc)
+{
+	for (int i = 0; i < 3; i++)
+	{
+		if (max_acc[i] - min_acc[i] > 1024)
+		{
+			return 0;
+		}
+	}
+
+
+	return 1;
+}
+
+void BigFoot::getResult(int* matrix)
+{
+	memcpy(matrix, result, 4 * sizeof(int));
+}
+
+void BigFoot::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)
+{
+
+
+	//需要用加速度过滤伪触地,如果期间是小于0.5g的则视为伪触地,过滤掉
+	//station_acc 判断方法
+
+	if (left_zupt && last_left_zupt == 0 && !station_acc(left_max_acc, left_min_acc))
+	//if (left_zupt && last_left_zupt == 0 )
+	{
+		result[0] = 1;
+		std::cout << "左脚踩了" << std::endl;
+	}
+	else
+	{
+		result[0] = 0;
+	}
+
+	if (right_zupt && last_right_zupt == 0 && !station_acc(right_max_acc, right_min_acc))
+	{
+		result[1] = 1;
+		std::cout << "右脚踩了" << std::endl;
+	}
+	else
+	{
+		result[1] = 0;
+	}
+	
+
+	last_left_zupt = left_zupt;
+
+	last_right_zupt = right_zupt;
+
+
+	if (left_zupt)
+	{
+		memcpy(left_min_acc, left_acc, 3 * sizeof(int));
+
+		memcpy(left_max_acc, left_acc, 3 * sizeof(int));
+	}
+	else
+	{
+		for (int i = 0; i < 3; i++)
+		{
+			if (left_min_acc[i] > left_acc[i])
+			{
+				left_min_acc[i] = left_acc[i];
+			}
+
+			if (left_max_acc[i] < left_acc[i])
+			{
+				left_max_acc[i] = left_acc[i];
+			}
+		}
+	}
+
+	if (right_zupt)
+	{
+		memcpy(right_min_acc, right_acc, 3 * sizeof(int));
+
+		memcpy(right_max_acc, right_acc, 3 * sizeof(int));
+	}
+	else
+	{
+		for (int i = 0; i < 3; i++)
+		{
+			if (right_min_acc[i] > right_acc[i])
+			{
+				right_min_acc[i] = right_acc[i];
+			}
+
+			if (right_max_acc[i] < right_acc[i])
+			{
+				right_max_acc[i] = right_acc[i];
+			}
+		}
+	}
+
+
+}

+ 39 - 0
RunGame/SDK/shoes_sdk/BigFoot.h

@@ -0,0 +1,39 @@
+#pragma once
+#ifndef _BigFoot_H_
+#define _BigFoot_H_
+
+class BigFoot {
+public:
+
+	BigFoot();
+
+	void 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);
+
+	int station_acc(int* max_acc, int* min_acc);
+
+
+private:
+
+	int result[4];
+
+	int left_min_acc[3];
+
+	int left_max_acc[3];
+	
+	int right_min_acc[3];
+
+	int right_max_acc[3];
+
+	int last_left_zupt;
+
+	int last_right_zupt;
+
+};
+
+
+#endif

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

@@ -76,15 +76,13 @@ 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;
@@ -128,4 +126,4 @@ int FootStep::getStepStatus()
 int FootStep::getStepCount()
 {
 	return stepCount;
-}
+}

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

@@ -21,6 +21,15 @@ Game::Game(int gametype)
 	leftRate = 0;
 	rightRate = 0;
 
+	last_down = 0;
+	last_jump = 0;
+
+	down_count = 0;
+	jump_count = 0;
+
+	down_wait = 0;
+	avoid_down_between_jump = 0;
+
 	interaction = Interaction();
 
 	InteractionCMD = -1;
@@ -57,6 +66,11 @@ Game::Game(int gametype)
 	{
 		tricycle = Tricycle();
 	}
+
+	else if (GameType == BIGFOOT)
+	{
+		bigfoot = BigFoot();
+	}
 	
 
 }
@@ -66,19 +80,95 @@ int Game::getInteractionCMD()
 	return InteractionCMD;
 }
 
+void Game::processCalorieData(int down, int jump)
+{
+
+	if (down)
+	{
+		down_wait = 20;
+	}
+
+	if (jump)
+	{
+		avoid_down_between_jump = 20;
+	}
+
+	if (avoid_down_between_jump > 0 && h_zupt == 0 && s_zupt == 0)
+	{
+		avoid_down_between_jump = 20;
+	}
+
+	if (avoid_down_between_jump > 0 && down == 1)
+	{
+		avoid_down_between_jump = 20;
+	}
+
+	if (avoid_down_between_jump > 0)
+	{
+		down_wait = 0;
+		down = 0;
+		last_down = 0;
+	}
+
+	if (down_wait > 0)
+	{
+		down = 1;
+
+		down_wait --;
+	}
+
+	if (avoid_down_between_jump)
+	{
+		avoid_down_between_jump--;
+	}
+	
+	if (down == 0 && last_down == 1)
+	{
+		down_count++;
+
+		std::cout << "蹲的次数 : " << down_count << endl;
+	}
+
+	if (last_jump == 0 && jump == 1)
+	{
+		jump_count++;
+		std::cout << "跳的次数 : " << jump_count << endl;
+
+	}
+
+	last_down = down;
+	last_jump = jump;
+}
+
+
+int Game::getGameDownCount()
+{
+	return down_count;
+}
+
+int Game::getGameJumpCount()
+{
+	return jump_count;
+}
+
 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();
+
+	processCalorieData(down, jump);
+	
 	
 	if (GameType == RUNGAME)
 	{
@@ -95,6 +185,7 @@ 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);
@@ -174,6 +265,16 @@ void Game::GameProcess(int timeStamp, int* right_pos, int* right_att, int *right
 		tricycle.getResult(resultMatrix);
 
 	}
+
+	else if (GameType == BIGFOOT)
+	{
+
+		bigfoot.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);
+
+		//跑酷游戏处理结果获取
+		bigfoot.getResult(resultMatrix);
+	}
 	
 	/*
 	if (foot_data_file.is_open()&& GameType == DANCEGAME)
@@ -334,6 +435,7 @@ void Game::GameProcessBuf(uint8_t* buf, int len) {
 
 	jump = (buf[48] & 0x01) >> 0;
 
+
 	rssi = (int)buf[49];
 
 	posTimeStamp = buf[50];

+ 19 - 0
RunGame/SDK/shoes_sdk/Game.h

@@ -4,6 +4,7 @@
 
 #include "pub.h"
 #include "RunGame.h"
+
 #include "InertialTrajProcess.h"
 #include "DanceGame.h"
 
@@ -19,6 +20,8 @@
 
 #include "Tricycle.h"
 
+#include "BigFoot.h"
+
 #include <fstream>
 #include <time.h>
 #include <sstream>
@@ -56,6 +59,12 @@ class Game
 
 			int getInteractionCMD();
 
+			void processCalorieData(int down, int jump);
+
+			int getGameDownCount();
+
+			int getGameJumpCount();
+
 		private:
 
 			int GameType;
@@ -80,6 +89,7 @@ class Game
 
 			Tricycle tricycle;
 
+			BigFoot bigfoot;
 
 			int leftStepRate;
 			int rightStepRate;
@@ -135,6 +145,15 @@ class Game
 			uint32_t right_step;
 			uint32_t left_step;
 
+			int down_count;
+			int jump_count;
+			
+			int last_down;
+			int last_jump;
+
+			int down_wait;
+			int avoid_down_between_jump;
+
 };
 
 #endif

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

@@ -20,12 +20,11 @@ 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)
 {
 	/*
@@ -43,14 +42,12 @@ void InertialTrajProcess::TrajRotate(int* pos)
 
 	posTemp[0] = cos(curheading) * float(pos_f[0]) + sin(curheading) * float(pos_f[1]);
 	posTemp[1] = -sin(curheading) * float(pos_f[0]) + cos(curheading) * 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);
 
 	//std::cout << "DanceGame:Rotate : " << pos[0] << " " << pos[1] << " " << pos[2] << std::endl;
-    
 }
 
 void InertialTrajProcess::ResetHeading(int heading)

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

@@ -35,10 +35,12 @@ 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);

+ 2 - 1
RunGame/SDK/shoes_sdk/pub.h

@@ -24,6 +24,7 @@ using namespace std;
 #define MONSTER 4
 #define RUINS 5
 #define CYCLE 6
+#define BIGFOOT 7
 
 #define RSSI_LIMIT
 
@@ -33,7 +34,7 @@ using namespace std;
 
 #define PRESS_MIN 41000
 
-#define GAME_VERSION "0.3.28"
+#define GAME_VERSION "0.3.30"
 
 enum CMD_MOTION
 {

+ 22 - 0
RunGame/Unity-iPhone.xcodeproj/project.pbxproj

@@ -141,6 +141,11 @@
 		91634BCABE88DDD8DFAAD540 /* Mono.Security.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4155430EA7CEB59D55197759 /* Mono.Security.cpp */; };
 		92574E71A6978B6FF12FF692 /* Assembly-CSharp_CodeGen.c in Sources */ = {isa = PBXBuildFile; fileRef = 02AA41F1A4261ED4EB825C5C /* Assembly-CSharp_CodeGen.c */; };
 		9310484E8033EE90AEEE8CF6 /* Unity.TextMeshPro2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1594831A43DADD87DAD6E8B /* Unity.TextMeshPro2.cpp */; };
+		9353CD64275B48EA0022CE0B /* MainShoesAnalysis.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9353CD63275B48EA0022CE0B /* MainShoesAnalysis.mm */; };
+		9353CD67275B493E0022CE0B /* ViceShoesAnalysis.m in Sources */ = {isa = PBXBuildFile; fileRef = 9353CD66275B493E0022CE0B /* ViceShoesAnalysis.m */; };
+		936820C9276201B2007B4D6B /* BigFoot.h in Headers */ = {isa = PBXBuildFile; fileRef = 936820C7276201B2007B4D6B /* BigFoot.h */; };
+		936820CA276201B2007B4D6B /* BigFoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 936820C8276201B2007B4D6B /* BigFoot.cpp */; };
+		936820CB276201B2007B4D6B /* BigFoot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 936820C8276201B2007B4D6B /* BigFoot.cpp */; };
 		93BF4D8886264CB7CCCB31FC /* QFramework.RefCounter_CodeGen.c in Sources */ = {isa = PBXBuildFile; fileRef = 0BBF475A88C75316BEDFEF01 /* QFramework.RefCounter_CodeGen.c */; };
 		93FA55822750E1EE00AEAD33 /* TXCarouselCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93FA54ED2750E1EE00AEAD33 /* TXCarouselCollectionViewCell.xib */; };
 		93FA55832750E1EE00AEAD33 /* TXCarouselCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93FA54ED2750E1EE00AEAD33 /* TXCarouselCollectionViewCell.xib */; };
@@ -802,6 +807,12 @@
 		91414BD8887A9299F2C1172C /* GenericMethods4.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = GenericMethods4.cpp; path = Classes/Native/GenericMethods4.cpp; sourceTree = SOURCE_ROOT; };
 		918B4D4F9ECEFF4EE2170695 /* Il2CppGenericMethodPointerTable.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Il2CppGenericMethodPointerTable.cpp; path = Classes/Native/Il2CppGenericMethodPointerTable.cpp; sourceTree = SOURCE_ROOT; };
 		92CB4BD9A16B9E951042227B /* UnityEngine.ParticleSystemModule.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = UnityEngine.ParticleSystemModule.cpp; path = Classes/Native/UnityEngine.ParticleSystemModule.cpp; sourceTree = SOURCE_ROOT; };
+		9353CD62275B48EA0022CE0B /* MainShoesAnalysis.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainShoesAnalysis.h; sourceTree = "<group>"; };
+		9353CD63275B48EA0022CE0B /* MainShoesAnalysis.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MainShoesAnalysis.mm; sourceTree = "<group>"; };
+		9353CD65275B493E0022CE0B /* ViceShoesAnalysis.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViceShoesAnalysis.h; sourceTree = "<group>"; };
+		9353CD66275B493E0022CE0B /* ViceShoesAnalysis.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViceShoesAnalysis.m; sourceTree = "<group>"; };
+		936820C7276201B2007B4D6B /* BigFoot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BigFoot.h; path = ../../../../shoe_sdk_c/BigFoot.h; sourceTree = "<group>"; };
+		936820C8276201B2007B4D6B /* BigFoot.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BigFoot.cpp; path = ../../../../shoe_sdk_c/BigFoot.cpp; sourceTree = "<group>"; };
 		93FA54ED2750E1EE00AEAD33 /* TXCarouselCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TXCarouselCollectionViewCell.xib; sourceTree = "<group>"; };
 		93FA54EE2750E1EE00AEAD33 /* TXCarouselViewLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TXCarouselViewLayout.h; sourceTree = "<group>"; };
 		93FA54EF2750E1EE00AEAD33 /* ShoesCarouselView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShoesCarouselView.h; sourceTree = "<group>"; };
@@ -1595,6 +1606,10 @@
 			children = (
 				93FA55092750E1EE00AEAD33 /* BTDataProcess.h */,
 				93FA550A2750E1EE00AEAD33 /* BTDataProcess.mm */,
+				9353CD62275B48EA0022CE0B /* MainShoesAnalysis.h */,
+				9353CD63275B48EA0022CE0B /* MainShoesAnalysis.mm */,
+				9353CD65275B493E0022CE0B /* ViceShoesAnalysis.h */,
+				9353CD66275B493E0022CE0B /* ViceShoesAnalysis.m */,
 				93FA550C2750E1EE00AEAD33 /* CBPeripheral+ADName.h */,
 				93FA55072750E1EE00AEAD33 /* CBPeripheral+ADName.m */,
 				93FA55082750E1EE00AEAD33 /* LEONBLManager.h */,
@@ -1663,6 +1678,8 @@
 		93FA55282750E1EE00AEAD33 /* shoes_sdk */ = {
 			isa = PBXGroup;
 			children = (
+				936820C8276201B2007B4D6B /* BigFoot.cpp */,
+				936820C7276201B2007B4D6B /* BigFoot.h */,
 				93FA552A2750E1EE00AEAD33 /* DanceFoot.cpp */,
 				93FA55362750E1EE00AEAD33 /* DanceFoot.h */,
 				93FA553D2750E1EE00AEAD33 /* DanceGame.cpp */,
@@ -1863,6 +1880,7 @@
 				93FA55E62750E1EE00AEAD33 /* InertialTrajProcess.h in Headers */,
 				93FA55D62750E1EE00AEAD33 /* OriginTraj.h in Headers */,
 				93FA55E12750E1EE00AEAD33 /* FootStep.h in Headers */,
+				936820C9276201B2007B4D6B /* BigFoot.h in Headers */,
 				93FA55B32750E1EE00AEAD33 /* MBProgressHUD.h in Headers */,
 				93FA55CD2750E1EE00AEAD33 /* MonsterH5.h in Headers */,
 				93FA55D02750E1EE00AEAD33 /* RunGame.h in Headers */,
@@ -2175,6 +2193,7 @@
 				93FA55F02750E1EF00AEAD33 /* RunGame.cpp in Sources */,
 				93FA55C22750E1EE00AEAD33 /* AFURLSessionManager.m in Sources */,
 				93FA55C92750E1EE00AEAD33 /* AFSecurityPolicy.m in Sources */,
+				9353CD67275B493E0022CE0B /* ViceShoesAnalysis.m in Sources */,
 				93FA55DF2750E1EE00AEAD33 /* Tricycle.cpp in Sources */,
 				93FA559E2750E1EE00AEAD33 /* NoDeviceTip.m in Sources */,
 				93FA56632750E1EF00AEAD33 /* UIView+ST.m in Sources */,
@@ -2189,6 +2208,7 @@
 				93FA55BD2750E1EE00AEAD33 /* AFURLResponseSerialization.m in Sources */,
 				93FA55AA2750E1EE00AEAD33 /* LEONBLManager.m in Sources */,
 				93FA55D92750E1EE00AEAD33 /* Interaction.cpp in Sources */,
+				936820CA276201B2007B4D6B /* BigFoot.cpp in Sources */,
 				93FA55E82750E1EF00AEAD33 /* DanceGame.cpp in Sources */,
 				93FA55CE2750E1EE00AEAD33 /* DanceFoot.cpp in Sources */,
 				93FA56592750E1EF00AEAD33 /* UIColor+Hex.m in Sources */,
@@ -2199,6 +2219,7 @@
 				93FA55EE2750E1EF00AEAD33 /* OriginTraj.cpp in Sources */,
 				93FA55C72750E1EE00AEAD33 /* AFNetworkReachabilityManager.m in Sources */,
 				93FA55902750E1EE00AEAD33 /* TXCarouselViewLayout.m in Sources */,
+				9353CD64275B48EA0022CE0B /* MainShoesAnalysis.mm in Sources */,
 				93FA55862750E1EE00AEAD33 /* TXCarouselCellModel.m in Sources */,
 				93FA55A82750E1EE00AEAD33 /* BTDataProcess.mm in Sources */,
 				93FA55E42750E1EE00AEAD33 /* RuinsExplore.cpp in Sources */,
@@ -2427,6 +2448,7 @@
 				02A348E8BBAF57C87E6D26F0 /* QFramework.TypeEventSystem_CodeGen.c in Sources */,
 				65614303949651223559F812 /* QFramework.UIKit.cpp in Sources */,
 				D6514916B0DBABBEB7525B42 /* QFramework.UIKit_CodeGen.c in Sources */,
+				936820CB276201B2007B4D6B /* BigFoot.cpp in Sources */,
 				945F488DABC9734CAE1874BF /* System.Configuration.cpp in Sources */,
 				6F524710B89E0CE58E8D0A4E /* System.Configuration_CodeGen.c in Sources */,
 				93FA55CA2750E1EE00AEAD33 /* AFSecurityPolicy.m in Sources */,

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


+ 6 - 0
RunGame/Unity-iPhone.xcodeproj/xcuserdata/duowan123.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Bucket
+   uuid = "21EDB339-9027-495D-8073-23518ABD2CBC"
+   type = "1"
+   version = "2.0">
+</Bucket>