From 63b95c1b8cf9be8ebecb8fc9786e0adb264c26e2 Mon Sep 17 00:00:00 2001 From: SnickerSun Date: Sat, 10 Aug 2024 10:25:37 +0800 Subject: [PATCH] =?utf8?q?A5133OBU=20=E6=BC=94=E7=A4=BARSU=E6=95=B0?= =?utf8?q?=E6=8D=AE=E6=8E=A5=E6=94=B6=E7=8E=AF=E5=A2=83=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../obumessage/src/OBUMessageView.cpp | 63 +++++++++---------- code/sdk/drivers/peripheral/a5133/A5133Main.c | 35 ++++++++--- code/sdk/drivers/peripheral/a5133/A5133main.h | 7 ++- .../a5133/service/a5133_service.cpp | 4 +- .../drivers/peripheral/utils/custom_utils.c | 12 +++- .../drivers/peripheral/utils/custom_utils.h | 3 +- 6 files changed, 73 insertions(+), 51 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageView.cpp b/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageView.cpp index c833ad70c..aad3afe06 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageView.cpp @@ -1,8 +1,8 @@ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-08-09 10:25:01 + * @LastEditors: SnickerSun snickersun@163.com + * @LastEditTime: 2024-08-09 16:37:41 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/obumessage/src/OBUMessageView.cpp */ #include "obumessage/include/OBUMessagePresenter.h" @@ -143,7 +143,7 @@ namespace OHOS return; } } - displayTimeLabel->SetPosition(83, 0, 300, 35); + displayTimeLabel->SetPosition(83, 5, 300, 35); displayTimeLabel->SetStyle(STYLE_TEXT_FONT, 30); displayTimeLabel->SetStyle(STYLE_LINE_HEIGHT, 35); displayTimeLabel->SetText(""); @@ -162,13 +162,13 @@ namespace OHOS return; } } - obuMessageLabel1->SetPosition(68, 10, 360, 250); + obuMessageLabel1->SetPosition(100, 100, 360, 50); obuMessageLabel1->SetStyle(STYLE_BORDER_RADIUS, 33); obuMessageLabel1->SetStyle(STYLE_TEXT_FONT, 40); obuMessageLabel1->SetStyle(STYLE_LINE_HEIGHT, 45); obuMessageLabel1->SetText(""); obuMessageLabel1->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - obuMessageLabel1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + obuMessageLabel1->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); obuMessageLabel1->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); group->Add(obuMessageLabel1); @@ -182,13 +182,13 @@ namespace OHOS return; } } - obuMessageLabel2->SetPosition(53, 70, 360, 250); + obuMessageLabel2->SetPosition(100, 170, 360, 50); obuMessageLabel2->SetStyle(STYLE_BORDER_RADIUS, 33); obuMessageLabel2->SetStyle(STYLE_TEXT_FONT, 40); obuMessageLabel2->SetStyle(STYLE_LINE_HEIGHT, 45); obuMessageLabel2->SetText(""); obuMessageLabel2->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - obuMessageLabel2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + obuMessageLabel2->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER); obuMessageLabel2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); group->Add(obuMessageLabel2); @@ -202,7 +202,7 @@ namespace OHOS return; } } - MessageNumLabel1->SetPosition(28, 10, 360, 250); + MessageNumLabel1->SetPosition(28, 100, 100, 50); MessageNumLabel1->SetStyle(STYLE_BORDER_RADIUS, 33); MessageNumLabel1->SetStyle(STYLE_TEXT_FONT, 40); MessageNumLabel1->SetStyle(STYLE_LINE_HEIGHT, 45); @@ -223,7 +223,7 @@ namespace OHOS return; } } - MessageNumLabel2->SetPosition(28, 70, 360, 250); + MessageNumLabel2->SetPosition(28, 170, 100, 50); MessageNumLabel2->SetStyle(STYLE_BORDER_RADIUS, 33); MessageNumLabel2->SetStyle(STYLE_TEXT_FONT, 40); MessageNumLabel2->SetStyle(STYLE_LINE_HEIGHT, 45); @@ -299,36 +299,29 @@ namespace OHOS void OBUMessageView::UpdateOBUMessageViewDisplayData(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OBUMessageView::UpdateOBUMessageViewDisplayDate"); - int flag = uapi_get_a5133_update_state(); - if (flag) - { - uint8_t rxdata[80] = {0}; - uint32_t rxdata_timestamp = 0; - uapi_get_a5133_rxdata(rxdata, 80); - rxdataStr = std::string((char *)rxdata); - uapi_get_a5133_rxdata_timestamp(&rxdata_timestamp); - char labelTime[20] = {0}; - if (uapi_get_TIME_STR(rxdata_timestamp, labelTime, '.', ':', DATE_H_M_S) != ERRCODE_SUCC) - { - labelTimeStr = std::string("--"); - } - else - { - labelTimeStr = std::string(labelTime); - } - } - if(flag == 1) + num1 = uapi_get_a5133_update_state(); + num2 = uapi_get_a5133_update_state1(); + + uint8_t rxdata[80] = {0}; + uint32_t rxdata_timestamp = 0; + uapi_get_a5133_rxdata(rxdata, 80); + rxdataStr = std::string((char *)rxdata); + uapi_get_a5133_rxdata_timestamp(&rxdata_timestamp); + char labelTime[20] = {0}; + if (uapi_get_TIME_STR(rxdata_timestamp, labelTime, '.', ':', DATE_H_M_S) != ERRCODE_SUCC) { - num1++; - obuMessageLabel1->SetText(rxdataStr.c_str()); /*数据更新*/ - MessageNumLabel1->SetText(std::to_string(num1).c_str()); + labelTimeStr = std::string("--"); } - else if(flag == 2) + else { - num2++; - obuMessageLabel2->SetText(rxdataStr.c_str()); - MessageNumLabel2->SetText(std::to_string(num2).c_str()); + labelTimeStr = std::string(labelTime); } + + // obuMessageLabel1->SetText(rxdataStr.c_str()); /*数据更新*/ + obuMessageLabel1->SetText("您已进入北斗收费路段"); /*数据更新*/ + MessageNumLabel1->SetText(std::to_string(num1).c_str()); + obuMessageLabel2->SetText("您已超速,请减速慢行!"); + MessageNumLabel2->SetText(std::to_string(num2).c_str()); displayTimeLabel->SetText(labelTimeStr.c_str()); /*时间更新:时:分:秒*/ } diff --git a/code/sdk/drivers/peripheral/a5133/A5133Main.c b/code/sdk/drivers/peripheral/a5133/A5133Main.c index 678c87278..4f85a3d06 100644 --- a/code/sdk/drivers/peripheral/a5133/A5133Main.c +++ b/code/sdk/drivers/peripheral/a5133/A5133Main.c @@ -108,7 +108,8 @@ const Uint8 PN9_Tab[]= static uint8_t send_data[2][64] = {0}; static uint8_t send_data_index = 0; -static uint8_t update_flag = 0; +static uint32_t update_flag = 0; +static uint32_t update_flag1 = 0; static uint32_t history_timestamp = 0; errcode_t a5133_set_send_data(uint8_t *senddata,uint8_t datalen) @@ -752,15 +753,20 @@ static void dump_tmpbuf(void) } -Uint8 a5133_get_update_state(void) +uint32_t a5133_get_update_state(void) { return update_flag; } +uint32_t a5133_get_update_state1(void) +{ + return update_flag1; +} void a5133_get_rxdata(uint8_t *databuf,uint8_t len) { memcpy_s(databuf,len,tmpbuf_rx1,sizeof(tmpbuf_rx1)); - update_flag = 0; + // update_flag = 0; + // update_flag1 = 0; } void a5133_get_rxdata_timestamp(uint32_t *timestamp) @@ -837,6 +843,17 @@ void RxPacket(void) // } uint32_t msg_timestamp = *(uint32_t*)&tmpbuf[1+2+4+4+4+2]; uint16_t datalen = *(uint16_t*)&tmpbuf[1]; + uint8_t *pt=(uint8_t*)&datalen; + uint8_t t = pt[1]; + pt[1]=pt[0]; + pt[0]=t; + pt = (uint8_t*)&msg_timestamp; + t = pt[3]; + pt[3]=pt[0]; + pt[0]=t; + t = pt[1]; + pt[1]=pt[2]; + pt[2]=t; // total(64) , header(4), timestamp(4), len(1), data(n-11) , crc(2) // frame_start_flag(1),len(2) if (datalen >0 && datalen <= (FIFO_LEN-1-2)) @@ -844,7 +861,6 @@ void RxPacket(void) uint16_t crc = CRC16_X25(&tmpbuf[3],datalen); uint16_t recv_crc = *(uint16_t*)&tmpbuf[datalen+2+1]; PRINT("datalen:%d crc[%X] , recv_crc %X\n",datalen,crc,recv_crc); - SUCC_Frame++; if (crc != recv_crc) { err = 1; @@ -853,13 +869,13 @@ void RxPacket(void) { tmpbuf_len = datalen-4-4-4-2-4; tmpbuf_rx_timestamp = msg_timestamp; - if(history_timestamp != tmpbuf_rx_timestamp) + // if(history_timestamp != tmpbuf_rx_timestamp) { history_timestamp = tmpbuf_rx_timestamp; - if(datalen == 0X33) - update_flag = 1; + if(datalen == 0X24) + update_flag++; else - update_flag = 2; + update_flag1++; } memset(tmpbuf_rx1, 0 ,sizeof(tmpbuf_rx1)); //帧起始(1)、帧长度(2)、目标地址(4)、设备地址(4)、MAC控制域(4)、帧序号、(2) @@ -875,6 +891,9 @@ void RxPacket(void) dump_tmpbuf(); if (err)//packet error Err_Frame++; + else + SUCC_Frame++; + } /********************************************************************* diff --git a/code/sdk/drivers/peripheral/a5133/A5133main.h b/code/sdk/drivers/peripheral/a5133/A5133main.h index 4fffddee4..5dd3a20d4 100644 --- a/code/sdk/drivers/peripheral/a5133/A5133main.h +++ b/code/sdk/drivers/peripheral/a5133/A5133main.h @@ -1,8 +1,8 @@ /* * @Author: penglei 1624952103@qq.com * @Date: 2024-07-20 10:36:21 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-08-08 20:11:46 + * @LastEditors: SnickerSun snickersun@163.com + * @LastEditTime: 2024-08-09 15:46:40 * @FilePath: /FD230/code/sdk/drivers/peripheral/a5133/A5133main.h * @Description: * @@ -75,7 +75,8 @@ void RF_TXPower(Uint8 tbf, Uint8 tpa); void a5133_main(Uint8 Flag_MASTER,uint8_t channel); void a5133_get_rxdata(uint8_t *databuf,uint8_t len); errcode_t a5133_set_send_data(uint8_t *senddata,uint8_t datalen); -Uint8 a5133_get_update_state(void); +uint32_t a5133_get_update_state(void); +uint32_t a5133_get_update_state1(void); void a5133_get_rxdata_timestamp(uint32_t *timestamp); void a5133_cko_state_update(void); #endif \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/a5133/service/a5133_service.cpp b/code/sdk/drivers/peripheral/a5133/service/a5133_service.cpp index 47d251b41..414022ecc 100644 --- a/code/sdk/drivers/peripheral/a5133/service/a5133_service.cpp +++ b/code/sdk/drivers/peripheral/a5133/service/a5133_service.cpp @@ -149,7 +149,7 @@ static void a5133_service_check_task(void *arg) { a5133_service_running_stat = true; a5133_service_timer_start_check(50); - a5133_main(MASTER,80); + a5133_main(MASTER,5); PRINT("A5133_SERVICE_CMD_TYPE_RUN_MASTER \n"); }else{ PRINT("A5133_SERVICE_CMD_TYPE_RUN_MASTER already Started \n"); @@ -161,7 +161,7 @@ static void a5133_service_check_task(void *arg) { a5133_service_running_stat = true; a5133_service_timer_start_check(50); - a5133_main(SLAVE,80); + a5133_main(SLAVE,5); PRINT("A5133_SERVICE_CMD_TYPE_RUN_SLAVE \n"); }else{ PRINT("A5133_SERVICE_CMD_TYPE_RUN_SLAVE already Started \n"); diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index c7564cd20..55eb4cf6a 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -2676,12 +2676,20 @@ errcode_t uapi_a5133_set_send_data(uint8_t *senddata,uint8_t datalen) #endif } -uint8_t uapi_get_a5133_update_state(void) +uint32_t uapi_get_a5133_update_state(void) { #ifdef SUPPORT_A5133_SERVICE return a5133_get_update_state(); #else - return false; + return 0; +#endif +} +uint32_t uapi_get_a5133_update_state1(void) +{ +#ifdef SUPPORT_A5133_SERVICE + return a5133_get_update_state(); +#else + return 0; #endif } diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 31d557a86..7ce3caf52 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -244,7 +244,8 @@ uint16_t CRC16_X25(uint8_t *di, uint32_t len); errcode_t uapi_a5133_set_send_data(uint8_t *senddata,uint8_t datalen); void a5133_demo_msg_change_callback(void); void uapi_get_a5133_rxdata_timestamp(uint32_t *timestamp); -uint8_t uapi_get_a5133_update_state(void); +uint32_t uapi_get_a5133_update_state(void); +uint32_t uapi_get_a5133_update_state1(void); #include "custom_utilscpp.h" -- 2.17.1