forked from nrfconnect/sdk-nrf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
treewide: Remove unnecessary modem dependencies related to MMSS
Remove various unnecessary modem dependencies that prevent building the MQTT Multi Service Sample for Wi-Fi-only targets. IRIS-6344 IRIS-5812 Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
- Loading branch information
1 parent
f2ce6c2
commit 9a5deca
Showing
16 changed files
with
180 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
samples/nrf9160/nrf_cloud_mqtt_multi_service/src/at_commands.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/logging/log.h> | ||
#include <nrf_modem_at.h> | ||
#include <nrf_errno.h> | ||
#include <modem/location.h> | ||
#include <cJSON.h> | ||
#include <stdio.h> | ||
|
||
#include "nrf_cloud_codec_internal.h" | ||
#include "connection.h" | ||
#include "at_commands.h" | ||
|
||
LOG_MODULE_REGISTER(at_cmd_execution, CONFIG_MQTT_MULTI_SERVICE_LOG_LEVEL); | ||
|
||
/* AT command request error handling */ | ||
#define AT_CMD_REQUEST_ERR_FORMAT "Error while processing AT command request: %d" | ||
#define AT_CMD_REQUEST_ERR_MAX_LEN (sizeof(AT_CMD_REQUEST_ERR_FORMAT) + 20) | ||
BUILD_ASSERT(CONFIG_AT_CMD_REQUEST_RESPONSE_BUFFER_LENGTH >= AT_CMD_REQUEST_ERR_MAX_LEN, | ||
"Not enough AT command response buffer for printing error events."); | ||
|
||
/* Buffer to contain modem responses when performing AT command requests */ | ||
static char at_cmd_resp_buf[CONFIG_AT_CMD_REQUEST_RESPONSE_BUFFER_LENGTH]; | ||
|
||
char *execute_at_cmd_request(const char *const cmd) | ||
{ | ||
LOG_DBG("Modem AT command requested: %s", cmd); | ||
|
||
/* Clear the response buffer */ | ||
memset(at_cmd_resp_buf, 0, sizeof(at_cmd_resp_buf)); | ||
|
||
/* Pass the command off to the modem. | ||
* | ||
* We must pass the command in using a format specifier it might contain special characters | ||
* such as %. | ||
* | ||
* We subtract 1 from the passed-in response buffer length to ensure that the response is | ||
* always null-terminated, even when the response is longer than the response buffer size. | ||
*/ | ||
|
||
int err = nrf_modem_at_cmd(at_cmd_resp_buf, sizeof(at_cmd_resp_buf) - 1, "%s", cmd); | ||
|
||
/* Post-process the response */ | ||
LOG_DBG("Modem AT command response (%d, %d): %s", | ||
nrf_modem_at_err_type(err), nrf_modem_at_err(err), at_cmd_resp_buf); | ||
|
||
/* Trim \r\n from modem response for better readability in the portal. */ | ||
at_cmd_resp_buf[MAX(0, strlen(at_cmd_resp_buf) - 2)] = '\0'; | ||
|
||
/* If an error occurred with the request, report it */ | ||
if (err < 0) { | ||
/* Negative error codes indicate an error with the modem lib itself, so the | ||
* response buffer will be empty (or filled with junk). Thus, we can print the | ||
* error message directly into it. | ||
*/ | ||
snprintf(at_cmd_resp_buf, sizeof(at_cmd_resp_buf), AT_CMD_REQUEST_ERR_FORMAT, err); | ||
LOG_ERR("%s", at_cmd_resp_buf); | ||
} | ||
|
||
/* Return a pointer to the start of the command response buffer (which is now populated with | ||
* the AT command response) | ||
*/ | ||
return &at_cmd_resp_buf[0]; | ||
} |
31 changes: 31 additions & 0 deletions
31
samples/nrf9160/nrf_cloud_mqtt_multi_service/src/at_commands.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#ifndef _AT_CMD_REQUESTS_H_ | ||
#define _AT_CMD_REQUESTS_H_ | ||
|
||
/** | ||
* @brief Forwards an AT command string to the modem, and returns a pointer | ||
* to a buffer containing the modem's response, or a human readable error. | ||
* | ||
* If CONFIG_NRF_MODEM_LIB is not enabled, the function is not compiled and always | ||
* returns an error string. | ||
* | ||
* Please note that the returned response buffer becomes unsafe to use as soon as | ||
* the next AT command request is made, so be sure to copy or handle the response before performing | ||
* another request. | ||
* | ||
* Do not modify the string in the returned response buffer. | ||
* | ||
* @param cmd - The AT command to execute. | ||
* @return char* a pointer into a NULL-terminated buffer containing the command response. | ||
*/ | ||
#if defined(CONFIG_NRF_MODEM_LIB) | ||
char *execute_at_cmd_request(const char *const cmd); | ||
#else /* CONFIG_NRF_MODEM_LIB */ | ||
#define execute_at_cmd_request(...) "AT command requests are not supported by this build!" | ||
#endif /* CONFIG_NRF_MODEM_LIB */ | ||
|
||
#endif /* _AT_CMD_REQUESTS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.