Skip to content

Commit

Permalink
net: nrf_provisioning: Fix http request parameter names
Browse files Browse the repository at this point in the history
Update parameter names for maximum TX and RX response sizes to
match the latest API.

Increase buffer sizes and heap size.

Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
  • Loading branch information
juhaylinen authored and rlubos committed Jun 26, 2023
1 parent b8fecf8 commit 19ae1d3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion samples/nrf9160/nrf_provisioning/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ CONFIG_MODEM_INFO_ADD_SIM=n
CONFIG_MODEM_KEY_MGMT=y

# System
CONFIG_HEAP_MEM_POOL_SIZE=6144
CONFIG_HEAP_MEM_POOL_SIZE=16384
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_FPU=y
CONFIG_NEWLIB_LIBC=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ config NRF_PROVISIONING_CODEC_AT_CMD_LEN
config NRF_PROVISIONING_CODEC_RX_SZ_START
int "Default RX buff size, increased automatically up to 4K if necessary"
range 64 4096
default 512
default 1024

rsource "Kconfig.nrf_provisioning_cbor"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ config NRF_PROVISIONING_HTTP_RX_BUF_SZ

config NRF_PROVISIONING_HTTP_TX_BUF_SZ
int "Request body size"
default 1536
default 2048

rsource "Kconfig.nrf_provisioning_codec"

Expand Down
4 changes: 2 additions & 2 deletions subsys/net/lib/nrf_provisioning/src/nrf_provisioning_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ LOG_MODULE_REGISTER(nrf_provisioning_http, CONFIG_NRF_PROVISIONING_LOG_LEVEL);
#define API_GET_CMDS API_VER API_PRV "/commands"
#define CMDS_AFTER "after=%s"
#define CMDS_CVER "cver=%s"
#define CMDS_MAX_RX_SZ "rxSize=%s"
#define CMDS_MAX_TX_SZ "txSize=%s"
#define CMDS_MAX_RX_SZ "rxMaxSize=%s"
#define CMDS_MAX_TX_SZ "txMaxSize=%s"
#define CMDS_MVER "mver=%s"
#define API_CMDS_TEMPLATE (API_GET_CMDS "?" \
CMDS_AFTER "&" CMDS_MAX_RX_SZ "&" CMDS_MAX_TX_SZ "&" CMDS_MVER "&" CMDS_CVER)
Expand Down
26 changes: 13 additions & 13 deletions tests/subsys/net/lib/nrf_provisioning/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,19 @@ static int rest_client_request_url_valid(struct rest_client_req_context *req_ctx
char *cversion;
char *endpoint;
char *command;
char *txSize;
char *rxSize;
char *txMaxSize;
char *rxMaxSize;
};

/* 'txSize', 'rxSize', 'mver', 'cver' and 'after' */
/* 'txMaxSize', 'rxMaxSize', 'mver', 'cver' and 'after' */
char *query_items[QUERY_ITEMS_MAX] = { NULL, NULL, NULL, NULL };

struct url_info info = { .apiver = 0,
.mversion = NULL,
.endpoint = NULL,
.command = NULL,
.txSize = NULL,
.rxSize = NULL };
.txMaxSize = NULL,
.rxMaxSize = NULL };

tokens = (char *)malloc(strlen(req_ctx->url) + 1);

Expand Down Expand Up @@ -369,7 +369,7 @@ static int rest_client_request_url_valid(struct rest_client_req_context *req_ctx

resp_ctx->http_status_code = NRF_PROVISIONING_HTTP_STATUS_NO_CONTENT;

/* '/v1/provisioning/commands?txSize=1536&rxSize=1536&mver=1.3.2&cver=1' */
/* '/v1/provisioning/commands?txMaxSize=1536&rxMaxSize=1536&mver=1.3.2&cver=1' */

TEST_ASSERT_EQUAL_INT(3, sgmtc);
TEST_ASSERT_GREATER_OR_EQUAL_INT(1, atoi(&(info.apiver[1]))); /* No 'v' */
Expand All @@ -378,7 +378,7 @@ static int rest_client_request_url_valid(struct rest_client_req_context *req_ctx

/* At least 'after' */
TEST_ASSERT_GREATER_OR_EQUAL_INT(1, qcnt);
/* No more than 'txSize', 'rxSize', 'mver', 'cver' and 'after'*/
/* No more than 'txMaxSize', 'rxMaxSize', 'mver', 'cver' and 'after'*/
TEST_ASSERT_LESS_OR_EQUAL_INT(QUERY_ITEMS_MAX, qcnt);

for (int idx = 0; idx < QUERY_ITEMS_MAX && query_items[idx]; idx++) {
Expand All @@ -388,14 +388,14 @@ static int rest_client_request_url_valid(struct rest_client_req_context *req_ctx
} else if (strncmp(query_items[idx], "cver=", strlen("cver=")) == 0) {
info.cversion = &(query_items[idx][strlen("cver=")]);
TEST_ASSERT_GREATER_OR_EQUAL_INT(1, atoi(info.cversion));
} else if (strncmp(query_items[idx], "txSize=", strlen("txSize=")) == 0) {
info.txSize = &(query_items[idx][strlen("txSize=")]);
} else if (strncmp(query_items[idx], "txMaxSize=", strlen("txMaxSize=")) == 0) {
info.txMaxSize = &(query_items[idx][strlen("txMaxSize=")]);
TEST_ASSERT_EQUAL_INT(
CONFIG_NRF_PROVISIONING_HTTP_TX_BUF_SZ, atoi(info.txSize));
} else if (strncmp(query_items[idx], "rxSize=", strlen("rxSize=")) == 0) {
info.rxSize = &(query_items[idx][strlen("rxSize=")]);
CONFIG_NRF_PROVISIONING_HTTP_TX_BUF_SZ, atoi(info.txMaxSize));
} else if (strncmp(query_items[idx], "rxMaxSize=", strlen("rxMaxSize=")) == 0) {
info.rxMaxSize = &(query_items[idx][strlen("rxMaxSize=")]);
TEST_ASSERT_EQUAL_INT(
CONFIG_NRF_PROVISIONING_HTTP_RX_BUF_SZ, atoi(info.rxSize));
CONFIG_NRF_PROVISIONING_HTTP_RX_BUF_SZ, atoi(info.rxMaxSize));
} else if (strncmp(query_items[idx], "after=", strlen("after=")) == 0) {
;
} else {
Expand Down

0 comments on commit 19ae1d3

Please sign in to comment.