|
|
@ -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<RemoteControlerReportPacket_t> ackQueue; |
|
|
|
static ZQueue<RemoteControlerReportPacket_t> 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; |
|
|
|
} |
|
|
|
/***********************************************************************************************************************
|
|
|
|