Skip to content

Commit 0dbb07d

Browse files
plskeggsrlubos
authored andcommitted
net: lib: nrf_cloud_coap: Net info optional for AGNSS
Move all the network info fields to an optional section of the AGNSS CDDL. Rebuild codecs with zcbor. Adjust coap_codec_agnss_encode() accordingly. Signed-off-by: Pete Skeggs <[email protected]>
1 parent 1f5aa4c commit 0dbb07d

File tree

6 files changed

+135
-39
lines changed

6 files changed

+135
-39
lines changed

subsys/net/lib/nrf_cloud/coap/cddl/nrf_cloud_coap_agnss.cddl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
agnss_req = {
1212
? types => [1*13 int],
13-
eci => uint,
13+
? eci => uint,
1414
? filtered => bool,
1515
? mask => uint,
16-
mcc => uint,
17-
mnc => uint,
16+
? mcc => uint,
17+
? mnc => uint,
1818
? rsrp => int,
19-
tac => uint
19+
? tac => uint
2020
}
2121

2222
types = 1

subsys/net/lib/nrf_cloud/coap/include/agnss_encode_types.h

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ struct agnss_req_types_r {
3232
size_t agnss_req_types_int_count;
3333
};
3434

35+
struct agnss_req_eci {
36+
uint32_t agnss_req_eci;
37+
};
38+
3539
struct agnss_req_filtered {
3640
bool agnss_req_filtered;
3741
};
@@ -40,23 +44,39 @@ struct agnss_req_mask {
4044
uint32_t agnss_req_mask;
4145
};
4246

47+
struct agnss_req_mcc {
48+
uint32_t agnss_req_mcc;
49+
};
50+
51+
struct agnss_req_mnc {
52+
uint32_t agnss_req_mnc;
53+
};
54+
4355
struct agnss_req_rsrp {
4456
int32_t agnss_req_rsrp;
4557
};
4658

59+
struct agnss_req_tac {
60+
uint32_t agnss_req_tac;
61+
};
62+
4763
struct agnss_req {
4864
struct agnss_req_types_r agnss_req_types;
4965
bool agnss_req_types_present;
50-
uint32_t agnss_req_eci;
66+
struct agnss_req_eci agnss_req_eci;
67+
bool agnss_req_eci_present;
5168
struct agnss_req_filtered agnss_req_filtered;
5269
bool agnss_req_filtered_present;
5370
struct agnss_req_mask agnss_req_mask;
5471
bool agnss_req_mask_present;
55-
uint32_t agnss_req_mcc;
56-
uint32_t agnss_req_mnc;
72+
struct agnss_req_mcc agnss_req_mcc;
73+
bool agnss_req_mcc_present;
74+
struct agnss_req_mnc agnss_req_mnc;
75+
bool agnss_req_mnc_present;
5776
struct agnss_req_rsrp agnss_req_rsrp;
5877
bool agnss_req_rsrp_present;
59-
uint32_t agnss_req_tac;
78+
struct agnss_req_tac agnss_req_tac;
79+
bool agnss_req_tac_present;
6080
};
6181

6282
#ifdef __cplusplus

subsys/net/lib/nrf_cloud/coap/src/agnss_encode.c

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121

2222
static bool encode_repeated_agnss_req_types(zcbor_state_t *state,
2323
const struct agnss_req_types_r *input);
24+
static bool encode_repeated_agnss_req_eci(zcbor_state_t *state, const struct agnss_req_eci *input);
2425
static bool encode_repeated_agnss_req_filtered(zcbor_state_t *state,
2526
const struct agnss_req_filtered *input);
2627
static bool encode_repeated_agnss_req_mask(zcbor_state_t *state,
2728
const struct agnss_req_mask *input);
29+
static bool encode_repeated_agnss_req_mcc(zcbor_state_t *state, const struct agnss_req_mcc *input);
30+
static bool encode_repeated_agnss_req_mnc(zcbor_state_t *state, const struct agnss_req_mnc *input);
2831
static bool encode_repeated_agnss_req_rsrp(zcbor_state_t *state,
2932
const struct agnss_req_rsrp *input);
33+
static bool encode_repeated_agnss_req_tac(zcbor_state_t *state, const struct agnss_req_tac *input);
3034
static bool encode_agnss_req(zcbor_state_t *state, const struct agnss_req *input);
3135

3236
static bool encode_repeated_agnss_req_types(zcbor_state_t *state,
@@ -53,6 +57,23 @@ static bool encode_repeated_agnss_req_types(zcbor_state_t *state,
5357
return tmp_result;
5458
}
5559

60+
static bool encode_repeated_agnss_req_eci(zcbor_state_t *state, const struct agnss_req_eci *input)
61+
{
62+
zcbor_log("%s\r\n", __func__);
63+
64+
bool tmp_result = ((((zcbor_uint32_put(state, (2)))) &&
65+
(zcbor_uint32_encode(state, (&(*input).agnss_req_eci)))));
66+
67+
if (!tmp_result) {
68+
zcbor_trace_file(state);
69+
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
70+
} else {
71+
zcbor_log("%s success\r\n", __func__);
72+
}
73+
74+
return tmp_result;
75+
}
76+
5677
static bool encode_repeated_agnss_req_filtered(zcbor_state_t *state,
5778
const struct agnss_req_filtered *input)
5879
{
@@ -88,6 +109,40 @@ static bool encode_repeated_agnss_req_mask(zcbor_state_t *state, const struct ag
88109
return tmp_result;
89110
}
90111

112+
static bool encode_repeated_agnss_req_mcc(zcbor_state_t *state, const struct agnss_req_mcc *input)
113+
{
114+
zcbor_log("%s\r\n", __func__);
115+
116+
bool tmp_result = ((((zcbor_uint32_put(state, (5)))) &&
117+
(zcbor_uint32_encode(state, (&(*input).agnss_req_mcc)))));
118+
119+
if (!tmp_result) {
120+
zcbor_trace_file(state);
121+
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
122+
} else {
123+
zcbor_log("%s success\r\n", __func__);
124+
}
125+
126+
return tmp_result;
127+
}
128+
129+
static bool encode_repeated_agnss_req_mnc(zcbor_state_t *state, const struct agnss_req_mnc *input)
130+
{
131+
zcbor_log("%s\r\n", __func__);
132+
133+
bool tmp_result = ((((zcbor_uint32_put(state, (6)))) &&
134+
(zcbor_uint32_encode(state, (&(*input).agnss_req_mnc)))));
135+
136+
if (!tmp_result) {
137+
zcbor_trace_file(state);
138+
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
139+
} else {
140+
zcbor_log("%s success\r\n", __func__);
141+
}
142+
143+
return tmp_result;
144+
}
145+
91146
static bool encode_repeated_agnss_req_rsrp(zcbor_state_t *state, const struct agnss_req_rsrp *input)
92147
{
93148
zcbor_log("%s\r\n", __func__);
@@ -105,6 +160,23 @@ static bool encode_repeated_agnss_req_rsrp(zcbor_state_t *state, const struct ag
105160
return tmp_result;
106161
}
107162

163+
static bool encode_repeated_agnss_req_tac(zcbor_state_t *state, const struct agnss_req_tac *input)
164+
{
165+
zcbor_log("%s\r\n", __func__);
166+
167+
bool tmp_result = ((((zcbor_uint32_put(state, (8)))) &&
168+
(zcbor_uint32_encode(state, (&(*input).agnss_req_tac)))));
169+
170+
if (!tmp_result) {
171+
zcbor_trace_file(state);
172+
zcbor_log("%s error: %s\r\n", __func__, zcbor_error_str(zcbor_peek_error(state)));
173+
} else {
174+
zcbor_log("%s success\r\n", __func__);
175+
}
176+
177+
return tmp_result;
178+
}
179+
108180
static bool encode_agnss_req(zcbor_state_t *state, const struct agnss_req *input)
109181
{
110182
zcbor_log("%s\r\n", __func__);
@@ -113,20 +185,20 @@ static bool encode_agnss_req(zcbor_state_t *state, const struct agnss_req *input
113185
(((zcbor_map_start_encode(state, 8) &&
114186
(((!(*input).agnss_req_types_present ||
115187
encode_repeated_agnss_req_types(state, (&(*input).agnss_req_types))) &&
116-
(((zcbor_uint32_put(state, (2)))) &&
117-
(zcbor_uint32_encode(state, (&(*input).agnss_req_eci)))) &&
188+
(!(*input).agnss_req_eci_present ||
189+
encode_repeated_agnss_req_eci(state, (&(*input).agnss_req_eci))) &&
118190
(!(*input).agnss_req_filtered_present ||
119191
encode_repeated_agnss_req_filtered(state, (&(*input).agnss_req_filtered))) &&
120192
(!(*input).agnss_req_mask_present ||
121193
encode_repeated_agnss_req_mask(state, (&(*input).agnss_req_mask))) &&
122-
(((zcbor_uint32_put(state, (5)))) &&
123-
(zcbor_uint32_encode(state, (&(*input).agnss_req_mcc)))) &&
124-
(((zcbor_uint32_put(state, (6)))) &&
125-
(zcbor_uint32_encode(state, (&(*input).agnss_req_mnc)))) &&
194+
(!(*input).agnss_req_mcc_present ||
195+
encode_repeated_agnss_req_mcc(state, (&(*input).agnss_req_mcc))) &&
196+
(!(*input).agnss_req_mnc_present ||
197+
encode_repeated_agnss_req_mnc(state, (&(*input).agnss_req_mnc))) &&
126198
(!(*input).agnss_req_rsrp_present ||
127199
encode_repeated_agnss_req_rsrp(state, (&(*input).agnss_req_rsrp))) &&
128-
(((zcbor_uint32_put(state, (8)))) &&
129-
(zcbor_uint32_encode(state, (&(*input).agnss_req_tac))))) ||
200+
(!(*input).agnss_req_tac_present ||
201+
encode_repeated_agnss_req_tac(state, (&(*input).agnss_req_tac)))) ||
130202
(zcbor_list_map_end_force_encode(state), false)) &&
131203
zcbor_map_end_encode(state, 8))));
132204

subsys/net/lib/nrf_cloud/coap/src/coap_codec.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,17 +414,21 @@ int coap_codec_agnss_encode(struct nrf_cloud_rest_agnss_request const *const req
414414
memset(&input, 0, sizeof(struct agnss_req));
415415

416416
if (request->net_info != NULL) {
417-
input.agnss_req_eci = request->net_info->current_cell.id;
418-
input.agnss_req_mcc = request->net_info->current_cell.mcc;
419-
input.agnss_req_mnc = request->net_info->current_cell.mnc;
420-
input.agnss_req_tac = request->net_info->current_cell.tac;
421-
if (request->net_info->current_cell.rsrp != NRF_CLOUD_LOCATION_CELL_OMIT_RSRP) {
422-
input.agnss_req_rsrp.agnss_req_rsrp = request->net_info->current_cell.rsrp;
417+
if (request->net_info->current_cell.id != LTE_LC_CELL_EUTRAN_ID_MAX) {
418+
input.agnss_req_eci_present = true;
419+
input.agnss_req_eci.agnss_req_eci = request->net_info->current_cell.id;
420+
}
421+
input.agnss_req_mcc_present = true;
422+
input.agnss_req_mcc.agnss_req_mcc = request->net_info->current_cell.mcc;
423+
input.agnss_req_mnc_present = true;
424+
input.agnss_req_mnc.agnss_req_mnc = request->net_info->current_cell.mnc;
425+
input.agnss_req_tac_present = true;
426+
input.agnss_req_tac.agnss_req_tac = request->net_info->current_cell.tac;
427+
if (request->net_info->current_cell.rsrp != LTE_LC_CELL_RSRP_INVALID) {
423428
input.agnss_req_rsrp_present = true;
429+
input.agnss_req_rsrp.agnss_req_rsrp = request->net_info->current_cell.rsrp;
424430
}
425431
} else {
426-
input.agnss_req_eci = LTE_LC_CELL_EUTRAN_ID_INVALID;
427-
input.agnss_req_tac = LTE_LC_CELL_TAC_INVALID;
428432
LOG_DBG("No net_info provided.");
429433
}
430434

subsys/net/lib/nrf_cloud/coap/src/msg_encode.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,21 @@ static bool encode_message_out(zcbor_state_t *state, const struct message_out *i
137137
(zcbor_tstr_encode(state, (&(*input).message_out_appId)))) &&
138138
(((zcbor_uint32_put(state, (2)))) &&
139139
(((*input).message_out_data_choice == message_out_data_tstr_c)
140-
? ((zcbor_tstr_encode(state, (&(*input).message_out_data_tstr))))
141-
: (((*input).message_out_data_choice == message_out_data_float_c)
142-
? ((zcbor_float64_encode(
143-
state, (&(*input).message_out_data_float))))
144-
: (((*input).message_out_data_choice ==
145-
message_out_data_int_c)
146-
? ((zcbor_int32_encode(
147-
state,
148-
(&(*input).message_out_data_int))))
149-
: (((*input).message_out_data_choice ==
150-
message_out_data_pvt_m_c)
151-
? ((encode_pvt(
152-
state,
153-
(&(*input).message_out_data_pvt_m))))
154-
: false))))) &&
140+
? ((zcbor_tstr_encode(state, (&(*input).message_out_data_tstr))))
141+
: (((*input).message_out_data_choice == message_out_data_float_c)
142+
? ((zcbor_float64_encode(
143+
state, (&(*input).message_out_data_float))))
144+
: (((*input).message_out_data_choice ==
145+
message_out_data_int_c)
146+
? ((zcbor_int32_encode(
147+
state,
148+
(&(*input).message_out_data_int))))
149+
: (((*input).message_out_data_choice ==
150+
message_out_data_pvt_m_c)
151+
? ((encode_pvt(
152+
state,
153+
(&(*input).message_out_data_pvt_m))))
154+
: false))))) &&
155155
(!(*input).message_out_ts_present ||
156156
encode_repeated_message_out_ts(state, (&(*input).message_out_ts)))) ||
157157
(zcbor_list_map_end_force_encode(state), false)) &&

subsys/net/lib/nrf_cloud/coap/update_codec.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)