From 00141ac2673ad818bd5009b8ba54fa25ee564aa1 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 29 Aug 2024 16:33:03 +0800 Subject: [PATCH] update --- .settings/language.settings.xml | 4 +-- app_protocols | 2 +- ui/hand_acid_mainboard_ui.HMI | Bin 15800145 -> 15800145 bytes usrc/service/app_core.cpp | 51 +++++++++++++++++++++++++++++++++-- usrc/service/front_end_controler.cpp | 2 +- usrc/service/remote_controler.cpp | 47 +++++++++++++++++--------------- 6 files changed, 78 insertions(+), 28 deletions(-) diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index ab6f426..cf9e0be 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/app_protocols b/app_protocols index dbdfce1..7c86a5d 160000 --- a/app_protocols +++ b/app_protocols @@ -1 +1 @@ -Subproject commit dbdfce1070c28400346d455da9862c34c767d4fc +Subproject commit 7c86a5d3b430a0a02b78355035f18ed2ec9ee24d diff --git a/ui/hand_acid_mainboard_ui.HMI b/ui/hand_acid_mainboard_ui.HMI index 4398987c7ffbd82fb475f73ab81a40ff84f4af3c..8e13430c8fd718987ebd309fc2b5191152fdd8d4 100644 GIT binary patch delta 5315 zcmeH~e^^u38OQGlNtjmoorqJ`um@}R&|(TLRw*tBh!z!CN5zRsHmS8M?M(uf)~;YZ z72DYXv+!=>4{CK{bqZy0gH%NzZtYscwrZ!fpq;kesAA_I&RN_yxrqsZP`77)><{nr zeBiz3dEM`$Qou z7~LJ^g3w+rEWy)fBZR%}gKtEkK!rY`@d-r-o9gAND>DoC&KT-yZ<}W`3+>;ry9&aF zWy-p#v0l!tITj&tE_!WvuJf6Wdo*3$ZV|q#f%B2_#$;9ESY_auqo>x?hLqKYFrWZ_ zKnYYpE!Bqj=Y4hir3(N1m%7FfT4o4kKmq)K5~zS$GKBiK_5DBmpwSR&$m0+4X?!|Q z;1BUcK7;>|8+a0*$&+~sPvx_C8lTP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WAtN z1+{P*&cInX2j}4eT!c$d2S34OxB@>zJviVh`~uhDI^2Mpa0_n39k>hkpaB};KK#l9 J%A0z{{|RGKn`r<5 diff --git a/usrc/service/app_core.cpp b/usrc/service/app_core.cpp index dba6bf4..454b53d 100644 --- a/usrc/service/app_core.cpp +++ b/usrc/service/app_core.cpp @@ -78,6 +78,47 @@ void AppCore::processKeyEventFromRemoter(hand_acid_remoter_key_event_t keyEvent) } } +void blelogdump(uint8_t* rx, int32_t len) { + // + zble_proto_packet_t* packet = (zble_proto_packet_t*)rx; + ZLOGI(TAG, "onEvent: index:[%d],from:%d,to:%d cmd:%d", packet->frameIndex, packet->from, packet->to, packet->cmd); + + if (packet->cmd == kzble_report_connected_event) { + zble_connected_event_t* event = (zble_connected_event_t*)packet->data; + ZLOGI(TAG, "onBleEvent -> [connected], name:%20s, peeradd:%s, rssi:%d, tx_power:%d", event->blename, zhex2str(event->peeradd, 6), event->rssi, event->tx_power); + return; + } + + if (packet->cmd == kzble_report_disconnect_event) { + ZLOGI(TAG, "onBleEvent -> disconnect"); + return; + } + if (packet->cmd == kzble_report_scan_result) { + zble_scan_result_t* event = (zble_scan_result_t*)packet->data; + ZLOGI(TAG, "onBleEvent -> [scanResult], name:%20s, peeradd:%s, rssi:%d, tx_power:%d", event->blename, zhex2str(event->peeradd, 6), event->rssi, event->tx_power); + return; + } + + if (packet->cmd == kzble_report_heart) { + zble_heart_t* event = (zble_heart_t*)packet->data; + ZLOGI(TAG, "onBleEvent -> [heart], from:%s, resetFlag:%d, connectedFlag:%d, power:%d", zble_proto_role_2_str(packet->from), event->reset_flag, event->connected_flag, event->power); + return; + } + + if (packet->cmd == kzble_report_power_on) { + ZLOGI(TAG, "onBleEvent -> [power_on], from:%s", zble_proto_role_2_str(packet->from)); + return; + } + + if (packet->cmd == kzble_app_report_key_event) { + int32_t keyEvent = *(int32_t*)packet->data; + ZLOGI(TAG, "onBleEvent -> [keyEvent] : %s(%d)", hand_acid_remoter_key_event_2_str(keyEvent), keyEvent); + return; + } + + ZLOGI(TAG, "[process-thread] rx unkown event(%d) : %s", packet->cmd, zhex2str(rx, len)); +} + void AppCore::appsetup() { /*********************************************************************************************************************** * INIT * @@ -97,15 +138,19 @@ void AppCore::appsetup() { Page_main::ins()->initialize(); // Page_keybAcidCh::ins()->initialize(); Page_muAcidType::ins()->initialize(); - + /*********************************************************************************************************************** * REG_EVENT_HANDLER * ***********************************************************************************************************************/ - RCTRL->regOnReport([this](uint8_t* rx, int32_t len) { // + RCTRL->regOnReport([this](uint8_t* rx, int32_t len) { zble_proto_packet_t* packet = (zble_proto_packet_t*)rx; + ZLOGI(TAG, "[] rx event : %s", zhex2str(rx, len)); + + blelogdump(rx, len); if (packet->cmd == kzble_app_report_key_event) { int32_t keyEvent = *(int32_t*)packet->data; processKeyEventFromRemoter((hand_acid_remoter_key_event_t)keyEvent); + return; } }); @@ -119,11 +164,13 @@ void AppCore::appsetup() { // dim UIS->chpage(pg_login); } +#define DEBUG_LIGHT_IO PE2 void AppCore::initialize() { AppHal::MX_TIM6_Init(); AppHal::MX_TIM7_Init(); AppHal::DEBUG_UART_INIT(PA9, PA10, 460800); + debuglight.initAsOutput(DEBUG_LIGHT_IO, kxs_gpio_nopull, false, false); ZLOGI(TAG, "======================= boardinfo ==================== "); ZLOGI(TAG, "project : %s ", PROJECT); diff --git a/usrc/service/front_end_controler.cpp b/usrc/service/front_end_controler.cpp index 664be0d..33b12c9 100644 --- a/usrc/service/front_end_controler.cpp +++ b/usrc/service/front_end_controler.cpp @@ -9,7 +9,7 @@ using namespace iflytop; #define CMD_OVERTIME 50 -#define DEBUG 1 +#define DEBUG 0 static ZThread uart_rx_thread; static ZThread rx_processed_thread; diff --git a/usrc/service/remote_controler.cpp b/usrc/service/remote_controler.cpp index 5ca1cfa..477078c 100644 --- a/usrc/service/remote_controler.cpp +++ b/usrc/service/remote_controler.cpp @@ -3,10 +3,11 @@ #include "app_protocols/ble_through/ble_proto_utils.h" using namespace iflytop; -#define UART_RX_OVERTIME 3 +#define UART_RX_OVERTIME 10 #define TAG "RemoteControler" #define CMD_OVERTIME 500 +#define DEBUG 1 static ZQueue ackQueue; static ZQueue eventQueue; @@ -33,6 +34,7 @@ void RemoteControlerUpper::initialize() { m_uart = AppHardware::ins()->remoteContolerUart; m_cmdlock.init(); + zble_proto_utils_init(kzble_master); } void RemoteControlerUpper::regOnReport(on_report_cb_t on_report) { m_cb[m_ncb] = on_report; @@ -72,7 +74,8 @@ void RemoteControlerUpper::startSchedule() { if (rxpacket.datalen != 0) { preProcessrxpacket(&rxpacket); } - osDelay(1); + // ZLOGI(TAG,"."); + osDelay(3); } }); @@ -160,68 +163,68 @@ bool RemoteControlerUpper::txcmd(uint8_t* data, uint32_t len) { bool RemoteControlerUpper::resetMasterBoard() { zble_proto_utils_create_cmd_packet(txpacket, kzble_cmd_reset, m_index++, NULL, 0); - txpacket->to = kzble_master; - bool suc = txcmd(txbuf, txpacket->packetlen); + zble_proto_utils_set_packet_to(txpacket, kzble_master); + bool suc = txcmd(txbuf, txpacket->packetlen); return suc; } bool RemoteControlerUpper::resetClientBoard() { zble_proto_utils_create_cmd_packet(txpacket, kzble_cmd_reset, m_index++, NULL, 0); - txpacket->to = kzble_slave; - bool suc = txcmd(txbuf, txpacket->packetlen); + zble_proto_utils_set_packet_to(txpacket, kzble_slave); + bool suc = txcmd(txbuf, txpacket->packetlen); return suc; } bool RemoteControlerUpper::readMasterBoardVersion(zble_read_version_t* version) { zble_proto_utils_create_cmd_packet(txpacket, kzble_cmd_read_version, m_index++, NULL, 0); - txpacket->to = kzble_master; - bool suc = txcmd(txbuf, txpacket->packetlen); + zble_proto_utils_set_packet_to(txpacket, kzble_master); + bool suc = txcmd(txbuf, txpacket->packetlen); if (suc) *version = *(zble_read_version_t*)(rxpacket->data); return suc; } bool RemoteControlerUpper::readClientBoardVersion(zble_read_version_t* version) { zble_proto_utils_create_cmd_packet(txpacket, kzble_cmd_read_version, m_index++, NULL, 0); - txpacket->to = kzble_slave; - bool suc = txcmd(txbuf, txpacket->packetlen); + zble_proto_utils_set_packet_to(txpacket, kzble_slave); + bool suc = txcmd(txbuf, txpacket->packetlen); if (suc) *version = *(zble_read_version_t*)(rxpacket->data); return suc; } bool RemoteControlerUpper::clearMasterResetFlag() { zble_proto_utils_create_cmd_packet(txpacket, kzble_cmd_clear_reset_flag, m_index++, NULL, 0); - txpacket->to = kzble_master; - bool suc = txcmd(txbuf, txpacket->packetlen); + zble_proto_utils_set_packet_to(txpacket, kzble_master); + bool suc = txcmd(txbuf, txpacket->packetlen); return suc; } bool RemoteControlerUpper::clearSlaveResetFlag() { zble_proto_utils_create_cmd_packet(txpacket, kzble_cmd_clear_reset_flag, m_index++, NULL, 0); - txpacket->to = kzble_slave; - bool suc = txcmd(txbuf, txpacket->packetlen); + zble_proto_utils_set_packet_to(txpacket, kzble_slave); + bool suc = txcmd(txbuf, txpacket->packetlen); return suc; } bool RemoteControlerUpper::setMasterInDfuMode() { zble_proto_utils_create_cmd_packet(txpacket, kzble_cmd_set_in_dfu_mode, m_index++, NULL, 0); - txpacket->to = kzble_master; - bool suc = txcmd(txbuf, txpacket->packetlen); + zble_proto_utils_set_packet_to(txpacket, kzble_master); + bool suc = txcmd(txbuf, txpacket->packetlen); return suc; } bool RemoteControlerUpper::setSlaveInDfuMode() { zble_proto_utils_create_cmd_packet(txpacket, kzble_cmd_set_in_dfu_mode, m_index++, NULL, 0); - txpacket->to = kzble_slave; - bool suc = txcmd(txbuf, txpacket->packetlen); + zble_proto_utils_set_packet_to(txpacket, kzble_slave); + bool suc = txcmd(txbuf, txpacket->packetlen); return suc; } bool RemoteControlerUpper::startScan() { zble_proto_utils_create_cmd_packet(txpacket, kzble_cmd_start_scan, m_index++, NULL, 0); - txpacket->to = kzble_master; - bool suc = txcmd(txbuf, txpacket->packetlen); + zble_proto_utils_set_packet_to(txpacket, kzble_master); + bool suc = txcmd(txbuf, txpacket->packetlen); return suc; } bool RemoteControlerUpper::stopScan() { zble_proto_utils_create_cmd_packet(txpacket, kzble_cmd_stop_scan, m_index++, NULL, 0); - txpacket->to = kzble_master; - bool suc = txcmd(txbuf, txpacket->packetlen); + zble_proto_utils_set_packet_to(txpacket, kzble_master); + bool suc = txcmd(txbuf, txpacket->packetlen); return suc; } /***********************************************************************************************************************