app_client_infomation.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include "system.h"
  2. #include "app_client_infomation.h"
  3. #include "app_flash.h"
  4. #include "bsp_time.h"
  5. #include "system.h"
  6. #include "app_host.h"
  7. #include "app_step.h"
  8. #include "hal_ble_client.h"
  9. #include "ble_gap.h"
  10. void app_client_infomation_Send_defineName(uint8_t name[],uint8_t lenth)
  11. {
  12. //<< 0(设备基本信息): 设备型号(64)+左鞋蓝牙地址(6)+硬件版本(2)+软件版本(2)+左鞋蓝牙地址(6)+硬件版本(6)+软件版本(2)
  13. ble_gap_addr_t mAddr;
  14. uint32_t err_code;
  15. uint8_t buf[128];
  16. uint8_t L = SHOES_NAME_LEN+1;
  17. memset(buf,0,sizeof(buf));
  18. //子命令
  19. buf[0] = BLE_Client_T_UPDATE_BASEINFO;
  20. //设备名称
  21. for(int i=0;i<lenth;i++){
  22. buf[i+1] = name[i];
  23. }
  24. //MAC 地址
  25. err_code = sd_ble_gap_addr_get(&mAddr); APP_ERROR_CHECK(err_code);
  26. //SEGGER_RTT_printf(0,"mac addr:");for(int i=0;i<6;i++){SEGGER_RTT_printf(0,"%02X ",mAddr.addr[i]);}SEGGER_RTT_printf(0,"\n");
  27. for(int i=0;i<6;i++){
  28. buf[L++] = mAddr.addr[5-i];
  29. }
  30. //硬件版本
  31. buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>8);
  32. buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>0);
  33. //软件版本
  34. buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>8);
  35. buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>0);
  36. //右鞋mac地址
  37. for(int i=0;i<6;i++) buf[L++] = mFlash.mClient.macAddr[i];
  38. //右鞋硬件版本
  39. //buf[L++] = (uint8_t)(mFlash.mClient.hardVersion>>8);
  40. //buf[L++] = (uint8_t)(mFlash.mClient.hardVersion>>0);
  41. buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>8);
  42. buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>0);
  43. //右鞋软件版本
  44. buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>8);
  45. buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>0);
  46. BLE_Client_Tx_Send(0,BLE_UPDATE,buf,L);
  47. }
  48. void app_client_infomation_Send(void)
  49. {
  50. //<< 0(设备基本信息): 设备型号(64)+左鞋蓝牙地址(6)+硬件版本(2)+软件版本(2)+左鞋蓝牙地址(6)+硬件版本(6)+软件版本(2)
  51. ble_gap_addr_t mAddr;
  52. uint32_t err_code;
  53. uint8_t buf[128];
  54. uint8_t L = SHOES_NAME_LEN+1;
  55. memset(buf,0,sizeof(buf));
  56. //子命令
  57. buf[0] = BLE_Client_T_UPDATE_BASEINFO;
  58. //设备名称
  59. for(int i=0;i<sizeof(SHOES_NAME);i++){
  60. buf[i+1] = SHOES_NAME[i];
  61. }
  62. //MAC 地址
  63. err_code = sd_ble_gap_addr_get(&mAddr); APP_ERROR_CHECK(err_code);
  64. // SEGGER_RTT_printf(0,"mac addr:");for(int i=0;i<6;i++){SEGGER_RTT_printf(0,"%02X ",mAddr.addr[i]);}SEGGER_RTT_printf(0,"\n");
  65. for(int i=0;i<6;i++){
  66. buf[L++] = mAddr.addr[5-i];
  67. }
  68. //硬件版本
  69. buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>8);
  70. buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>0);
  71. //软件版本
  72. buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>8);
  73. buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>0);
  74. //右鞋mac地址
  75. for(int i=0;i<6;i++) buf[L++] = mFlash.mClient.macAddr[i];
  76. // SEGGER_RTT_printf(0,"mac addr:");for(int i=0;i<6;i++){SEGGER_RTT_printf(0,"%02X ",mFlash.mClient.macAddr[i]);}SEGGER_RTT_printf(0,"\n");
  77. //右鞋硬件版本
  78. //buf[L++] = (uint8_t)(mFlash.mClient.hardVersion>>8);
  79. //buf[L++] = (uint8_t)(mFlash.mClient.hardVersion>>0);
  80. buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>8);
  81. buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>0);
  82. //右鞋软件版本
  83. buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>8);
  84. buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>0);
  85. BLE_Client_Tx_Send(0,BLE_UPDATE,buf,L);
  86. }