mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
fix mqtt receive command default behaviour
Some checks failed
CodeQL / Analyze (push) Has been cancelled
MacOS Build and Test / macos-make (push) Has been cancelled
MacOS Build and Test / macos-make-btaddon (push) Has been cancelled
MacOS Build and Test / macos-cmake (push) Has been cancelled
Ubuntu Build and Test / ubuntu-make (push) Has been cancelled
Ubuntu Build and Test / ubuntu-make-btaddon (push) Has been cancelled
Ubuntu Build and Test / ubuntu-cmake (push) Has been cancelled
Windows Build and Test / proxspace (push) Has been cancelled
Windows Build and Test / wsl (push) Has been cancelled
Some checks failed
CodeQL / Analyze (push) Has been cancelled
MacOS Build and Test / macos-make (push) Has been cancelled
MacOS Build and Test / macos-make-btaddon (push) Has been cancelled
MacOS Build and Test / macos-cmake (push) Has been cancelled
Ubuntu Build and Test / ubuntu-make (push) Has been cancelled
Ubuntu Build and Test / ubuntu-make-btaddon (push) Has been cancelled
Ubuntu Build and Test / ubuntu-cmake (push) Has been cancelled
Windows Build and Test / proxspace (push) Has been cancelled
Windows Build and Test / wsl (push) Has been cancelled
This commit is contained in:
parent
a3c2d2b815
commit
fa59b9cb6b
1 changed files with 7 additions and 9 deletions
|
@ -31,22 +31,20 @@
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
static void mqtt_publish_callback(void **unused, struct mqtt_response_publish *published) {
|
static void mqtt_publish_callback(void **unused, struct mqtt_response_publish *published) {
|
||||||
/* note that published->topic_name is NOT null-terminated (here we'll change it to a c-string) */
|
// note that published->topic_name is NOT null-terminated (here we'll change it to a c-string)
|
||||||
char *topic_name = (char *) calloc(published->topic_name_size + 1, 1);
|
char *topic_name = (char *) calloc(published->topic_name_size + 1, 1);
|
||||||
memcpy(topic_name, published->topic_name, published->topic_name_size);
|
memcpy(topic_name, published->topic_name, published->topic_name_size);
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "rec.. %zu", published->application_message_size);
|
|
||||||
|
|
||||||
const char *msg = published->application_message;
|
const char *msg = published->application_message;
|
||||||
|
|
||||||
char *ps = strstr(msg, "Created\": \"proxmark3");
|
char *ps = strstr(msg, "Created\": \"proxmark3");
|
||||||
if (ps) {
|
if (ps) {
|
||||||
int res = saveFileTXT("ice_mqtt", ".json", msg, published->application_message_size, spDefault);
|
int res = saveFileTXT("ice_mqtt", ".json", msg, published->application_message_size, spDefault);
|
||||||
if (res == PM3_SUCCESS) {
|
if (res == PM3_SUCCESS) {
|
||||||
PrintAndLogEx(INFO, "Got a json file, save OK");
|
PrintAndLogEx(INFO, "Got a json file ( %s )", _GREEN_("ok"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(SUCCESS, "[" _GREEN_("%s")"] " _YELLOW_("%s"), topic_name, msg);
|
PrintAndLogEx(SUCCESS, _GREEN_("%s") " - ( %zu ) " _YELLOW_("%s"), topic_name, published->application_message_size, msg);
|
||||||
}
|
}
|
||||||
free(topic_name);
|
free(topic_name);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +100,7 @@ static void mqtt_reconnect_client(struct mqtt_client* client, void **reconnect_s
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int mqtt_receive(const char *addr, const char *port, const char *topic) {
|
static int mqtt_receive(const char *addr, const char *port, const char *topic, const char *fn) {
|
||||||
// open the non-blocking TCP socket (connecting to the broker)
|
// open the non-blocking TCP socket (connecting to the broker)
|
||||||
int sockfd = open_nb_socket(addr, port);
|
int sockfd = open_nb_socket(addr, port);
|
||||||
if (sockfd == -1) {
|
if (sockfd == -1) {
|
||||||
|
@ -324,10 +322,10 @@ static int CmdMqttReceive(const char *Cmd) {
|
||||||
arg_str0(NULL, "addr", "<str>", "MQTT server address"),
|
arg_str0(NULL, "addr", "<str>", "MQTT server address"),
|
||||||
arg_str0("p", "port", "<str>", "MQTT server port"),
|
arg_str0("p", "port", "<str>", "MQTT server port"),
|
||||||
arg_str0(NULL, "topic", "<str>", "MQTT topic"),
|
arg_str0(NULL, "topic", "<str>", "MQTT topic"),
|
||||||
arg_str0("f", "file", "<fn>", "file to send"),
|
arg_str0("f", "file", "<fn>", "file name to use for received files"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
|
||||||
int alen = 0;
|
int alen = 0;
|
||||||
char addr[256] = {0x00};
|
char addr[256] = {0x00};
|
||||||
|
@ -363,7 +361,7 @@ static int CmdMqttReceive(const char *Cmd) {
|
||||||
strcpy(topic, "proxdump");
|
strcpy(topic, "proxdump");
|
||||||
}
|
}
|
||||||
|
|
||||||
return mqtt_receive(addr, port, topic);
|
return mqtt_receive(addr, port, topic, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue