Update to 'hf.field.timeout_sec'
This commit is contained in:
1 parent
b443fc7723
commit
75a49716a9
5 files changed
+30
-32
No files matched your search
+6
-4
@@ -846,11 +846,13 @@ bool OpenProxmark(pm3_device_t **dev, const char *port, bool wait_for_port, int
|
||||
}
|
||||
}
|
||||
|
||||
int SetHfFieldTimeout(uint32_t timeout_ms, bool quiet) {
|
||||
int SetHfFieldTimeout(uint32_t timeout_sec, bool quiet) {
|
||||
if (g_session.pm3_present == false) {
|
||||
return PM3_ENOTTY;
|
||||
}
|
||||
|
||||
uint32_t timeout_ms = timeout_sec * 1000U;
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_SET_HF_FIELD_TIMEOUT, (uint8_t *)&timeout_ms, sizeof(timeout_ms));
|
||||
|
||||
@@ -944,10 +946,10 @@ int TestProxmark(pm3_device_t *dev) {
|
||||
}
|
||||
}
|
||||
|
||||
if (g_session.hf_field_timeout > 0) {
|
||||
int timeout_res = SetHfFieldTimeout(g_session.hf_field_timeout, true);
|
||||
if (g_session.hf_field_timeout_sec > 0) {
|
||||
int timeout_res = SetHfFieldTimeout(g_session.hf_field_timeout_sec, true);
|
||||
if (timeout_res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Failed to apply HF field timeout (" _YELLOW_("%u") " ms)", g_session.hf_field_timeout);
|
||||
PrintAndLogEx(WARNING, "Failed to apply HF field timeout (" _YELLOW_("%u") " s)", g_session.hf_field_timeout_sec);
|
||||
}
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms
|
||||
bool WaitForResponseTimeout(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout);
|
||||
bool WaitForResponse(uint32_t cmd, PacketResponseNG *response);
|
||||
|
||||
int SetHfFieldTimeout(uint32_t timeout_ms, bool quiet);
|
||||
int SetHfFieldTimeout(uint32_t timeout_sec, bool quiet);
|
||||
|
||||
//bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning);
|
||||
bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint32_t start_index, uint8_t *data, uint32_t datalen, PacketResponseNG *response, size_t ms_timeout, bool show_warning);
|
||||
|
||||
@@ -45,7 +45,7 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 1, "prefs get client.debug" },
|
||||
{ 1, "prefs get client.delay" },
|
||||
{ 1, "prefs get client.timeout" },
|
||||
{ 1, "prefs get hf.field.timeout" },
|
||||
{ 1, "prefs get hf.field.timeout_sec" },
|
||||
{ 1, "prefs get color" },
|
||||
{ 1, "prefs get savepaths" },
|
||||
{ 1, "prefs get emoji" },
|
||||
@@ -58,7 +58,7 @@ const static vocabulary_t vocabulary[] = {
|
||||
{ 1, "prefs set client.debug" },
|
||||
{ 1, "prefs set client.delay" },
|
||||
{ 1, "prefs set client.timeout" },
|
||||
{ 1, "prefs set hf.field.timeout" },
|
||||
{ 1, "prefs set hf.field.timeout_sec" },
|
||||
{ 1, "prefs set color" },
|
||||
{ 1, "prefs set emoji" },
|
||||
{ 1, "prefs set hints" },
|
||||
|
||||
+20
-24
@@ -102,7 +102,7 @@ int preferences_load(void) {
|
||||
g_session.client_debug_level = cdbOFF;
|
||||
// g_session.device_debug_level = ddbOFF;
|
||||
g_session.timeout = uart_get_timeouts();
|
||||
g_session.hf_field_timeout = 0;
|
||||
g_session.hf_field_timeout_sec = 0;
|
||||
|
||||
g_session.window_changed = false;
|
||||
g_session.plot.x = 10;
|
||||
@@ -330,7 +330,7 @@ void preferences_save_callback(json_t *root) {
|
||||
*/
|
||||
JsonSaveInt(root, "client.exe.delay", g_session.client_exe_delay);
|
||||
JsonSaveInt(root, "client.timeout", g_session.timeout);
|
||||
JsonSaveInt(root, "hf.field.timeout", g_session.hf_field_timeout);
|
||||
JsonSaveInt(root, "hf.field.timeout_sec", g_session.hf_field_timeout_sec);
|
||||
|
||||
// MQTT
|
||||
JsonSaveStr(root, "mqtt.server", g_session.mqtt_server);
|
||||
@@ -442,13 +442,9 @@ void preferences_load_callback(json_t *root) {
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "client.timeout", &i1) == 0)
|
||||
g_session.timeout = i1;
|
||||
|
||||
// persistent HF field timeout
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "hf.field.timeout", &i1) == 0) {
|
||||
g_session.hf_field_timeout = i1;
|
||||
} else if (json_unpack_ex(root, &up_error, 0, "{s:i}", "field.timeout", &i1) == 0) {
|
||||
// Backward compatibility with earlier key name.
|
||||
g_session.hf_field_timeout = i1;
|
||||
}
|
||||
// persistent HF field timeout (seconds)
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:i}", "hf.field.timeout_sec", &i1) == 0)
|
||||
g_session.hf_field_timeout_sec = (i1 > 0) ? (uint32_t)i1 : 0;
|
||||
|
||||
// MQTT server
|
||||
if (json_unpack_ex(root, &up_error, 0, "{s:s}", "mqtt.server", &s1) == 0)
|
||||
@@ -682,10 +678,10 @@ static void showClientTimeoutState(void) {
|
||||
}
|
||||
|
||||
static void showFieldTimeoutState(void) {
|
||||
if (g_session.hf_field_timeout == 0) {
|
||||
if (g_session.hf_field_timeout_sec == 0) {
|
||||
PrintAndLogEx(INFO, " HF field timeout........ " _WHITE_("off"));
|
||||
} else {
|
||||
PrintAndLogEx(INFO, " HF field timeout........ " _GREEN_("%u") " ms", g_session.hf_field_timeout);
|
||||
PrintAndLogEx(INFO, " HF field timeout........ " _GREEN_("%u") " s", g_session.hf_field_timeout_sec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1087,16 +1083,16 @@ static int setCmdClientTimeout(const char *Cmd) {
|
||||
|
||||
static int setCmdHfFieldTimeout(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "prefs set hf.field.timeout",
|
||||
CLIParserInit(&ctx, "prefs set hf.field.timeout_sec",
|
||||
"Set persistent preference of PM3 HF field inactivity timeout",
|
||||
"prefs set hf.field.timeout --ms 0 --> disable HF field auto timeout\n"
|
||||
"prefs set hf.field.timeout --ms 5000 --> turn HF field off after 5s of inactivity\n"
|
||||
"prefs set hf.field.timeout --ms 300000 --> turn HF field off after 5 minutes of inactivity\n"
|
||||
"prefs set hf.field.timeout --ms 900000 --> turn HF field off after 15 minutes of inactivity\n");
|
||||
"prefs set hf.field.timeout_sec --sec 0 --> disable HF field auto timeout\n"
|
||||
"prefs set hf.field.timeout_sec --sec 5 --> turn HF field off after 5 seconds of inactivity\n"
|
||||
"prefs set hf.field.timeout_sec --sec 300 --> turn HF field off after 5 minutes of inactivity\n"
|
||||
"prefs set hf.field.timeout_sec --sec 900 --> turn HF field off after 15 minutes of inactivity\n");
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_int0("m", "ms", "<ms>", "HF field inactivity timeout in milliseconds"),
|
||||
arg_int0("s", "sec", "<sec>", "HF field inactivity timeout in seconds"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
@@ -1110,9 +1106,9 @@ static int setCmdHfFieldTimeout(const char *Cmd) {
|
||||
|
||||
uint32_t new_value = (uint32_t)arg;
|
||||
|
||||
if (g_session.hf_field_timeout != new_value) {
|
||||
if (g_session.hf_field_timeout_sec != new_value) {
|
||||
showFieldTimeoutState();
|
||||
g_session.hf_field_timeout = new_value;
|
||||
g_session.hf_field_timeout_sec = new_value;
|
||||
showFieldTimeoutState();
|
||||
preferences_save();
|
||||
} else {
|
||||
@@ -1120,7 +1116,7 @@ static int setCmdHfFieldTimeout(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (g_session.pm3_present) {
|
||||
int res = SetHfFieldTimeout(g_session.hf_field_timeout, false);
|
||||
int res = SetHfFieldTimeout(g_session.hf_field_timeout_sec, false);
|
||||
if (res != PM3_SUCCESS) {
|
||||
PrintAndLogEx(WARNING, "Failed to apply HF field timeout to connected PM3");
|
||||
}
|
||||
@@ -1581,9 +1577,9 @@ static int getCmdClientTimeout(const char *Cmd) {
|
||||
|
||||
static int getCmdHfFieldTimeout(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "prefs get hf.field.timeout",
|
||||
CLIParserInit(&ctx, "prefs get hf.field.timeout_sec",
|
||||
"Get preference of PM3 HF field inactivity timeout",
|
||||
"prefs get hf.field.timeout"
|
||||
"prefs get hf.field.timeout_sec"
|
||||
);
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
@@ -1618,7 +1614,7 @@ static command_t CommandTableGet[] = {
|
||||
{"client.debug", getCmdDebug, AlwaysAvailable, "Get client debug level preference"},
|
||||
{"client.delay", getCmdExeDelay, AlwaysAvailable, "Get client execution delay preference"},
|
||||
{"client.timeout", getCmdClientTimeout, AlwaysAvailable, "Get client execution delay preference"},
|
||||
{"hf.field.timeout", getCmdHfFieldTimeout, AlwaysAvailable, "Get PM3 HF field inactivity timeout preference"},
|
||||
{"hf.field.timeout_sec", getCmdHfFieldTimeout, AlwaysAvailable, "Get PM3 HF field inactivity timeout preference"},
|
||||
{"color", getCmdColor, AlwaysAvailable, "Get color support preference"},
|
||||
{"savepaths", getCmdSavePaths, AlwaysAvailable, "Get file folder "},
|
||||
// {"devicedebug", getCmdDeviceDebug, AlwaysAvailable, "Get device debug level"},
|
||||
@@ -1636,7 +1632,7 @@ static command_t CommandTableSet[] = {
|
||||
{"client.debug", setCmdDebug, AlwaysAvailable, "Set client debug level"},
|
||||
{"client.delay", setCmdExeDelay, AlwaysAvailable, "Set client execution delay"},
|
||||
{"client.timeout", setCmdClientTimeout, AlwaysAvailable, "Set client communication timeout"},
|
||||
{"hf.field.timeout", setCmdHfFieldTimeout, AlwaysAvailable, "Set PM3 HF field inactivity timeout"},
|
||||
{"hf.field.timeout_sec", setCmdHfFieldTimeout, AlwaysAvailable, "Set PM3 HF field inactivity timeout"},
|
||||
|
||||
{"color", setCmdColor, AlwaysAvailable, "Set color support"},
|
||||
{"emoji", setCmdEmoji, AlwaysAvailable, "Set emoji display"},
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ typedef struct {
|
||||
char *history_path;
|
||||
pm3_device_t *current_device;
|
||||
uint32_t timeout;
|
||||
uint32_t hf_field_timeout;
|
||||
uint32_t hf_field_timeout_sec;
|
||||
char *mqtt_server;
|
||||
char *mqtt_port;
|
||||
char *mqtt_topic;
|
||||
|
||||
Reference in new issue
Block a user