Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
HTTP fixes for cellular: timeout cannot be zero. (#1086)
Browse files Browse the repository at this point in the history
Cellular modules return an error if an attempt is made to set the HTTP timeout to zero:

AT+UHTTP=0,7,0
+CME ERROR: Operation not supported

This is pointed out in the description of uCellHttpOpen() and does not occur if the intended pattern of assigning uHttpClientConnection_t to U_HTTP_CLIENT_CONNECTION_DEFAULT when calling pUHttpClientOpen() is followed. However that pattern is not documented in the description of pUHttpClientOpen() and uCellHttpOpen() allows the timeout to be set to zero, which it should not.

Our thanks to jamal-mouline for highlighting this.
  • Loading branch information
RobMeades authored Feb 1, 2024
1 parent 2018c62 commit 0bf07df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cell/src/u_cell_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ int32_t uCellHttpOpen(uDeviceHandle_t cellHandle, const char *pServerName,
errorCodeOrHandle = (int32_t) U_ERROR_COMMON_INVALID_PARAMETER;
if ((pServerName != NULL) && (strlen(pServerName) <= U_CELL_HTTP_SERVER_NAME_MAX_LEN_BYTES) &&
((pUserName != NULL) || (pPassword == NULL)) &&
(timeoutSeconds >= 0) && (pCallback != NULL)) {
(timeoutSeconds > 0) && (pCallback != NULL)) {
errorCodeOrHandle = (int32_t) U_ERROR_COMMON_NO_MEMORY;
pHttpContext = pCellInstance->pHttpContext;
if (pHttpContext == NULL) {
Expand Down
5 changes: 5 additions & 0 deletions common/http_client/api/u_http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ typedef struct {
* potentially a callback function which
* would make the HTTP request functions
* non-blocking; cannot be NULL.
* IT IS GOOD PRACTICE to assign this,
* initially, to
* #U_HTTP_CLIENT_CONNECTION_DEFAULT and
* then modify the members you want
* to be different to the default value.
* @param[in] pSecurityTlsSettings a pointer to the security settings to
* be applied if you wish to make an HTTPS
* connection, NULL for no security.
Expand Down

0 comments on commit 0bf07df

Please sign in to comment.