From a5aad9a6baff180b9df97ecf2044280fc6af0a3e Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 13 Jan 2024 18:27:06 +0800 Subject: [PATCH] add app_set_reg --- .../micro_computer_module_device_script_cmder_paser.cpp | 13 ++++++++++++- .../micro_computer_module_device_script_cmder_paser.hpp | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp index 0467216..c3f4fe4 100644 --- a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp +++ b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.cpp @@ -56,7 +56,9 @@ void MicroComputerModuleDeviceScriptCmderPaser::initialize(ICmdParser* cancmder, cancmder->regCMD("app_module_read_raw_str", "(mid,size)", 2, [this](int32_t paramN, const char* paraV[], ICmdParserACK* ack) { // app_module_read_raw_str(paramN, paraV, ack); }); - + cancmder->regCMD("app_set_reg", "(regindex,mid,val)", 3, [this](int32_t paramN, const char* paraV[], ICmdParserACK* ack) { // + app_module_read_raw_str(paramN, paraV, ack); + }); deviceManager->regOnRegValChangeEvent([this](int32_t moduleid, int32_t regindex, int32_t oldval, int32_t toval) { // ZLOGI(TAG, "onRegValChangeEvent(moduleId[%d], reg[%d], %d->%d)", moduleid, regindex, oldval, toval); }); @@ -76,6 +78,15 @@ void MicroComputerModuleDeviceScriptCmderPaser::app_dump_reg(int32_t paramN, con app_dump_reg(moduleId, regid); } +void MicroComputerModuleDeviceScriptCmderPaser::app_set_reg(int32_t paramN, const char* paraV[], ICmdParserACK* ack) { + ack->ecode = 0; + uint16_t regid = atoi(paraV[0]); + uint16_t moduleId = atoi(paraV[1]); + uint16_t regval = atoi(paraV[2]); + ack->ecode = m_deviceManager->module_set_reg(moduleId, regid, regval); + return; +} + void MicroComputerModuleDeviceScriptCmderPaser::app_module_read_raw_str(int32_t paramN, const char* paraV[], ICmdParserACK* ack) { ack->ecode = 0; uint16_t moduleId = atoi(paraV[0]); diff --git a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp index 400fb13..dd1886b 100644 --- a/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp +++ b/components/zprotocol_helper/micro_computer_module_device_script_cmder_paser.hpp @@ -20,6 +20,9 @@ class MicroComputerModuleDeviceScriptCmderPaser : public ZModuleDeviceScriptCmde void app_dump_reg(int32_t paramN, const char* paraV[], ICmdParserACK* ack); void app_module_read_raw_str(int32_t paramN, const char* paraV[], ICmdParserACK* ack); + void app_set_reg(int32_t paramN, const char* paraV[], ICmdParserACK* ack); + + }; } // namespace iflytop