app_client.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "system.h"
  2. #include "app_client.h"
  3. #include "hal_ble_client.h"
  4. #include "hal_ble_host.h"
  5. #include "bsp_time.h"
  6. #include "hal_led.h"
  7. #include "ble_gap.h"
  8. #include "hal_flash.h"
  9. #include "app_client_step.h"
  10. #include "app_client_infomation.h"
  11. #include "app_client_dataupdate.h"
  12. //>> 0xA1: 查询
  13. void cb_BLE_Client_R_UPDATE(void* handle)
  14. {
  15. BLE_Client_Rx_t *target = handle;
  16. uint8_t _cmd = target->pDat[0];
  17. switch(_cmd){
  18. case BLE_Client_R_UPDATE_BASEINFO:{
  19. //>> 0(设备基本信息): 开始时间ms(8)
  20. //<< 0(子命令): 设备型号(64)+左鞋蓝牙地址(6)+硬件版本(2)+软件版本(2)+右鞋蓝牙地址(6)+硬件版本(6)+软件版本(2)
  21. //>> AA 06 F9 A1 00 4A
  22. //<< AA 55 AA A1 00 53 4D 41 52 54 20 53 48 4F 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C1 EB D0 E3 87 47 01 00 01 00 00 00 00 00 00 4F
  23. app_client_infomation_Send();
  24. break;}
  25. case BLE_Client_R_UPDATE_DATA:{
  26. //>> 1(设备数据)
  27. //<< 1(子命令): 左鞋电量(1)+左鞋温度(1)+左鞋压力(4)+左鞋步数(4)+右鞋电量(1)+右鞋温度(1)+右鞋压力(4)+右鞋步数(4)
  28. app_client_DataUpdate_Send();
  29. break;}
  30. case BLE_Client_R_UPDATE_STEPNUM:{
  31. //>> 2(查询步数): 包序号[0全部](2)
  32. //<< 2(查询步数): +开始时间ms(8)+包的数量(2)+包序号(2)+每小时步数(2)+...
  33. app_client_SendStep(target);
  34. break;}
  35. case BLE_Client_R_UPDATE_STEPNUM_CLERA:{
  36. //>> 3(删除步数): 开始时间ms(8)+距离上一个整点的分钟数(1)
  37. //<< 3(删除步数): 开始时间ms(8)+距离上一个整点的分钟数(1)
  38. BLE_Client_Tx_Send(0,BLE_Client_T_UPDATE,target->pDat,target->datLen);
  39. app_client_DeleteStep(target);
  40. break;}
  41. default:break;
  42. }
  43. }
  44. void app_client_Initialize(void)
  45. {
  46. BLE_Client_Rx_Regist(BLE_Client_R_UPDATE,cb_BLE_Client_R_UPDATE);
  47. app_client_step_Initialize();
  48. }