app_data_transfer.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*Includes ----------------------------------------------*/
  2. #include "system.h"
  3. #include "ble_comm.h"
  4. #include "bsp_time.h"
  5. #include "hal_ble_client.h"
  6. #include "hal_ble_common.h"
  7. #include "hal_ser_imu_mode_manage.h"
  8. #include "app_flash.h"
  9. #include "app_game.h"
  10. #include "app_data_transfer.h"
  11. /*Local Functions ------------------------------------------------------------------------------------------------------------------------------------*/
  12. static void app_data_transfer_Process(void)
  13. {
  14. static uint32_t tim = 0;
  15. static uint32_t tim2 = 0;
  16. if(hal_ser_imu_mode_manage_get_ready(HAL_SER_IMU_MODE_MANAGE_GAME) || \
  17. hal_ser_imu_mode_manage_get_ready(HAL_SER_IMU_MODE_MANAGE_REALSTEP))
  18. {
  19. if(TIME_GetTicks()-tim>=500){tim = TIME_GetTicks();
  20. if( 0 == slave_isconnect())advertising_start();
  21. if(mFlash.isHost && 0 == host_isconnect())scan_start();
  22. }
  23. if(TIME_GetTicks()-tim2>=FullPower_Interval){tim2 = TIME_GetTicks();
  24. IMU_Dtalige();
  25. }
  26. }
  27. }
  28. /*API -------------------------------------------------------*/
  29. /**
  30. @brief 初始化数据传输应用
  31. @param 无
  32. @return 错误代码 - [out] -1失败,0成功
  33. */
  34. int app_data_transfer_Init(void)
  35. {
  36. //设置数据传输线程
  37. Process_Start(0,"app_data_transfer_Process",app_data_transfer_Process);
  38. return 0;
  39. }
  40. /**
  41. @brief 将旧版本的IMU_SetSlaveData(uint8_t* pdat,uint8_t len)写在这里
  42. @param pdat 略
  43. @param len 略
  44. @return 无
  45. */
  46. void app_data_transfer_set_SlaveData(uint8_t* pdat,uint8_t len)
  47. {
  48. if(pdat[3]==BLE_TRACK){
  49. IMU_Rec_data(pdat,len);
  50. }
  51. app_game_SetClientGameMode();
  52. }
  53. void send_protocol(uint8_t index,uint8_t cmd,uint8_t* p,uint8_t datLen)
  54. {
  55. BLE_Client_Tx_Send(0,(BLE_CMD_n)cmd,p,datLen);
  56. }