123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /*Includes ----------------------------------------------*/
- #include "system.h"
- #include "ble_comm.h"
- #include "bsp_time.h"
- #include "hal_ble_client.h"
- #include "hal_ble_common.h"
- #include "hal_ser_imu_mode_manage.h"
- #include "app_flash.h"
- #include "app_game.h"
- #include "app_data_transfer.h"
-
- /*Local Functions ------------------------------------------------------------------------------------------------------------------------------------*/
- static void app_data_transfer_Process(void)
- {
- static uint32_t tim = 0;
- static uint32_t tim2 = 0;
-
- if(hal_ser_imu_mode_manage_get_ready(HAL_SER_IMU_MODE_MANAGE_GAME) || \
- hal_ser_imu_mode_manage_get_ready(HAL_SER_IMU_MODE_MANAGE_REALSTEP))
- {
- if(TIME_GetTicks()-tim>=500){tim = TIME_GetTicks();
- if( 0 == slave_isconnect())advertising_start();
- if(mFlash.isHost && 0 == host_isconnect())scan_start();
- }
- if(TIME_GetTicks()-tim2>=FullPower_Interval){tim2 = TIME_GetTicks();
- IMU_Dtalige();
- }
- }
- }
- /*API -------------------------------------------------------*/
- /**
- @brief 初始化数据传输应用
- @param 无
- @return 错误代码 - [out] -1失败,0成功
- */
- int app_data_transfer_Init(void)
- {
- //设置数据传输线程
- Process_Start(0,"app_data_transfer_Process",app_data_transfer_Process);
-
- return 0;
- }
- /**
- @brief 将旧版本的IMU_SetSlaveData(uint8_t* pdat,uint8_t len)写在这里
- @param pdat 略
- @param len 略
- @return 无
- */
- void app_data_transfer_set_SlaveData(uint8_t* pdat,uint8_t len)
- {
- if(pdat[3]==BLE_TRACK){
- IMU_Rec_data(pdat,len);
- }
- app_game_SetClientGameMode();
- }
-
- void send_protocol(uint8_t index,uint8_t cmd,uint8_t* p,uint8_t datLen)
- {
- BLE_Client_Tx_Send(0,(BLE_CMD_n)cmd,p,datLen);
- }
|