Skip to content

Commit 6b9e23f

Browse files
[preferences] adding getType command
1 parent 02a4039 commit 6b9e23f

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

UNOR4USBBridge/cmds_preferences.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,33 @@ void CAtHandler::add_cmds_preferences() {
200200
}
201201
};
202202

203+
/* ....................................................................... */
204+
command_table[_PREF_TYPE] = [this](auto & srv, auto & parser) {
205+
/* ....................................................................... */
206+
switch (parser.cmd_mode) {
207+
case chAT::CommandMode::Write: {
208+
if (parser.args.size() != 1) {
209+
return chAT::CommandStatus::ERROR;
210+
}
211+
212+
auto &key = parser.args[0];
213+
if (key.empty()) {
214+
return chAT::CommandStatus::ERROR;
215+
}
216+
217+
String error = String(pref.getType(key.c_str())) + "\r\n";
218+
219+
srv.write_response_prompt();
220+
srv.write_str((const char *)(error.c_str()));
221+
srv.write_line_end();
222+
return chAT::CommandStatus::OK;
223+
224+
}
225+
default:
226+
return chAT::CommandStatus::ERROR;
227+
}
228+
};
229+
203230
/* ....................................................................... */
204231
command_table[_PREF_GET] = [this](auto & srv, auto & parser) {
205232
/* ....................................................................... */

UNOR4USBBridge/commands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ enum file_op {
130130
#define _PREF_CLEAR "+PREFCLEAR"
131131
#define _PREF_REMOVE "+PREFREMOVE"
132132
#define _PREF_PUT "+PREFPUT"
133+
#define _PREF_TYPE "+PREFTYPE"
133134
#define _PREF_GET "+PREFGET"
134135
#define _PREF_LEN "+PREFLEN"
135136
#define _PREF_STAT "+PREFSTAT"

0 commit comments

Comments
 (0)