1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00

drivers/at : Add CONFIG_

Add CONFIG_ prefix to AT_SEND_EOL,  AT_SEND_SKIP_ECHO,
CONFIG_AT_RECV_OK, CONFIG_AT_RECV_ERROR
This commit is contained in:
Akshai M 2020-05-04 21:57:39 +05:30
parent 921badbf38
commit f9741b3ed5
3 changed files with 29 additions and 27 deletions

View File

@ -114,14 +114,14 @@ int at_send_cmd(at_dev_t *dev, const char *command, uint32_t timeout)
size_t cmdlen = strlen(command);
uart_write(dev->uart, (const uint8_t *)command, cmdlen);
uart_write(dev->uart, (const uint8_t *)AT_SEND_EOL, AT_SEND_EOL_LEN);
uart_write(dev->uart, (const uint8_t *)CONFIG_AT_SEND_EOL, AT_SEND_EOL_LEN);
if (AT_SEND_ECHO) {
if (at_expect_bytes(dev, command, timeout)) {
return -1;
}
if (at_expect_bytes(dev, AT_SEND_EOL AT_RECV_EOL_1 AT_RECV_EOL_2, timeout)) {
if (at_expect_bytes(dev, CONFIG_AT_SEND_EOL AT_RECV_EOL_1 AT_RECV_EOL_2, timeout)) {
return -2;
}
}
@ -194,17 +194,17 @@ ssize_t at_send_cmd_get_lines(at_dev_t *dev, const char *command,
}
else if (res > 0) {
bytes_left -= res;
size_t len_ok = sizeof(AT_RECV_OK) - 1;
size_t len_error = sizeof(AT_RECV_ERROR) - 1;
size_t len_ok = sizeof(CONFIG_AT_RECV_OK) - 1;
size_t len_error = sizeof(CONFIG_AT_RECV_ERROR) - 1;
if (((size_t )res == (len_ok + keep_eol)) &&
(len_ok != 0) &&
(strncmp(pos, AT_RECV_OK, len_ok) == 0)) {
(strncmp(pos, CONFIG_AT_RECV_OK, len_ok) == 0)) {
res = len - bytes_left;
break;
}
else if (((size_t )res == (len_error + keep_eol)) &&
(len_error != 0) &&
(strncmp(pos, AT_RECV_ERROR, len_error) == 0)) {
(strncmp(pos, CONFIG_AT_RECV_ERROR, len_error) == 0)) {
return -1;
}
else if (strncmp(pos, "+CME ERROR:", 11) == 0) {
@ -240,13 +240,13 @@ int at_send_cmd_wait_prompt(at_dev_t *dev, const char *command, uint32_t timeout
at_drain(dev);
uart_write(dev->uart, (const uint8_t *)command, cmdlen);
uart_write(dev->uart, (const uint8_t *)AT_SEND_EOL, AT_SEND_EOL_LEN);
uart_write(dev->uart, (const uint8_t *)CONFIG_AT_SEND_EOL, AT_SEND_EOL_LEN);
if (at_expect_bytes(dev, command, timeout)) {
return -1;
}
if (at_expect_bytes(dev, AT_SEND_EOL AT_RECV_EOL_2, timeout)) {
if (at_expect_bytes(dev, CONFIG_AT_SEND_EOL AT_RECV_EOL_2, timeout)) {
return -2;
}
@ -265,8 +265,8 @@ int at_send_cmd_wait_ok(at_dev_t *dev, const char *command, uint32_t timeout)
res = at_send_cmd_get_resp(dev, command, resp_buf, sizeof(resp_buf), timeout);
if (res > 0) {
ssize_t len_ok = sizeof(AT_RECV_OK) - 1;
if ((len_ok != 0) && (strcmp(resp_buf, AT_RECV_OK) == 0)) {
ssize_t len_ok = sizeof(CONFIG_AT_RECV_OK) - 1;
if ((len_ok != 0) && (strcmp(resp_buf, CONFIG_AT_RECV_OK) == 0)) {
res = 0;
}
else {

View File

@ -54,25 +54,25 @@ extern "C" {
/**
* @brief End of line character to send after the AT command.
*/
#ifndef AT_SEND_EOL
#define AT_SEND_EOL "\r"
#ifndef CONFIG_AT_SEND_EOL
#define CONFIG_AT_SEND_EOL "\r"
#endif
/**
* @brief Disable echo after an AT command is sent.
*/
#ifdef DOXYGEN
#define AT_SEND_SKIP_ECHO
#define CONFIG_AT_SEND_SKIP_ECHO
#endif
/**
* @brief Enable/disable the expected echo after an AT command is sent.
*
* @deprecated Use inverse @ref AT_SEND_SKIP_ECHO instead.
*
* @deprecated Use inverse @ref CONFIG_AT_SEND_SKIP_ECHO instead.
* Will be removed after 2021.01 release.
*/
#ifndef AT_SEND_ECHO
#if IS_ACTIVE(AT_SEND_SKIP_ECHO)
#if IS_ACTIVE(CONFIG_AT_SEND_SKIP_ECHO)
#define AT_SEND_ECHO 0
#else
#define AT_SEND_ECHO 1
@ -96,26 +96,25 @@ extern "C" {
/**
* @brief default OK reply of an AT device.
*/
#ifndef AT_RECV_OK
#define AT_RECV_OK "OK"
#ifndef CONFIG_AT_RECV_OK
#define CONFIG_AT_RECV_OK "OK"
#endif
/**
* @brief default ERROR reply of an AT device.
*/
#ifndef AT_RECV_ERROR
#define AT_RECV_ERROR "ERROR"
#ifndef CONFIG_AT_RECV_ERROR
#define CONFIG_AT_RECV_ERROR "ERROR"
#endif
/** @} */
/** Shortcut for getting send end of line length */
#define AT_SEND_EOL_LEN (sizeof(AT_SEND_EOL) - 1)
/**
* @brief Internal buffer size used to process unsolicited result code data.
*/
#if defined(MODULE_AT_URC) || DOXYGEN
#ifndef AT_BUF_SIZE
/** Internal buffer size used to process unsolicited result code data */
#define AT_BUF_SIZE (128)
#endif
/** @} */
/**
* @brief Unsolicited result code callback
@ -137,6 +136,9 @@ typedef struct {
#endif /* MODULE_AT_URC */
/** Shortcut for getting send end of line length */
#define AT_SEND_EOL_LEN (sizeof(CONFIG_AT_SEND_EOL) - 1)
/**
* @brief AT device structure
*/

View File

@ -124,7 +124,7 @@ static int send_recv_bytes(int argc, char **argv)
return 1;
}
sprintf(buffer, "%s%s", argv[1], AT_SEND_EOL);
sprintf(buffer, "%s%s", argv[1], CONFIG_AT_SEND_EOL);
at_send_bytes(&at_dev, buffer, strlen(buffer));
ssize_t len = at_recv_bytes(&at_dev, buffer, atoi(argv[2]), 10 * US_PER_SEC);
@ -146,7 +146,7 @@ static int send_recv_bytes_until_string(int argc, char **argv)
return 1;
}
sprintf(buffer, "%s%s", argv[1], AT_SEND_EOL);
sprintf(buffer, "%s%s", argv[1], CONFIG_AT_SEND_EOL);
at_send_bytes(&at_dev, buffer, strlen(buffer));
memset(buffer, 0, sizeof(buffer));