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 4398987..8e13430 100644
Binary files a/ui/hand_acid_mainboard_ui.HMI and b/ui/hand_acid_mainboard_ui.HMI differ
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;
}
/***********************************************************************************************************************