app_client_dataupdate.c 1.5 KB

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