created separate function for hex to char
Dependencies: SDFileSystem ds3231 eeprom_Nikita mbed testUniGraphic_150217
Fork of SS_SensePOC2P0_11Dec2017_USERPID by
Diff: main.cpp
- Revision:
- 70:f2e544a5645b
- Parent:
- 69:128e3b467820
- Child:
- 71:8f1851c556d6
--- a/main.cpp Thu Nov 23 12:11:46 2017 +0000 +++ b/main.cpp Thu Nov 30 10:25:19 2017 +0000 @@ -739,8 +739,20 @@ poc2p0_device_msg_res.chksum = checksum_struct((uint8_t *)&poc2p0_device_msg_res.cmd, (sizeof(poc2p0_device_msg_res)-1)); - send_thru_terminal(device_res_buffer,DEVICE_RES_LEN,(uint8_t *)&poc2p0_device_msg_res,sizeof(poc2p0_device_msg_res)); + //send_thru_terminal(device_res_buffer,DEVICE_RES_LEN,(uint8_t *)&poc2p0_device_msg_res,sizeof(poc2p0_device_msg_res)); + blue1.printf("%02x",poc2p0_device_msg_res.sos); + blue1.printf("%02x",poc2p0_device_msg_res.cmd); + blue1.printf("%02x",poc2p0_device_msg_res.length); + blue1.printf("%02x",poc2p0_device_msg_res.eos); + blue1.printf("%02x",poc2p0_device_msg_res.chksum); + blue1.printf("\n"); + gc.printf("%02x",poc2p0_device_msg_res.sos); + gc.printf("%02x",poc2p0_device_msg_res.cmd); + gc.printf("%02x",poc2p0_device_msg_res.length); + gc.printf("%02x",poc2p0_device_msg_res.eos); + gc.printf("%02x",poc2p0_device_msg_res.chksum); + gc.printf("\n"); } // this command response to heartbeat message request send by bluetooth device @@ -770,15 +782,15 @@ memcpy(poc2p0_device_heartbeat_res.pid,get_userpid(),sizeof(poc2p0_device_heartbeat_res.pid)); gc.printf("poc2p0_device_heartbeat_res.pid = %s\n",poc2p0_device_heartbeat_res.pid); - ascii_to_hex((const char *)poc2p0_device_heartbeat_res.pid, sizeof(poc2p0_device_heartbeat_res.pid)); + //ascii_to_hex((const char *)poc2p0_device_heartbeat_res.pid, sizeof(poc2p0_device_heartbeat_res.pid)); //gc.printf("poc2p0_device_heartbeat_res.pid = %2x\n",poc2p0_device_heartbeat_res.pid); - gc.printf("\n"); + //gc.printf("\n"); - for (uint8_t i = 0; i < sizeof(poc2p0_device_heartbeat_res.pid); i++) - { - gc.printf("%02x",poc2p0_device_heartbeat_res.pid[i]); - } - gc.printf("\n"); + //for (uint8_t i = 0; i < sizeof(poc2p0_device_heartbeat_res.pid); i++) + //{ + // gc.printf("%02x",poc2p0_device_heartbeat_res.pid[i]); + //} + //gc.printf("\n"); //poc2p0_device_heartbeat_res.pid = pid; } else @@ -815,8 +827,40 @@ // calculate chksum poc2p0_device_heartbeat_res.chksum = checksum_struct((uint8_t *)&poc2p0_device_heartbeat_res.cmd, (sizeof(poc2p0_device_heartbeat_res)-1)); - send_thru_terminal(heartbeat_res_buffer,HEARTBEAT_RES_LEN,(uint8_t *)&poc2p0_device_heartbeat_res,sizeof(poc2p0_device_heartbeat_res)); + //send_thru_terminal(heartbeat_res_buffer,HEARTBEAT_RES_LEN,(uint8_t *)&poc2p0_device_heartbeat_res,sizeof(poc2p0_device_heartbeat_res)); + blue1.printf("%02x",poc2p0_device_heartbeat_res.sos); + blue1.printf("%02x",poc2p0_device_heartbeat_res.cmd); + blue1.printf("%02x",poc2p0_device_heartbeat_res.length); + blue1.printf("%02x",poc2p0_device_heartbeat_res.did); + blue1.printf("%08x",poc2p0_device_heartbeat_res.pid); + blue1.printf("%02x",poc2p0_device_heartbeat_res.date_time.date); + blue1.printf("%02x",poc2p0_device_heartbeat_res.date_time.month); + blue1.printf("%02x",poc2p0_device_heartbeat_res.date_time.year); + blue1.printf("%02x",poc2p0_device_heartbeat_res.date_time.hour); + blue1.printf("%02x",poc2p0_device_heartbeat_res.date_time.mins); + blue1.printf("%02x",poc2p0_device_heartbeat_res.date_time.sec); + blue1.printf("%02x",poc2p0_device_heartbeat_res.device_state); + blue1.printf("%02x",poc2p0_device_heartbeat_res.battery_status); + blue1.printf("%02x",poc2p0_device_heartbeat_res.eos); + blue1.printf("%02x",poc2p0_device_heartbeat_res.chksum); + blue1.printf("\n"); + gc.printf("%02x",poc2p0_device_heartbeat_res.sos); + gc.printf("%02x",poc2p0_device_heartbeat_res.cmd); + gc.printf("%02x",poc2p0_device_heartbeat_res.length); + gc.printf("%02x",poc2p0_device_heartbeat_res.did); + gc.printf("%08x",poc2p0_device_heartbeat_res.pid); + gc.printf("%02x",poc2p0_device_heartbeat_res.date_time.date); + gc.printf("%02x",poc2p0_device_heartbeat_res.date_time.month); + gc.printf("%02x",poc2p0_device_heartbeat_res.date_time.year); + gc.printf("%02x",poc2p0_device_heartbeat_res.date_time.hour); + gc.printf("%02x",poc2p0_device_heartbeat_res.date_time.mins); + gc.printf("%02x",poc2p0_device_heartbeat_res.date_time.sec); + gc.printf("%02x",poc2p0_device_heartbeat_res.device_state); + gc.printf("%02x",poc2p0_device_heartbeat_res.battery_status); + gc.printf("%02x",poc2p0_device_heartbeat_res.eos); + gc.printf("%02x",poc2p0_device_heartbeat_res.chksum); + gc.printf("\n"); } // this command send final test result response to bluetooth device @@ -837,8 +881,23 @@ poc2p0_device_tst_result_res.chksum = checksum_struct((uint8_t *)&poc2p0_device_tst_result_res.cmd, (sizeof(poc2p0_device_tst_result_res)-1)); - send_thru_terminal(test_res_buffer,TEST_RES_LEN,(uint8_t *)&poc2p0_device_tst_result_res,sizeof(poc2p0_device_tst_result_res)); - + //send_thru_terminal(test_res_buffer,TEST_RES_LEN,(uint8_t *)&poc2p0_device_tst_result_res,sizeof(poc2p0_device_tst_result_res)); + + blue1.printf("%02x",poc2p0_device_tst_result_res.sos); + blue1.printf("%02x",poc2p0_device_tst_result_res.cmd); + blue1.printf("%02x",poc2p0_device_tst_result_res.length); + blue1.printf("%08x",poc2p0_device_tst_result_res.test_result); + blue1.printf("%02x",poc2p0_device_tst_result_res.eos); + blue1.printf("%02x",poc2p0_device_tst_result_res.chksum); + blue1.printf("\n"); + + gc.printf("%02x",poc2p0_device_tst_result_res.sos); + gc.printf("%02x",poc2p0_device_tst_result_res.cmd); + gc.printf("%02x",poc2p0_device_tst_result_res.length); + gc.printf("%08x",poc2p0_device_tst_result_res.test_result); + gc.printf("%02x",poc2p0_device_tst_result_res.eos); + gc.printf("%02x",poc2p0_device_tst_result_res.chksum); + gc.printf("\n"); } static void send_thru_terminal(uint8_t input_buf[],uint8_t len_buff,uint8_t struct_data[],uint8_t len_struct)