mirror of https://github.com/ARMmbed/mbed-os.git
- BC95 socket creation bug fix
- Cellular information reading stopping on comma fixedpull/6082/head
parent
d2e8691754
commit
22e7fbd7e8
|
|
@ -49,6 +49,7 @@ const uint8_t CMS_ERROR_LENGTH = 11;
|
|||
const char *ERROR_ = "ERROR\r\n";
|
||||
const uint8_t ERROR_LENGTH = 7;
|
||||
const uint8_t MAX_RESP_LENGTH = CMS_ERROR_LENGTH;
|
||||
const char DEFAULT_DELIMITER = ',';
|
||||
|
||||
static const uint8_t map_3gpp_errors[][2] = {
|
||||
{ 103, 3 }, { 106, 6 }, { 107, 7 }, { 108, 8 }, { 111, 11 }, { 112, 12 }, { 113, 13 }, { 114, 14 },
|
||||
|
|
@ -72,7 +73,7 @@ ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char
|
|||
_processing(false),
|
||||
_ref_count(1),
|
||||
_stop_tag(NULL),
|
||||
_delimiter(','),
|
||||
_delimiter(DEFAULT_DELIMITER),
|
||||
_prefix_matched(false),
|
||||
_urc_matched(false),
|
||||
_error_found(false),
|
||||
|
|
@ -411,7 +412,7 @@ ssize_t ATHandler::read_bytes(uint8_t *buf, size_t len)
|
|||
ssize_t ATHandler::read_string(char *buf, size_t size, bool read_even_stop_tag)
|
||||
{
|
||||
tr_debug("%s", __func__);
|
||||
at_debug("\n----------buff:----------\n");
|
||||
at_debug("\n----------read_string buff:----------\n");
|
||||
for (size_t i = _recv_pos; i < _recv_len; i++) {
|
||||
at_debug("%c", _recv_buff[i]);
|
||||
}
|
||||
|
|
@ -484,6 +485,11 @@ void ATHandler::set_delimiter(char delimiter)
|
|||
_delimiter = delimiter;
|
||||
}
|
||||
|
||||
void ATHandler::set_default_delimiter()
|
||||
{
|
||||
_delimiter = DEFAULT_DELIMITER;
|
||||
}
|
||||
|
||||
void ATHandler::set_tag(tag_t* tag_dst, const char *tag_seq)
|
||||
{
|
||||
if (tag_seq) {
|
||||
|
|
@ -560,7 +566,7 @@ bool ATHandler::match_urc()
|
|||
prefix_len = strlen(oob->prefix);
|
||||
if (_recv_len >= prefix_len) {
|
||||
if (match(oob->prefix, prefix_len)) {
|
||||
tr_debug("URC!");
|
||||
tr_debug("URC! %s", oob->prefix);
|
||||
set_scope(InfoType);
|
||||
if (oob->cb) {
|
||||
oob->cb();
|
||||
|
|
@ -670,7 +676,7 @@ void ATHandler::resp(const char *prefix, bool check_urc)
|
|||
{
|
||||
tr_debug("%s: %s", __func__, prefix);
|
||||
|
||||
at_debug("\n----------buff:----------\n");
|
||||
at_debug("\n----------resp buff:----------\n");
|
||||
for (size_t i = _recv_pos; i < _recv_len; i++) {
|
||||
at_debug("%c", _recv_buff[i]);
|
||||
}
|
||||
|
|
@ -926,7 +932,6 @@ const char* ATHandler::mem_str(const char* dest, size_t dest_len, const char* sr
|
|||
if (dest_len > src_len) {
|
||||
for(size_t i = 0; i < dest_len-src_len; ++i) {
|
||||
if(memcmp(dest+i, src, src_len) == 0) {
|
||||
at_debug("mem_str i: %d", i);
|
||||
return dest+i;
|
||||
}
|
||||
}
|
||||
|
|
@ -955,6 +960,7 @@ void ATHandler::cmd_start(const char* cmd)
|
|||
|
||||
void ATHandler::write_int(int32_t param)
|
||||
{
|
||||
log_debug("write_int: %d", param);
|
||||
// do common checks before sending subparameter
|
||||
if (check_cmd_send() == false) {
|
||||
return;
|
||||
|
|
@ -976,6 +982,7 @@ void ATHandler::write_int(int32_t param)
|
|||
|
||||
void ATHandler::write_string(const char* param, bool useQuotations)
|
||||
{
|
||||
log_debug("write_string: %s, %d", param, useQuotations);
|
||||
// do common checks before sending subparameter
|
||||
if (check_cmd_send() == false) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -256,6 +256,10 @@ public:
|
|||
*/
|
||||
void set_delimiter(char delimiter);
|
||||
|
||||
/** Sets the delimiter to default value defined by DEFAULT_DELIMITER.
|
||||
*/
|
||||
void set_default_delimiter();
|
||||
|
||||
/** Consumes the reading buffer up to the delimiter or stop_tag
|
||||
*
|
||||
* @param count number of parameters to be skipped
|
||||
|
|
|
|||
|
|
@ -48,9 +48,11 @@ nsapi_error_t AT_CellularInformation::get_info(const char *cmd, char *buf, size_
|
|||
|
||||
_at.cmd_start(cmd);
|
||||
_at.cmd_stop();
|
||||
_at.set_delimiter(0);
|
||||
_at.resp_start();
|
||||
_at.read_string(buf, buf_size-1); // stop tag OK\r\n
|
||||
_at.read_string(buf, buf_size-1);
|
||||
_at.resp_stop();
|
||||
_at.set_default_delimiter();
|
||||
|
||||
return _at.unlock_return_error();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -492,8 +492,8 @@ nsapi_error_t AT_CellularNetwork::get_registration_status(RegistrationType type,
|
|||
|
||||
_at.cmd_start(at_reg[i].cmd);
|
||||
_at.write_string("?", false);
|
||||
|
||||
_at.cmd_stop();
|
||||
|
||||
_at.resp_start(rsp[i]);
|
||||
_at.read_int(); // ignore urc mode subparam
|
||||
status = (RegistrationStatus)_at.read_int();
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ nsapi_error_t QUECTEL_BC95_CellularStack::create_socket_impl(CellularSocket *soc
|
|||
sock_id = _at.read_int();
|
||||
_at.resp_stop();
|
||||
|
||||
bool socketOpenWorking = (_at.get_last_error() == NSAPI_ERROR_OK);
|
||||
socketOpenWorking = (_at.get_last_error() == NSAPI_ERROR_OK);
|
||||
|
||||
if (!socketOpenWorking) {
|
||||
_at.cmd_start("AT+NSOCL=0");
|
||||
|
|
@ -183,7 +183,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_recvfrom_impl(CellularS
|
|||
// remaining length
|
||||
_at.skip_param();
|
||||
|
||||
if (!recv_len || (_at.get_last_error() != NSAPI_ERROR_OK)) {
|
||||
if (!recv_len || (recv_len == -1) || (_at.get_last_error() != NSAPI_ERROR_OK)) {
|
||||
return NSAPI_ERROR_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue