SET(SOURCES main.c dev.c commands.c qmi-message.c)
-SET(LIBS ubox)
+FIND_LIBRARY(json json-c json)
+SET(LIBS ubox blobmsg_json ${json})
IF(DEBUG_PACKET)
ADD_DEFINITIONS(-DDEBUG_PACKET)
#include <unistd.h>
#include <libubox/blobmsg.h>
+#include <libubox/blobmsg_json.h>
#include "uqmi.h"
#include "commands.h"
static void uqmi_print_result(struct blob_attr *data)
{
- struct blob_attr *cur;
- int rem;
-
- blob_for_each_attr(cur, data, rem) {
- switch (blobmsg_type(cur)) {
- case BLOBMSG_TYPE_STRING:
- printf("%s=%s\n", blobmsg_name(cur), (char *) blobmsg_data(cur));
- break;
- case BLOBMSG_TYPE_INT32:
- printf("%s=%d\n", blobmsg_name(cur), (int32_t) blobmsg_get_u32(cur));
- break;
- case BLOBMSG_TYPE_INT8:
- printf("%s=%s\n", blobmsg_name(cur), blobmsg_get_u8(cur) ? "true" : "false");
- break;
- }
- }
+ char *str;
+
+ str = blobmsg_format_json_indent(data, true, 0);
+ if (!str)
+ return;
+
+ printf("%s\n", str);
+ free(str);
}
static bool __uqmi_run_commands(struct qmi_dev *qmi, bool option)