/*Includes ----------------------------------------------*/ #include "system.h" #include "ble_comm.h" #include "bsp_time.h" #include "hal_ble_host.h" #include "hal_ble_client.h" #include "hal_ble_common.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; static uint8_t flag = 0; //全功率模式 if(app_game_GetGameMode() || app_step_Real_Get()) { if(!flag){flag =1; Process_SetHoldOn(app_data_transfer_Process,1); } if(TIME_GetTicks()-tim>=500){tim = TIME_GetTicks(); if( 0 == slave_isconnect()){ // DEBUG_LOG("app_data_transfer_Process advertising_start\r\n"); advertising_stop(); advertising_start(); } if(mFlash.isHost && 0 == host_isconnect())scan_start(); } if(TIME_GetTicks()-tim2>=3){tim2 = TIME_GetTicks(); IMU_Dtalige(); } } else{ if(flag){flag =0; Process_SetHoldOn(app_data_transfer_Process,0); } } } /*API -------------------------------------------------------*/ /** @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(); } /** @brief 初始化数据传输应用 @param 无 @return 错误代码 - [out] -1失败,0成功 */ int app_data_transfer_Init(void) { //设置数据传输线程 Process_Start(0,"app_data_transfer_Process",app_data_transfer_Process); BLE_Host_Rx_Regist_Game(app_data_transfer_set_SlaveData); return 0; } 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); }