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

Oskari Lemmelä oskari at lemmela.net
Mon Mar 7 09:59:53 PST 2022


Hi Jan-Niklas,

On 7.3.2022 14.14, Jan-Niklas Burfeind wrote:
> 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?
I did not validate then json after adding this feature. I should have
done it :)
I think the array is the best. At least I don't know a better solution.

Another similar problem is with multiple channels. One example in
interfrequency_lte_info.
That, too, should be fixed. In the qmi-service-nas.json file, they are
called frequency and cell arrays.
Maybe the plurals of the words frequencies or channels and cells are
good names for them.

Thanks,
Oskari

>
> 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)




More information about the openwrt-devel mailing list