#include <unistd.h>
#include <libubox/blobmsg.h>
+#include <libubox/blobmsg_json.h>
#include "uqmi.h"
#include "commands.h"
#include "commands-wds.c"
#include "commands-dms.c"
#include "commands-nas.c"
+#include "commands-wms.c"
#define __uqmi_command(_name, _optname, _arg, _type) \
[__UQMI_COMMAND_##_name] = { \
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)