Browse Source

update

sunlight
zhaohe 11 months ago
parent
commit
27791d0abe
  1. 2
      app_protocols
  2. 7
      usrc/service/app_core.cpp
  3. 44
      usrc/service/remote_controler.cpp

2
app_protocols

@ -1 +1 @@
Subproject commit 7c86a5d3b430a0a02b78355035f18ed2ec9ee24d
Subproject commit 5f6308f9929809ffe5481b03d32488334f33c0e9

7
usrc/service/app_core.cpp

@ -81,7 +81,7 @@ 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);
// 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;
@ -144,7 +144,7 @@ void AppCore::appsetup() {
***********************************************************************************************************************/
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));
// ZLOGI(TAG, "[] rx event : %s", zhex2str(rx, len));
blelogdump(rx, len);
if (packet->cmd == kzble_app_report_key_event) {
@ -154,6 +154,8 @@ void AppCore::appsetup() {
}
});
// AciDisp00000
/***********************************************************************************************************************
* START *
***********************************************************************************************************************/
@ -161,6 +163,7 @@ void AppCore::appsetup() {
RCTRL->startSchedule();
RemoteControlerStateSyncService::ins()->startSync();
// dim
UIS->chpage(pg_login);
}

44
usrc/service/remote_controler.cpp

@ -3,11 +3,11 @@
#include "app_protocols/ble_through/ble_proto_utils.h"
using namespace iflytop;
#define UART_RX_OVERTIME 10
#define UART_RX_OVERTIME 100
#define TAG "RemoteControler"
#define CMD_OVERTIME 500
#define DEBUG 1
#define DEBUG 0
static ZQueue<RemoteControlerReportPacket_t> ackQueue;
static ZQueue<RemoteControlerReportPacket_t> eventQueue;
@ -59,23 +59,41 @@ void RemoteControlerUpper::startSchedule() {
while (1) {
// static uint8_t processbuf[128];
static RemoteControlerReportPacket_t rxpacket;
rxpacket.datalen = 0;
if (m_uart->USR_UartITRxOff != 0 && zos_haspassedms(m_uart->USR_UartITLastRxTicket) > UART_RX_OVERTIME) {
vPortEnterCritical();
if (m_uart->USR_UartITRxOff != 0 && zos_haspassedms(m_uart->USR_UartITLastRxTicket) > UART_RX_OVERTIME) {
memset(rxpacket.data, 0, sizeof(rxpacket.data));
memcpy(rxpacket.data, m_uart->USR_UartITRxBuf, m_uart->USR_UartITRxOff);
rxpacket.datalen = m_uart->USR_UartITRxOff;
m_uart->USR_UartITRxOff = 0;
rxpacket.datalen = 0;
zble_proto_packet_t* rxblepacket = (zble_proto_packet_t*)m_uart->USR_UartITRxBuf;
uint8_t* rxblepacketu8 = (uint8_t*)m_uart->USR_UartITRxBuf;
int curPacketlen = rxblepacket->packetlen;
if (m_uart->USR_UartITRxOff != 0) {
if ((m_uart->USR_UartITRxOff >= curPacketlen) && //
rxblepacket->h1 == 0xAA && //
rxblepacket->h2 == 0xBB && //
rxblepacketu8[curPacketlen - 1] == 0xCC) {
vPortEnterCritical();
// copy data
memcpy(rxpacket.data, rxblepacketu8, curPacketlen);
rxpacket.datalen = curPacketlen;
// move data
memmove(m_uart->USR_UartITRxBuf, m_uart->USR_UartITRxBuf + curPacketlen, curPacketlen);
m_uart->USR_UartITRxOff = m_uart->USR_UartITRxOff - curPacketlen;
vPortExitCritical();
} else {
if (zos_haspassedms(m_uart->USR_UartITLastRxTicket) > UART_RX_OVERTIME) {
// drop data
ZLOGI(TAG, "drop data %d %s", m_uart->USR_UartITRxOff, zhex2str(m_uart->USR_UartITRxBuf, m_uart->USR_UartITRxOff));
vPortEnterCritical();
m_uart->USR_UartITRxOff = 0;
memset(rxbuf, 0, 128);
vPortExitCritical();
}
}
vPortExitCritical();
}
if (rxpacket.datalen != 0) {
preProcessrxpacket(&rxpacket);
}
// ZLOGI(TAG,".");
osDelay(3);
osDelay(2);
}
});

Loading…
Cancel
Save