[PATCH v2 2/2] command-nas: fix json output

Jan-Niklas Burfeind git at aiyionpri.me
Mon Mar 7 04:14:05 PST 2022


Output the cells from --get-cell-location-info in an array "cells".

Signed-off-by: Jan-Niklas Burfeind <git at aiyionpri.me>
---
Hey Oskari,
I think you original author would be you?
Have you got any suggestions how to name the cells array, or whether there's a cleaner way to fix the json output thats more how you intended it to be in the first place?

Thanks
Aiyion

 commands-nas.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/commands-nas.c b/commands-nas.c
index ff7a6c3..4b86304 100644
--- a/commands-nas.c
+++ b/commands-nas.c
@@ -708,7 +708,7 @@ static void
 cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
 {
 	struct qmi_nas_get_cell_location_info_response res;
-	void *c, *t, *cell, *freq;
+	void *c, *t, *cell, *cells, *freq;
 	int i, j;
 
 	qmi_parse_nas_get_cell_location_info_response(msg, &res);
@@ -769,6 +769,7 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
 			blobmsg_add_u32(&status, "s_intra_search_threshold",
 					res.data.intrafrequency_lte_info_v2.s_intra_search_threshold);
 		}
+		cells = blobmsg_open_array(&status, "cells");
 		for (i = 0; i < res.data.intrafrequency_lte_info_v2.cell_n; i++) {
 			cell = blobmsg_open_table(&status, NULL);
 			print_lte_info(res.data.intrafrequency_lte_info_v2.cell[i].physical_cell_id,
@@ -780,6 +781,7 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
 						res.data.intrafrequency_lte_info_v2.cell[i].cell_selection_rx_level);
 			blobmsg_close_table(&status, cell);
 		}
+		blobmsg_close_array(&status, cells);
 		blobmsg_close_table(&status, c);
 	}
 	if (res.set.interfrequency_lte_info) {
@@ -795,6 +797,7 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
 					       res.data.interfrequency_lte_info.frequency[i].cell_selection_rx_level_high_threshold,
 					       res.data.interfrequency_lte_info.frequency[i].cell_selection_rx_level_low_threshold);
 			}
+			cells = blobmsg_open_array(&status, "cells");
 			for (j = 0; j < res.data.interfrequency_lte_info.frequency[i].cell_n; j++) {
 				cell = blobmsg_open_table(&status, NULL);
 				print_lte_info(res.data.interfrequency_lte_info.frequency[i].cell[j].physical_cell_id,
@@ -806,6 +809,7 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
 							res.data.interfrequency_lte_info.frequency[i].cell[j].cell_selection_rx_level);
 				blobmsg_close_table(&status, cell);
 			}
+			blobmsg_close_array(&status, cells);
 			blobmsg_close_table(&status, freq);
 		}
 		if (res.data.interfrequency_lte_info.frequency_n > 0)
-- 
2.35.1




More information about the openwrt-devel mailing list