app_client_dataupdate.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "system.h"
  2. #include "app_client_dataupdate.h"
  3. #include "hal_ble_client.h"
  4. #include "hal_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. // uint32_t press = 0;
  19. sd_temp_get(&temperature);
  20. temperature = temperature>>2;
  21. // press = IMU_GetPressRAW(); //获取压力
  22. // SEGGER_RTT_printf(0,"temperature=%d\n",temperature);
  23. // SEGGER_RTT_printf(0,"press=%d\n",press);
  24. //子命令
  25. buf[L++] = BLE_Client_T_UPDATE_DATA;
  26. //左鞋
  27. buf[L++] = GetBatteryPersent();
  28. buf[L++] = (uint8_t)temperature;
  29. // buf[L++] = (uint8_t)(press>>24);
  30. // buf[L++] = (uint8_t)(press>>16);
  31. // buf[L++] = (uint8_t)(press>>8);
  32. // buf[L++] = (uint8_t)(press>>0);
  33. buf[L++] = 0;
  34. buf[L++] = 0;
  35. buf[L++] = 0;
  36. buf[L++] = 0;
  37. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>24);
  38. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>16);
  39. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>8);
  40. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>0);
  41. //右鞋
  42. buf[L++] = app_host_GetVol_R();
  43. buf[L++] = app_host_GetTemp_R();
  44. buf[L++] = (uint8_t)(app_host_GetPress_R()>>24);
  45. buf[L++] = (uint8_t)(app_host_GetPress_R()>>16);
  46. buf[L++] = (uint8_t)(app_host_GetPress_R()>>8);
  47. buf[L++] = (uint8_t)(app_host_GetPress_R()>>0);
  48. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[1]>>24);
  49. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[1]>>16);
  50. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[1]>>8);
  51. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[1]>>0);
  52. BLE_Client_Tx_Send(0,BLE_Client_T_UPDATE,buf,L);
  53. }