diff mbox series

[v3,2/2] command-nas: fix json output

Message ID 20220308150144.1617236-2-git@aiyionpri.me
State New
Headers show
Series [v3,1/2] command-nas: fix cmd_nas_get_cell_location_info_cb | expand

Commit Message

Jan-Niklas Burfeind March 8, 2022, 3:01 p.m. UTC
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@gmail.com>
Suggested-by: Oskari Lemmelä <oskari@lemmela.net>
Signed-off-by: Jan-Niklas Burfeind <git@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(-)

Comments

Jan-Niklas Burfeind March 14, 2022, 3:55 p.m. UTC | #1
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@gmail.com>
> Suggested-by: Oskari Lemmelä <oskari@lemmela.net>
> Signed-off-by: Jan-Niklas Burfeind <git@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);
>   }
Henrik Ginstmark March 16, 2022, 9 p.m. UTC | #2
Hi

You can break down LTE global-cell-id to enodeb_id and cell_id like this:

"intrafrequency_lte_info": {
"tracking_area_code": 14000,
"global_cell_id": 10498829,
=
"enodeb_id": 41011,
"cell_id": 13,

blobmsg_add_u32(&status,
"enodeb_id",res.data.intrafrequency_lte_info_v2.global_cell_id/256);
blobmsg_add_u32(&status,
"cell_id",res.data.intrafrequency_lte_info_v2.global_cell_id%256);

Same in nas_get_system_info and for UMTS global_cell_id you can break
down to rnc_id and
cell_id.

blobmsg_add_u32(&status, "rnc_id",res.data.wcdma_system_info_v2.cid/65536);
blobmsg_add_u32(&status, "cell_id",res.data.wcdma_system_info_v2.cid%65536);


Henrik

Den mån 14 mars 2022 kl 17:00 skrev Jan-Niklas Burfeind <git@aiyionpri.me>:
>
> 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@gmail.com>
> > Suggested-by: Oskari Lemmelä <oskari@lemmela.net>
> > Signed-off-by: Jan-Niklas Burfeind <git@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);
> >   }_______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Jan-Niklas Burfeind March 18, 2022, 11:33 a.m. UTC | #3
Hello Henrik,

I think changing the print_system_info function would require us to 
change its signature, wouldn't it?

The function is called with similar parameters from 2g,3g and 4g 
pendants. As the calculation and target values differ we'd need to add a 
uint for geneneration.

If that info is already extractable from another parameter let me know.
Else I'd implement a modified print function this weekend, that meets 
your reccomendation.

Any suggestions on the other two commits?

Jan-Niklas


On 3/16/22 22:00, Henrik Ginstmark wrote:
> Hi
> 
> You can break down LTE global-cell-id to enodeb_id and cell_id like this:
> 
> "intrafrequency_lte_info": {
> "tracking_area_code": 14000,
> "global_cell_id": 10498829,
> =
> "enodeb_id": 41011,
> "cell_id": 13,
> 
> blobmsg_add_u32(&status,
> "enodeb_id",res.data.intrafrequency_lte_info_v2.global_cell_id/256);
> blobmsg_add_u32(&status,
> "cell_id",res.data.intrafrequency_lte_info_v2.global_cell_id%256);
> 
> Same in nas_get_system_info and for UMTS global_cell_id you can break
> down to rnc_id and
> cell_id.
> 
> blobmsg_add_u32(&status, "rnc_id",res.data.wcdma_system_info_v2.cid/65536);
> blobmsg_add_u32(&status, "cell_id",res.data.wcdma_system_info_v2.cid%65536);
> 
> 
> Henrik
> 
> Den mån 14 mars 2022 kl 17:00 skrev Jan-Niklas Burfeind <git@aiyionpri.me>:
>>
>> 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@gmail.com>
>>> Suggested-by: Oskari Lemmelä <oskari@lemmela.net>
>>> Signed-off-by: Jan-Niklas Burfeind <git@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);
>>>    }_______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel@lists.openwrt.org
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Oskari Lemmelä March 18, 2022, 5:40 p.m. UTC | #4
Hi Jan,

The comments are below.

On 18.3.2022 13.33, Jan-Niklas Burfeind wrote:
> Hello Henrik,
>
> I think changing the print_system_info function would require us to
> change its signature, wouldn't it?
>
> The function is called with similar parameters from 2g,3g and 4g
> pendants. As the calculation and target values differ we'd need to add
> a uint for geneneration.
>
> If that info is already extractable from another parameter let me know.
> Else I'd implement a modified print function this weekend, that meets
> your reccomendation.
>
> Any suggestions on the other two commits?
>
> Jan-Niklas
>
>
> On 3/16/22 22:00, Henrik Ginstmark wrote:
>> Hi
>>
>> You can break down LTE global-cell-id to enodeb_id and cell_id like
>> this:
>>
>> "intrafrequency_lte_info": {
>> "tracking_area_code": 14000,
>> "global_cell_id": 10498829,
>> =
>> "enodeb_id": 41011,
>> "cell_id": 13,
>>
I was thinking about this, but since computing and terms vary between
technologies, I didn’t implement it
I also recommend leaving global_cell_id and only adding extra fields.
For example, the public cellmapper.net uses these global cell IDs for
different sectors.
 
>> blobmsg_add_u32(&status,
>> "enodeb_id",res.data.intrafrequency_lte_info_v2.global_cell_id/256);
>> blobmsg_add_u32(&status,
>> "cell_id",res.data.intrafrequency_lte_info_v2.global_cell_id%256);
>>
>> Same in nas_get_system_info and for UMTS global_cell_id you can break
>> down to rnc_id and
>> cell_id.
>>
>> blobmsg_add_u32(&status,
>> "rnc_id",res.data.wcdma_system_info_v2.cid/65536);
>> blobmsg_add_u32(&status,
>> "cell_id",res.data.wcdma_system_info_v2.cid%65536);
>>
>>
>> Henrik
>>
>> Den mån 14 mars 2022 kl 17:00 skrev Jan-Niklas Burfeind
>> <git@aiyionpri.me>:
>>>
>>> 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@gmail.com>
>>>> Suggested-by: Oskari Lemmelä <oskari@lemmela.net>
>>>> Signed-off-by: Jan-Niklas Burfeind <git@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.
>>>>
These res.data.umts_info_v2.neighboring_geran_n are only GSM channels
adjacent to UTMS.
Perhaps the use of channels is a better term because frequencies can be
a little misleading.
frequency_bands would be more accurate than just frequencies.

So I would use the term channels. I would replace geran with channels, too.

>>>> 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);
>>>>    }_______________________________________________
>>> openwrt-devel mailing list
>>> openwrt-devel@lists.openwrt.org
>>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>>
>> _______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel@lists.openwrt.org
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
diff mbox series

Patch

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