Skip to content

Commit 22e7fbd

Browse files
Mirela ChiricaAri Parkkila
authored andcommitted
- BC95 socket creation bug fix
- Cellular information reading stopping on comma fixed
1 parent d2e8691 commit 22e7fbd

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

features/cellular/framework/AT/ATHandler.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const uint8_t CMS_ERROR_LENGTH = 11;
4949
const char *ERROR_ = "ERROR\r\n";
5050
const uint8_t ERROR_LENGTH = 7;
5151
const uint8_t MAX_RESP_LENGTH = CMS_ERROR_LENGTH;
52+
const char DEFAULT_DELIMITER = ',';
5253

5354
static const uint8_t map_3gpp_errors[][2] = {
5455
{ 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
7273
_processing(false),
7374
_ref_count(1),
7475
_stop_tag(NULL),
75-
_delimiter(','),
76+
_delimiter(DEFAULT_DELIMITER),
7677
_prefix_matched(false),
7778
_urc_matched(false),
7879
_error_found(false),
@@ -411,7 +412,7 @@ ssize_t ATHandler::read_bytes(uint8_t *buf, size_t len)
411412
ssize_t ATHandler::read_string(char *buf, size_t size, bool read_even_stop_tag)
412413
{
413414
tr_debug("%s", __func__);
414-
at_debug("\n----------buff:----------\n");
415+
at_debug("\n----------read_string buff:----------\n");
415416
for (size_t i = _recv_pos; i < _recv_len; i++) {
416417
at_debug("%c", _recv_buff[i]);
417418
}
@@ -484,6 +485,11 @@ void ATHandler::set_delimiter(char delimiter)
484485
_delimiter = delimiter;
485486
}
486487

488+
void ATHandler::set_default_delimiter()
489+
{
490+
_delimiter = DEFAULT_DELIMITER;
491+
}
492+
487493
void ATHandler::set_tag(tag_t* tag_dst, const char *tag_seq)
488494
{
489495
if (tag_seq) {
@@ -560,7 +566,7 @@ bool ATHandler::match_urc()
560566
prefix_len = strlen(oob->prefix);
561567
if (_recv_len >= prefix_len) {
562568
if (match(oob->prefix, prefix_len)) {
563-
tr_debug("URC!");
569+
tr_debug("URC! %s", oob->prefix);
564570
set_scope(InfoType);
565571
if (oob->cb) {
566572
oob->cb();
@@ -670,7 +676,7 @@ void ATHandler::resp(const char *prefix, bool check_urc)
670676
{
671677
tr_debug("%s: %s", __func__, prefix);
672678

673-
at_debug("\n----------buff:----------\n");
679+
at_debug("\n----------resp buff:----------\n");
674680
for (size_t i = _recv_pos; i < _recv_len; i++) {
675681
at_debug("%c", _recv_buff[i]);
676682
}
@@ -926,7 +932,6 @@ const char* ATHandler::mem_str(const char* dest, size_t dest_len, const char* sr
926932
if (dest_len > src_len) {
927933
for(size_t i = 0; i < dest_len-src_len; ++i) {
928934
if(memcmp(dest+i, src, src_len) == 0) {
929-
at_debug("mem_str i: %d", i);
930935
return dest+i;
931936
}
932937
}
@@ -955,6 +960,7 @@ void ATHandler::cmd_start(const char* cmd)
955960

956961
void ATHandler::write_int(int32_t param)
957962
{
963+
log_debug("write_int: %d", param);
958964
// do common checks before sending subparameter
959965
if (check_cmd_send() == false) {
960966
return;
@@ -976,6 +982,7 @@ void ATHandler::write_int(int32_t param)
976982

977983
void ATHandler::write_string(const char* param, bool useQuotations)
978984
{
985+
log_debug("write_string: %s, %d", param, useQuotations);
979986
// do common checks before sending subparameter
980987
if (check_cmd_send() == false) {
981988
return;

features/cellular/framework/AT/ATHandler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ class ATHandler
256256
*/
257257
void set_delimiter(char delimiter);
258258

259+
/** Sets the delimiter to default value defined by DEFAULT_DELIMITER.
260+
*/
261+
void set_default_delimiter();
262+
259263
/** Consumes the reading buffer up to the delimiter or stop_tag
260264
*
261265
* @param count number of parameters to be skipped

features/cellular/framework/AT/AT_CellularInformation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ nsapi_error_t AT_CellularInformation::get_info(const char *cmd, char *buf, size_
4848

4949
_at.cmd_start(cmd);
5050
_at.cmd_stop();
51+
_at.set_delimiter(0);
5152
_at.resp_start();
52-
_at.read_string(buf, buf_size-1); // stop tag OK\r\n
53+
_at.read_string(buf, buf_size-1);
5354
_at.resp_stop();
55+
_at.set_default_delimiter();
5456

5557
return _at.unlock_return_error();
5658
}

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,8 @@ nsapi_error_t AT_CellularNetwork::get_registration_status(RegistrationType type,
492492

493493
_at.cmd_start(at_reg[i].cmd);
494494
_at.write_string("?", false);
495-
496495
_at.cmd_stop();
496+
497497
_at.resp_start(rsp[i]);
498498
_at.read_int(); // ignore urc mode subparam
499499
status = (RegistrationStatus)_at.read_int();

features/cellular/framework/targets/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ nsapi_error_t QUECTEL_BC95_CellularStack::create_socket_impl(CellularSocket *soc
9696
sock_id = _at.read_int();
9797
_at.resp_stop();
9898

99-
bool socketOpenWorking = (_at.get_last_error() == NSAPI_ERROR_OK);
99+
socketOpenWorking = (_at.get_last_error() == NSAPI_ERROR_OK);
100100

101101
if (!socketOpenWorking) {
102102
_at.cmd_start("AT+NSOCL=0");
@@ -183,7 +183,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_recvfrom_impl(CellularS
183183
// remaining length
184184
_at.skip_param();
185185

186-
if (!recv_len || (_at.get_last_error() != NSAPI_ERROR_OK)) {
186+
if (!recv_len || (recv_len == -1) || (_at.get_last_error() != NSAPI_ERROR_OK)) {
187187
return NSAPI_ERROR_WOULD_BLOCK;
188188
}
189189

0 commit comments

Comments
 (0)