mirror of https://github.com/ARMmbed/mbed-os.git
review fixes to athandler: changing int16/8 to int's and some minor issues.
parent
0ee265110a
commit
0e20e49ef7
|
@ -372,7 +372,7 @@ public:
|
||||||
/** Get the last 3GPP error code
|
/** Get the last 3GPP error code
|
||||||
* @return see 3GPP TS 27.007 error codes
|
* @return see 3GPP TS 27.007 error codes
|
||||||
*/
|
*/
|
||||||
virtual uint8_t get_3gpp_error() = 0;
|
virtual int get_3gpp_error() = 0;
|
||||||
|
|
||||||
/** Get the operator params
|
/** Get the operator params
|
||||||
*
|
*
|
||||||
|
|
|
@ -251,9 +251,8 @@ void ATHandler::process_oob()
|
||||||
rtos::Thread::yield();
|
rtos::Thread::yield();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} while (timer.read_ms() < 100);
|
} while (timer.read_ms() < 20); // URC's are very short so 20ms should be enough
|
||||||
}
|
}
|
||||||
log_debug("process_oob exit");
|
log_debug("process_oob exit");
|
||||||
|
|
||||||
|
@ -309,17 +308,20 @@ void ATHandler::fill_buffer()
|
||||||
}
|
}
|
||||||
at_debug("\n----------readable----------\n");
|
at_debug("\n----------readable----------\n");
|
||||||
return;
|
return;
|
||||||
|
} else if (len != -EAGAIN && len != 0) {
|
||||||
|
log_warn("%s error: %d while reading", __func__, len);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#ifdef MBED_CONF_RTOS_PRESENT
|
#ifdef MBED_CONF_RTOS_PRESENT
|
||||||
rtos::Thread::yield();
|
rtos::Thread::yield();
|
||||||
#endif
|
#endif
|
||||||
} while (timer.read_ms() < _at_timeout);
|
} while ((uint32_t)timer.read_ms() < _at_timeout);
|
||||||
|
|
||||||
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
||||||
log_error("AT TIMEOUT, scope: %d timeout: %d", _current_scope, _at_timeout);
|
log_error("AT TIMEOUT, scope: %d timeout: %d", _current_scope, _at_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t ATHandler::get_char()
|
int ATHandler::get_char()
|
||||||
{
|
{
|
||||||
if (_recv_pos == _recv_len) {
|
if (_recv_pos == _recv_len) {
|
||||||
log_debug("%s", __func__);
|
log_debug("%s", __func__);
|
||||||
|
@ -343,10 +345,10 @@ void ATHandler::skip_param(uint32_t count)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i=0; (i < count && !_stop_tag->found); i++) {
|
for (uint32_t i = 0; (i < count && !_stop_tag->found); i++) {
|
||||||
size_t match_pos = 0;
|
size_t match_pos = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
int16_t c = get_char();
|
int c = get_char();
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
||||||
return;
|
return;
|
||||||
|
@ -373,10 +375,10 @@ void ATHandler::skip_param(ssize_t len, uint32_t count)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i=0; i < count; i++) {
|
for (uint32_t i = 0; i < count; i++) {
|
||||||
ssize_t read_len = 0;
|
ssize_t read_len = 0;
|
||||||
while (read_len < len) {
|
while (read_len < len) {
|
||||||
int16_t c = get_char();
|
int c = get_char();
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
||||||
return;
|
return;
|
||||||
|
@ -395,8 +397,8 @@ ssize_t ATHandler::read_bytes(uint8_t *buf, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t read_len = 0;
|
size_t read_len = 0;
|
||||||
for (; read_len<len; read_len++) {
|
for (; read_len < len; read_len++) {
|
||||||
int16_t c = get_char();
|
int c = get_char();
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -426,8 +428,8 @@ ssize_t ATHandler::read_string(char *buf, size_t size, bool read_even_stop_tag)
|
||||||
|
|
||||||
consume_char('\"');
|
consume_char('\"');
|
||||||
|
|
||||||
for (; len<(size + match_pos); len++) {
|
for (; len < (size + match_pos); len++) {
|
||||||
int16_t c = get_char();
|
int c = get_char();
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
pbuf[len] = '\0';
|
pbuf[len] = '\0';
|
||||||
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
||||||
|
@ -467,7 +469,7 @@ int32_t ATHandler::read_int()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buff[BUFF_SIZE] = {0};
|
char buff[BUFF_SIZE];
|
||||||
char *first_no_digit;
|
char *first_no_digit;
|
||||||
|
|
||||||
if (read_string(buff, (size_t)sizeof(buff)) == 0) {
|
if (read_string(buff, (size_t)sizeof(buff)) == 0) {
|
||||||
|
@ -618,12 +620,12 @@ void ATHandler::set_error(nsapi_error_t err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ATHandler::get_3gpp_error()
|
int ATHandler::get_3gpp_error()
|
||||||
{
|
{
|
||||||
return _last_3gpp_error;
|
return _last_3gpp_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATHandler::set_3gpp_error(uint8_t err, DeviceErrorType error_type)
|
void ATHandler::set_3gpp_error(int err, DeviceErrorType error_type)
|
||||||
{
|
{
|
||||||
if (_last_3gpp_error) { // don't overwrite likely root cause error
|
if (_last_3gpp_error) { // don't overwrite likely root cause error
|
||||||
return;
|
return;
|
||||||
|
@ -633,7 +635,7 @@ void ATHandler::set_3gpp_error(uint8_t err, DeviceErrorType error_type)
|
||||||
// CMS errors 0-127 maps straight to 3GPP errors
|
// CMS errors 0-127 maps straight to 3GPP errors
|
||||||
_last_3gpp_error = err;
|
_last_3gpp_error = err;
|
||||||
} else {
|
} else {
|
||||||
for (size_t i=0; i<sizeof(map_3gpp_errors)/sizeof(map_3gpp_errors[0]); i++) {
|
for (size_t i = 0; i<sizeof(map_3gpp_errors)/sizeof(map_3gpp_errors[0]); i++) {
|
||||||
if (map_3gpp_errors[i][0] == err) {
|
if (map_3gpp_errors[i][0] == err) {
|
||||||
_last_3gpp_error = map_3gpp_errors[i][1];
|
_last_3gpp_error = map_3gpp_errors[i][1];
|
||||||
log_debug("AT3GPP error code %d", get_3gpp_error());
|
log_debug("AT3GPP error code %d", get_3gpp_error());
|
||||||
|
@ -688,7 +690,7 @@ void ATHandler::resp(const char *prefix, bool check_urc)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(match_error()) {
|
if (match_error()) {
|
||||||
_error_found = true;
|
_error_found = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -813,7 +815,7 @@ bool ATHandler::info_elem(char start_tag)
|
||||||
bool ATHandler::consume_char(char ch)
|
bool ATHandler::consume_char(char ch)
|
||||||
{
|
{
|
||||||
log_debug("%s: %c", __func__, ch);
|
log_debug("%s: %c", __func__, ch);
|
||||||
int16_t read_char = get_char();
|
int read_char = get_char();
|
||||||
// If we read something else than ch, recover it
|
// If we read something else than ch, recover it
|
||||||
if (read_char != ch && read_char != -1) {
|
if (read_char != ch && read_char != -1) {
|
||||||
_recv_pos--;
|
_recv_pos--;
|
||||||
|
@ -828,7 +830,7 @@ bool ATHandler::consume_to_tag(const char *tag, bool consume_tag)
|
||||||
size_t match_pos = 0;
|
size_t match_pos = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int16_t c = get_char();
|
int c = get_char();
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
} else if (c == tag[match_pos]) {
|
} else if (c == tag[match_pos]) {
|
||||||
|
@ -959,7 +961,7 @@ void ATHandler::write_int(int32_t param)
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the integer subparameter
|
// write the integer subparameter
|
||||||
const uint8_t str_len = 12;
|
const int32_t str_len = 12;
|
||||||
char number_string[str_len];
|
char number_string[str_len];
|
||||||
int32_t result = std::snprintf(number_string, str_len, "%ld", param);
|
int32_t result = std::snprintf(number_string, str_len, "%ld", param);
|
||||||
if (result > 0 && result < str_len) {
|
if (result > 0 && result < str_len) {
|
||||||
|
@ -1010,7 +1012,7 @@ void ATHandler::cmd_stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ATHandler::write_bytes(uint8_t *data, size_t len)
|
size_t ATHandler::write_bytes(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
if (_last_err != NSAPI_ERROR_OK) {
|
if (_last_err != NSAPI_ERROR_OK) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -179,7 +179,7 @@ private:
|
||||||
|
|
||||||
events::EventQueue &_queue;
|
events::EventQueue &_queue;
|
||||||
nsapi_error_t _last_err;
|
nsapi_error_t _last_err;
|
||||||
nsapi_error_t _last_3gpp_error;
|
int _last_3gpp_error;
|
||||||
device_err_t _last_at_err;
|
device_err_t _last_at_err;
|
||||||
uint16_t _oob_string_max_length;
|
uint16_t _oob_string_max_length;
|
||||||
char *_output_delimiter;
|
char *_output_delimiter;
|
||||||
|
@ -239,7 +239,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return number of characters successfully written
|
* @return number of characters successfully written
|
||||||
*/
|
*/
|
||||||
size_t write_bytes(uint8_t *data, size_t len);
|
size_t write_bytes(const uint8_t *data, size_t len);
|
||||||
|
|
||||||
/** Sets the stop tag for the current scope(response/information response/element)
|
/** Sets the stop tag for the current scope(response/information response/element)
|
||||||
* Parameter's reading routines will stop the reading when such tag is found and will set the found flag.
|
* Parameter's reading routines will stop the reading when such tag is found and will set the found flag.
|
||||||
|
@ -343,7 +343,7 @@ public:
|
||||||
/** Return the last 3GPP error code.
|
/** Return the last 3GPP error code.
|
||||||
* @return last 3GPP error code
|
* @return last 3GPP error code
|
||||||
*/
|
*/
|
||||||
uint8_t get_3gpp_error();
|
int get_3gpp_error();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ private:
|
||||||
|
|
||||||
// Gets char from receiving buffer.
|
// Gets char from receiving buffer.
|
||||||
// Resets and fills the buffer if all are already read (receiving position equals receiving length).
|
// Resets and fills the buffer if all are already read (receiving position equals receiving length).
|
||||||
int16_t get_char();
|
int get_char();
|
||||||
// Sets to 0 the reading position, reading length and the whole buffer content.
|
// Sets to 0 the reading position, reading length and the whole buffer content.
|
||||||
void reset_buffer();
|
void reset_buffer();
|
||||||
// Reading position set to 0 and buffer's unread content moved to beginning
|
// Reading position set to 0 and buffer's unread content moved to beginning
|
||||||
|
@ -439,7 +439,7 @@ private:
|
||||||
* @param err AT error code read from CME/CMS ERROR responses
|
* @param err AT error code read from CME/CMS ERROR responses
|
||||||
* @param error_type error type (CMS/CME/ERROR)
|
* @param error_type error type (CMS/CME/ERROR)
|
||||||
*/
|
*/
|
||||||
void set_3gpp_error(uint8_t err, DeviceErrorType error_type);
|
void set_3gpp_error(int err, DeviceErrorType error_type);
|
||||||
|
|
||||||
bool check_cmd_send();
|
bool check_cmd_send();
|
||||||
bool write_char(char c);
|
bool write_char(char c);
|
||||||
|
|
|
@ -928,7 +928,7 @@ nsapi_error_t AT_CellularNetwork::get_signal_quality(int &rssi, int &ber)
|
||||||
/** Get the last 3GPP error code
|
/** Get the last 3GPP error code
|
||||||
* @return see 3GPP TS 27.007 error codes
|
* @return see 3GPP TS 27.007 error codes
|
||||||
*/
|
*/
|
||||||
uint8_t AT_CellularNetwork::get_3gpp_error()
|
int AT_CellularNetwork::get_3gpp_error()
|
||||||
{
|
{
|
||||||
return _at.get_3gpp_error();
|
return _at.get_3gpp_error();
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ public: // CellularNetwork
|
||||||
/** Get the last 3GPP error code
|
/** Get the last 3GPP error code
|
||||||
* @return see 3GPP TS 27.007 error codes
|
* @return see 3GPP TS 27.007 error codes
|
||||||
*/
|
*/
|
||||||
virtual uint8_t get_3gpp_error();
|
virtual int get_3gpp_error();
|
||||||
|
|
||||||
/** Get the operator params
|
/** Get the operator params
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue