From 8dbb3e4e8179f2a64be3b093878f68dbf93a30ac Mon Sep 17 00:00:00 2001 From: zhaohe Date: Tue, 2 Jul 2024 20:40:29 +0800 Subject: [PATCH] update --- app/src/protocol_utils.c | 24 ++++++++++++------------ protocol | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/protocol_utils.c b/app/src/protocol_utils.c index d08c87c..69609d2 100644 --- a/app/src/protocol_utils.c +++ b/app/src/protocol_utils.c @@ -29,10 +29,12 @@ void send_error_receipt(hand_acid_ble_proto_t* rxpacket, int32_t errorcode) { txheader->frame_type = kproto_error_receipt; txheader->data.errreceipt.ecode = errorcode; // 校验 - txheader->packetlen = sendlen; - _cmdtxbuf[sendlen - 2] = compute_sum(_cmdtxbuf, sendlen - 2); - _cmdtxbuf[sendlen - 1] = PACKET_TAIL; - uart_send_data(_cmdtxbuf, sendlen); + txheader->packetlen = sendlen; + + PACKET_SET_CHECKSUM(txheader); + PACKET_SET_TAIL(txheader); + + uart_send_data((uint8_t*)txheader, sendlen); } void send_success_receipt(hand_acid_ble_proto_t* rxpacket) { @@ -51,11 +53,10 @@ void send_success_receipt(hand_acid_ble_proto_t* rxpacket) { } txheader->packetlen = sendlen; - // 校验 - _cmdtxbuf[sendlen - 2] = compute_sum(_cmdtxbuf, sendlen - 2); - _cmdtxbuf[sendlen - 1] = PACKET_TAIL; + PACKET_SET_CHECKSUM(txheader); + PACKET_SET_TAIL(txheader); - uart_send_data(_cmdtxbuf, sendlen); + uart_send_data((uint8_t*)txheader, sendlen); } void send_connected_event_report(uint8_t cmd, uint8_t connected, uint8_t from_ble_master) { @@ -74,9 +75,8 @@ void send_connected_event_report(uint8_t cmd, uint8_t connected, uint8_t from_bl txheader->data.connected_event.connected = connected; txheader->data.connected_event.from_ble_master = from_ble_master; - // 校验 - _cmdtxbuf[sendlen - 2] = compute_sum(_cmdtxbuf, sendlen - 2); - _cmdtxbuf[sendlen - 1] = PACKET_TAIL; + PACKET_SET_CHECKSUM(txheader); + PACKET_SET_TAIL(txheader); - uart_send_data(_cmdtxbuf, sendlen); + uart_send_data((uint8_t*)txheader, sendlen); } diff --git a/protocol b/protocol index a6f58d3..e5997c7 160000 --- a/protocol +++ b/protocol @@ -1 +1 @@ -Subproject commit a6f58d38c15815ac5b13c4d55e7ba12daaf158d6 +Subproject commit e5997c75812daaa49ddc95ffdaa06e90539ae0bb