app_losspack.c 760 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "app_losspack.h"
  2. #include "bsp_time.h"
  3. #include "app_flash.h"
  4. #include "system.h"
  5. #include "hal_ble_client.h"
  6. #include "ble_comm.h"
  7. #include "app_game.h"
  8. #if LOSSPACK_ENANBLE
  9. uint16_t lose_pack_all =0;
  10. void LossPack_process(void){
  11. if(!mFlash.isHost)return;
  12. if(app_game_GetGameMode()){
  13. uint16_t pack_l =0;
  14. uint8_t rssi = 0-host_get_rssi();
  15. pack_l = lose_pack_all;
  16. uint8_t buf[8];
  17. uint8_t L = 0;
  18. buf[L++] = (uint8_t)(pack_l>>8);
  19. buf[L++] = (uint8_t)(pack_l);
  20. buf[L++] = (uint8_t)(rssi);
  21. BLE_Client_Tx_Send(0,(BLE_CMD_n)0x03,buf,L);
  22. // DEBUG_LOG("lose_pack_all:%d, h_rssi=%d\r\n",lose_pack_all,rssi);
  23. lose_pack_all = 0;
  24. }
  25. }
  26. void app_losspack_Init(void)
  27. {
  28. Process_Start(1000,"LossPack",LossPack_process);
  29. }
  30. #endif