From 331c0db5cfd2c575d73e424c823df5c65ecd438b Mon Sep 17 00:00:00 2001 From: Toon Stegen Date: Thu, 6 Jun 2019 21:45:29 +0200 Subject: [PATCH] driver/at: add return code for CME/CMS errors in case of CME or CMS errors, the error codes or human readable strings are in the response buffer. We want to indicate to the AT driver user that when tihs case occurrs so he can extract the error codes. --- drivers/at/at.c | 4 ++-- drivers/include/at.h | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/at/at.c b/drivers/at/at.c index ac682b0eb1..09ac4eae5a 100644 --- a/drivers/at/at.c +++ b/drivers/at/at.c @@ -208,10 +208,10 @@ ssize_t at_send_cmd_get_lines(at_dev_t *dev, const char *command, return -1; } else if (strncmp(pos, "+CME ERROR:", 11) == 0) { - return -1; + return -2; } else if (strncmp(pos, "+CMS ERROR:", 11) == 0) { - return -1; + return -2; } else { pos += res; diff --git a/drivers/include/at.h b/drivers/include/at.h index 8e26bd5381..056d589017 100644 --- a/drivers/include/at.h +++ b/drivers/include/at.h @@ -183,8 +183,9 @@ ssize_t at_send_cmd_get_resp(at_dev_t *dev, const char *command, char *resp_buf, * This function sends the supplied @p command, then returns all response * lines until the device sends "OK". * - * If a line starts with "ERROR" or "+CME ERROR:", or the buffer is full, the - * function returns -1. + * If a line starts with "ERROR" or the buffer is full, the function returns -1. + * If a line starts with "+CME ERROR" or +CMS ERROR", the function returns -2. + * In this case resp_buf contains the error string. * * @param[in] dev device to operate on * @param[in] command command to send @@ -194,7 +195,8 @@ ssize_t at_send_cmd_get_resp(at_dev_t *dev, const char *command, char *resp_buf, * @param[in] timeout timeout (in usec) * * @returns length of response on success - * @returns <0 on error + * @returns -1 on error + * @returns -2 on CMS or CME error */ ssize_t at_send_cmd_get_lines(at_dev_t *dev, const char *command, char *resp_buf, size_t len, bool keep_eol, uint32_t timeout);