diff --git a/host_tasks.c b/host_tasks.c index 3b4bd5c..8dc60a3 100644 --- a/host_tasks.c +++ b/host_tasks.c @@ -174,8 +174,22 @@ static void on_ins_connect(ins_connect_t *p_ins) static void on_ins_write_char(ins_write_char_t *p_ins) { - NRF_LOG_INFO("write handle: 0x%02X", p_ins->handle); uint16_t write_size = p_ins->len - sizeof(p_ins->handle) - 1; + NRF_LOG_INFO("write handle: 0x%02X", p_ins->handle); + { + uint8_t *p_start = (void *)p_ins->write_data; + uint32_t loop = write_size / 8; + uint32_t remain = write_size % 8; + for (int i = 0; i < loop; i++) + { + NRF_LOG_HEXDUMP_INFO(p_start, 8); + p_start += 8; + } + if (remain) + { + NRF_LOG_HEXDUMP_INFO(p_start, remain); + } + } extern ret_code_t le_gatt_c_write_req(uint32_t handle, void *, uint16_t); ret_code_t err_code = le_gatt_c_write_req(p_ins->handle, p_ins->write_data, write_size); @@ -202,22 +216,38 @@ static void on_ins_survive(ins_survive_t *p_ins) success_ack(); } -typedef struct -{ - uint16_t rsp_code; - union - { - uint8_t len; - uint8_t payload[256]; - }; -} __PACKED read_char_rsp_t; - -read_char_rsp_t read_char_rsp; void host_read_char_cb(uint8_t *p_data, uint16_t len) { - read_char_rsp.rsp_code = 0x0004; - memcpy(&read_char_rsp.len, p_data, len); - uart_drv_tx(&read_char_rsp, offsetof(read_char_rsp_t, payload) + len); + static union + { + struct + { + uint16_t rsp_code; + uint8_t payload[]; + }; + uint8_t arr[256]; + } read_char_rsp = { + .rsp_code = 0x0004 + }; + + memcpy(read_char_rsp.payload, p_data, len); + + uart_drv_tx(&read_char_rsp, sizeof(read_char_rsp.rsp_code) + len); + + { + uint8_t *p_start = p_data; + uint32_t loop = len / 8; + uint32_t remain = len % 8; + for (int i = 0; i < loop; i++) + { + NRF_LOG_HEXDUMP_INFO(p_start, 8); + p_start += 8; + } + if (remain) + { + NRF_LOG_HEXDUMP_INFO(p_start, remain); + } + } } typedef struct