From 5e10f7251e90deffd91e2d1ac81e19c5bd89246e Mon Sep 17 00:00:00 2001 From: John Date: Sun, 14 Jan 2024 11:09:43 +0100 Subject: [PATCH] add inject command --- ChangeLog.md | 7 +++++++ src/ebusd/mainloop.cpp | 31 ++++++++++++++++++++++++++++++- src/ebusd/mainloop.h | 8 ++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 21f339ba..cd0bc7ce 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,10 @@ +# next (tbd) +## Bug Fixes +* fix conditional messages not being sent to message definition in MQTT integration and not being used in KNX group association +## Features +* add "inject" command + + # 23.3 (2023-12-26) ## Bug Fixes * fix MQTT topic string validation diff --git a/src/ebusd/mainloop.cpp b/src/ebusd/mainloop.cpp index f8351d7b..6ad18c76 100644 --- a/src/ebusd/mainloop.cpp +++ b/src/ebusd/mainloop.cpp @@ -477,6 +477,13 @@ result_t MainLoop::decodeRequest(Request* req, bool* connected, RequestMode* req *ostream << "ERR: command not enabled"; return RESULT_OK; } + if (cmd == "INJECT") { + if (m_enableHex) { + return executeInject(args, ostream); + } + *ostream << "ERR: command not enabled"; + return RESULT_OK; + } if (cmd == "F" || cmd == "FIND") { return executeFind(args, getUserLevels(*user), ostream); } @@ -1155,6 +1162,27 @@ result_t MainLoop::executeHex(const vector& args, ostringstream* ostream return RESULT_OK; } +result_t MainLoop::executeInject(const vector& args, ostringstream* ostream) { + size_t argPos = 1; + if (argPos < args.size()) { + MasterSymbolString master; + SlaveSymbolString slave; + if (!m_scanHelper->parseMessage(args[argPos++], false, &master, &slave)) { + return RESULT_ERR_INVALID_ARG; + } + m_busHandler->notifyProtocolMessage(false, master, slave); + return RESULT_OK; + } + *ostream << "usage: inject QQZZPBSBNN[DD]*/[NN[DD]*]\n" + " Inject hex data (without sending to bus).\n" + " QQ source address\n" + " ZZ destination address\n" + " PB SB primary/secondary command byte\n" + " NN number of following data bytes\n" + " DD data byte(s)"; + return RESULT_OK; +} + result_t MainLoop::executeDirect(const vector& args, RequestMode* reqMode, ostringstream* ostream) { if (reqMode->listenMode != lm_direct) { if (args.size() == 1) { @@ -1879,10 +1907,11 @@ result_t MainLoop::executeHelp(ostringstream* ostream) { " Write by new def.: write [-s QQ] [-d ZZ] -def DEFINITION [VALUE[;VALUE]*] (if enabled)\n" " Write hex message: write [-s QQ] [-c CIRCUIT] -h ZZPBSBNN[DD]*\n" " auth|a Authenticate user: auth USER SECRET\n" - " hex Send hex data: hex [-s QQ] [-n] ZZPBSB[NN][DD]* (if enabled)\n" " find|f Find message(s): find [-v|-V] [-r] [-w] [-p] [-a] [-d] [-h] [-i ID] [-f] [-F COL[,COL]*] [-e]" " [-c CIRCUIT] [-l LEVEL] [NAME]\n" " listen|l Listen for updates: listen [-v|-V] [-n|-N] [-u|-U] [stop]\n" + " hex Send hex data: hex [-s QQ] [-n] ZZPBSB[NN][DD]* (if enabled)\n" + " inject Inject hex data: inject QQZZPBSBNN[DD]*/[NN[DD]*] (if enabled)\n" " direct Enter direct mode\n" " state|s Report bus state\n" " info|i Report information about the daemon, configuration, seen participants, and the device.\n" diff --git a/src/ebusd/mainloop.h b/src/ebusd/mainloop.h index 43255752..3703a79e 100644 --- a/src/ebusd/mainloop.h +++ b/src/ebusd/mainloop.h @@ -207,6 +207,14 @@ class MainLoop : public Thread { */ result_t executeHex(const vector& args, ostringstream* ostream); + /** + * Execute the inject command. + * @param args the arguments passed to the command (starting with the command itself), or empty for help. + * @param ostream the @a ostringstream to format the result string to. + * @return the result code. + */ + result_t executeInject(const vector& args, ostringstream* ostream); + /** * Execute the direct command. * @param args the arguments passed to the command (starting with the command itself), or empty for help.