[PATCH v3 2/2] command-nas: fix json output
Jan-Niklas Burfeind
git at aiyionpri.me
Mon Mar 14 08:55:22 PDT 2022
Hey everyone,
I attached the current output of my patched uqmi.
Please let me know if you think the arrays should be named differently
or if you spot an error.
Thanks and have a nice day
Aiyion
On 3/8/22 16:01, Jan-Niklas Burfeind wrote:
> Output the cells from --get-cell-location-info in an array "cells",
> "geran" entries as an array called alike,
> and wrap output for different "frequencies" as such.
>
> Reported-by: Cezary Jackiewicz <cezary.jackiewicz at gmail.com>
> Suggested-by: Oskari Lemmelä <oskari at lemmela.net>
> Signed-off-by: Jan-Niklas Burfeind <git at aiyionpri.me>
> ---
> Hey Oskari and Cezary,
> Please have a thorough look at this, as I do not have the matching
> equipment at hand to test all cases.
> Let me know if you rather would see `frequencies` become `channels`
> and if the `geran`-array does make sense.
>
> I just compiled this series without errors and will have a look at the
> LTE-related json-outputs.
>
> Thanks for your time
> Jan-Niklas
>
> commands-nas.c | 46 +++++++++++++++++++++++++++++++++++++---------
> 1 file changed, 37 insertions(+), 9 deletions(-)
>
> diff --git a/commands-nas.c b/commands-nas.c
> index 275c53f..b99767f 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, *frequencies, *geran;
> int i, j;
>
> qmi_parse_nas_get_cell_location_info_response(msg, &res);
> @@ -724,6 +724,7 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
> res.data.umts_info_v2.primary_scrambling_code);
> blobmsg_add_u32(&status, "rscp", res.data.umts_info_v2.rscp);
> blobmsg_add_u32(&status, "ecio", res.data.umts_info_v2.ecio);
> + cells = blobmsg_open_array(&status, "cells");
> for (j = 0; j < res.data.umts_info_v2.cell_n; j++) {
> cell = blobmsg_open_table(&status, NULL);
> blobmsg_add_u32(&status, "channel",
> @@ -734,6 +735,8 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
> blobmsg_add_u32(&status, "ecio", res.data.umts_info_v2.cell[j].ecio);
> blobmsg_close_table(&status, cell);
> }
> + blobmsg_close_array(&status, cells);
> + geran = blobmsg_open_array(&status, "geran");
> for (j = 0; j < res.data.umts_info_v2.neighboring_geran_n; j++) {
> cell = blobmsg_open_table(&status, "neighboring_geran");
> blobmsg_add_u32(&status, "channel",
> @@ -746,6 +749,7 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
> res.data.umts_info_v2.neighboring_geran[j].rssi);
> blobmsg_close_table(&status, cell);
> }
> + blobmsg_close_array(&status, geran);
> blobmsg_close_table(&status, c);
> }
> if (res.set.intrafrequency_lte_info_v2) {
> @@ -769,6 +773,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,11 +785,14 @@ 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) {
> - if (res.data.interfrequency_lte_info.frequency_n > 0)
> + if (res.data.interfrequency_lte_info.frequency_n > 0) {
> c = blobmsg_open_table(&status, "interfrequency_lte_info");
> + frequencies = blobmsg_open_array(&status, "frequencies");
> + }
> for (i = 0; i < res.data.interfrequency_lte_info.frequency_n; i++) {
> freq = blobmsg_open_table(&status, NULL);
> blobmsg_add_u32(&status, "channel",
> @@ -795,6 +803,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,14 +815,19 @@ 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)
> + if (res.data.interfrequency_lte_info.frequency_n > 0) {
> + blobmsg_close_array(&status, frequencies);
> blobmsg_close_table(&status, c);
> + }
> }
> if (res.set.lte_info_neighboring_gsm) {
> - if (res.data.lte_info_neighboring_gsm.frequency_n > 0)
> + if (res.data.lte_info_neighboring_gsm.frequency_n > 0) {
> c = blobmsg_open_table(&status, "lte_info_neighboring_gsm");
> + frequencies = blobmsg_open_array(&status, "frequencies");
> + }
> for (i = 0; i < res.data.lte_info_neighboring_gsm.frequency_n; i++) {
> freq = blobmsg_open_table(&status, NULL);
> blobmsg_add_u32(&status, "ncc_permitted",
> @@ -823,6 +837,7 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
> res.data.lte_info_neighboring_gsm.frequency[i].cell_reselection_high_threshold,
> res.data.lte_info_neighboring_gsm.frequency[i].cell_reselection_low_threshold);
> }
> + cells = blobmsg_open_array(&status, "cells");
> for (j = 0; j < res.data.lte_info_neighboring_gsm.frequency[i].cell_n; j++) {
> cell = blobmsg_open_table(&status, NULL);
> blobmsg_add_u32(&status, "channel",
> @@ -836,14 +851,19 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
> res.data.lte_info_neighboring_gsm.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.lte_info_neighboring_gsm.frequency_n > 0)
> + if (res.data.lte_info_neighboring_gsm.frequency_n > 0) {
> + blobmsg_close_array(&status, frequencies);
> blobmsg_close_table(&status, c);
> + }
> }
> if (res.set.lte_info_neighboring_wcdma) {
> - if (res.data.lte_info_neighboring_wcdma.frequency_n > 0)
> + if (res.data.lte_info_neighboring_wcdma.frequency_n > 0) {
> c = blobmsg_open_table(&status, "lte_info_neighboring_wcdma");
> + frequencies = blobmsg_open_array(&status, "frequencies");
> + }
> for (i = 0; i < res.data.lte_info_neighboring_wcdma.frequency_n; i++) {
> freq = blobmsg_open_table(&status, NULL);
> blobmsg_add_u32(&status, "channel",
> @@ -853,6 +873,7 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
> res.data.lte_info_neighboring_wcdma.frequency[i].cell_reselection_high_threshold,
> res.data.lte_info_neighboring_wcdma.frequency[i].cell_reselection_low_threshold);
> }
> + cells = blobmsg_open_array(&status, "cells");
> for (j = 0; j < res.data.lte_info_neighboring_wcdma.frequency[i].cell_n; j++) {
> cell = blobmsg_open_table(&status, NULL);
> blobmsg_add_u32(&status, "primary_scrambling_code",
> @@ -866,14 +887,19 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
> res.data.lte_info_neighboring_wcdma.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.lte_info_neighboring_wcdma.frequency_n > 0)
> + if (res.data.lte_info_neighboring_wcdma.frequency_n > 0) {
> + blobmsg_close_array(&status, frequencies);
> blobmsg_close_table(&status, c);
> + }
> }
> if (res.set.umts_info_neighboring_lte) {
> - if (res.data.umts_info_neighboring_lte.frequency_n > 0)
> + if (res.data.umts_info_neighboring_lte.frequency_n > 0) {
> c = blobmsg_open_table(&status, "umts_info_neighboring_lte");
> + frequencies = blobmsg_open_array(&status, "frequencies");
> + }
> for (i = 0; i < res.data.umts_info_neighboring_lte.frequency_n; i++) {
> freq = blobmsg_open_table(&status, NULL);
> blobmsg_add_u32(&status, "channel",
> @@ -889,8 +915,10 @@ cmd_nas_get_cell_location_info_cb(struct qmi_dev *qmi, struct qmi_request *req,
> res.data.umts_info_neighboring_lte.frequency[i].cell_selection_rx_level);
> blobmsg_close_table(&status, freq);
> }
> - if (res.data.umts_info_neighboring_lte.frequency_n > 0)
> + if (res.data.umts_info_neighboring_lte.frequency_n > 0) {
> + blobmsg_close_array(&status, frequencies);
> blobmsg_close_table(&status, c);
> + }
> }
> blobmsg_close_table(&status, t);
> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2_testresult.json
Type: application/json
Size: 4935 bytes
Desc: not available
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20220314/b7843333/attachment-0001.json>
More information about the openwrt-devel
mailing list