app_client_dataupdate.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "system.h"
  2. #include "app_client_dataupdate.h"
  3. #include "hal_ble_client.h"
  4. #include "app_flash.h"
  5. #include "bsp_time.h"
  6. #include "system.h"
  7. #include "app_host.h"
  8. #include "app_step.h"
  9. #include "hal_battery.h"
  10. #include "hal_imu.h"
  11. void app_client_DataUpdate_Send(void)
  12. {
  13. //>> 1(设备数据)
  14. //<< 1(子命令): 左鞋电量(1)+左鞋温度(1)+左鞋压力(4)+左鞋步数(4)+右鞋电量(1)+右鞋温度(1)+右鞋压力(4)+右鞋步数(4)
  15. uint8_t buf[32];
  16. uint8_t L=0;
  17. int32_t temperature;
  18. sd_temp_get(&temperature);
  19. temperature = temperature>>2;
  20. // SEGGER_RTT_printf(0,"temperature=%d\n",temperature);
  21. // SEGGER_RTT_printf(0,"press=%d\n",press);
  22. //子命令
  23. buf[L++] = BLE_Client_T_UPDATE_DATA;
  24. //左鞋
  25. buf[L++] = GetBatteryPersent();
  26. buf[L++] = (uint8_t)temperature;
  27. //压力数据
  28. buf[L++] = 0;
  29. buf[L++] = 0;
  30. buf[L++] = 0;
  31. buf[L++] = 0;
  32. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>24);
  33. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>16);
  34. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>8);
  35. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>0);
  36. //右鞋
  37. buf[L++] = app_host_GetVol_R();
  38. buf[L++] = app_host_GetTemp_R();
  39. buf[L++] = (uint8_t)(app_host_GetPress_R()>>24);
  40. buf[L++] = (uint8_t)(app_host_GetPress_R()>>16);
  41. buf[L++] = (uint8_t)(app_host_GetPress_R()>>8);
  42. buf[L++] = (uint8_t)(app_host_GetPress_R()>>0);
  43. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[1]>>24);
  44. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[1]>>16);
  45. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[1]>>8);
  46. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[1]>>0);
  47. BLE_Client_Tx_Send(0,BLE_UPDATE,buf,L);
  48. }