123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #include "system.h"
- #include "app_client_infomation.h"
- #include "hal_flash.h"
- #include "bsp_time.h"
- #include "system.h"
- #include "app_host.h"
- #include "app_step.h"
- #include "hal_ble_client.h"
- #include "ble_gap.h"
- void app_client_infomation_Send_defineName(uint8_t name[],uint8_t lenth)
- {
- //<< 0(设备基本信息): 设备型号(64)+左鞋蓝牙地址(6)+硬件版本(2)+软件版本(2)+左鞋蓝牙地址(6)+硬件版本(6)+软件版本(2)
- ble_gap_addr_t mAddr;
- uint32_t err_code;
- uint8_t buf[128];
- uint8_t L = SHOES_NAME_LEN+1;
-
- memset(buf,0,sizeof(buf));
- //子命令
- buf[0] = BLE_Client_T_UPDATE_BASEINFO;
- //设备名称
- for(int i=0;i<lenth;i++){
- buf[i+1] = name[i];
- }
- //MAC 地址
- err_code = sd_ble_gap_addr_get(&mAddr); APP_ERROR_CHECK(err_code);
- //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");
- for(int i=0;i<6;i++){
- buf[L++] = mAddr.addr[5-i];
- }
- //硬件版本
- buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>8);
- buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>0);
- //软件版本
- buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>8);
- buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>0);
-
- //右鞋mac地址
- for(int i=0;i<6;i++) buf[L++] = mFlash.mClient.macAddr[i];
-
- //右鞋硬件版本
- //buf[L++] = (uint8_t)(mFlash.mClient.hardVersion>>8);
- //buf[L++] = (uint8_t)(mFlash.mClient.hardVersion>>0);
- buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>8);
- buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>0);
- //右鞋软件版本
- buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>8);
- buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>0);
-
- BLE_Client_Tx_Send(0,BLE_Client_T_UPDATE,buf,L);
- }
- void app_client_infomation_Send(void)
- {
- //<< 0(设备基本信息): 设备型号(64)+左鞋蓝牙地址(6)+硬件版本(2)+软件版本(2)+左鞋蓝牙地址(6)+硬件版本(6)+软件版本(2)
- ble_gap_addr_t mAddr;
- uint32_t err_code;
- uint8_t buf[128];
- uint8_t L = SHOES_NAME_LEN+1;
-
- memset(buf,0,sizeof(buf));
- //子命令
- buf[0] = BLE_Client_T_UPDATE_BASEINFO;
- //设备名称
- for(int i=0;i<sizeof(SHOES_NAME);i++){
- buf[i+1] = SHOES_NAME[i];
- }
- //MAC 地址
- err_code = sd_ble_gap_addr_get(&mAddr); APP_ERROR_CHECK(err_code);
- // 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");
- for(int i=0;i<6;i++){
- buf[L++] = mAddr.addr[5-i];
- }
- //硬件版本
- buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>8);
- buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>0);
- //软件版本
- buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>8);
- buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>0);
-
- //右鞋mac地址
- for(int i=0;i<6;i++) buf[L++] = mFlash.mClient.macAddr[i];
-
- //右鞋硬件版本
- //buf[L++] = (uint8_t)(mFlash.mClient.hardVersion>>8);
- //buf[L++] = (uint8_t)(mFlash.mClient.hardVersion>>0);
- buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>8);
- buf[L++] = (uint8_t)((uint16_t)HARDWARE_VERSION>>0);
- //右鞋软件版本
- buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>8);
- buf[L++] = (uint8_t)((uint16_t)SOFTWARE_VERSION>>0);
-
- BLE_Client_Tx_Send(0,BLE_Client_T_UPDATE,buf,L);
- }
|