Skip to content

Commit 578fb7a

Browse files
updated api and removed Astyle issue
1 parent d34b047 commit 578fb7a

File tree

5 files changed

+21
-31
lines changed

5 files changed

+21
-31
lines changed

features/cellular/TESTS/api/cellular_sms/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,20 @@ static void test_sms_initialize_pdu_mode()
111111
{
112112
nsapi_error_t err = sms->initialize(CellularSMS::CellularSMSMmodePDU);
113113
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
114-
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
114+
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
115115
}
116116

117117
static void test_set_cscs()
118118
{
119119
nsapi_error_t err = sms->set_cscs("IRA");
120120
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
121-
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
121+
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
122122
err = sms->set_cscs("UCS2");
123123
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
124-
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
124+
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
125125
err = sms->set_cscs("GSM");
126126
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
127-
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
127+
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
128128
}
129129

130130
static void test_set_csca()
@@ -144,7 +144,7 @@ static void test_set_cpms_me()
144144
{
145145
nsapi_error_t err = sms->set_cpms("ME", "ME", "ME");
146146
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED || (err == NSAPI_ERROR_DEVICE_ERROR &&
147-
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
147+
((AT_CellularSMS *)sms)->get_device_error().errCode == SIM_BUSY));
148148
}
149149

150150
#ifdef MBED_CONF_APP_CELLULAR_PHONE_NUMBER

features/cellular/framework/AT/AT_CellularStack.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protoc
132132
tr_info("Socket %d open", index);
133133
// create local socket structure, socket on modem is created when app calls sendto/recvfrom
134134
_socket[index] = new CellularSocket;
135-
CellularSocket *psock;
136-
psock = _socket[index];
137-
memset(psock, 0, sizeof(CellularSocket));
135+
CellularSocket *psock = _socket[index];
138136
SocketAddress addr(0, get_dynamic_ip_port());
139137
psock->id = index;
140138
psock->localAddress = addr;

features/cellular/framework/targets/UBLOX/AT/UBLOX_AT_CellularStack.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,12 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
296296
_at.read_string(ipAddress, sizeof(ipAddress));
297297
port = _at.read_int();
298298
usorf_sz = _at.read_int();
299-
300299
if (usorf_sz > size) {
301300
usorf_sz = size;
302301
}
302+
_at.read_bytes(&ch, 1);
303+
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
304+
_at.resp_stop();
303305

304306
// Must use what +USORF returns here as it may be less or more than we asked for
305307
if (usorf_sz > socket->pending_bytes) {
@@ -308,10 +310,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
308310
socket->pending_bytes -= usorf_sz;
309311
}
310312

311-
_at.read_bytes(&ch, 1);
312-
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
313-
_at.resp_stop();
314-
315313
if (usorf_sz > 0) {
316314
count += usorf_sz;
317315
size -= usorf_sz;
@@ -346,6 +344,12 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
346344
_at.resp_start("+USORD:");
347345
_at.skip_param(); // receiving socket id
348346
usorf_sz = _at.read_int();
347+
if (usorf_sz > size) {
348+
usorf_sz = size;
349+
}
350+
_at.read_bytes(&ch, 1);
351+
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
352+
_at.resp_stop();
349353

350354
// Must use what +USORD returns here as it may be less or more than we asked for
351355
if (usorf_sz > socket->pending_bytes) {
@@ -354,13 +358,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
354358
socket->pending_bytes -= usorf_sz;
355359
}
356360

357-
if (usorf_sz > size) {
358-
usorf_sz = size;
359-
}
360-
_at.read_bytes(&ch, 1);
361-
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
362-
_at.resp_stop();
363-
364361
if (usorf_sz > 0) {
365362
count += usorf_sz;
366363
size -= usorf_sz;

features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ AT_CellularSMS *UBLOX_N2XX::open_sms_impl(ATHandler &at)
6666

6767
nsapi_error_t UBLOX_N2XX::init()
6868
{
69-
_at->set_at_timeout(5000);
7069
_at->lock();
7170
_at->flush();
7271
_at->cmd_start("AT"); // echo off
@@ -77,11 +76,7 @@ nsapi_error_t UBLOX_N2XX::init()
7776

7877
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN
7978
set_pin(MBED_CONF_NSAPI_DEFAULT_CELLULAR_SIM_PIN);
80-
wait(1);
81-
_at->cmd_start("AT+CFUN=1"); // set full functionality
82-
_at->cmd_stop_read_resp();
8379
#endif
84-
_at->restore_at_timeout();
8580
return _at->unlock_return_error();
8681
}
8782

features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularStack.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_sendto_impl(CellularSocke
138138
sent_len = _at.read_int();
139139
_at.resp_stop();
140140

141-
free(dataStr);
141+
delete[] dataStr;
142142
if ((_at.get_last_error() == NSAPI_ERROR_OK)) {
143143
return sent_len;
144144
}
@@ -150,7 +150,7 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
150150
void *buffer, nsapi_size_t size)
151151
{
152152
nsapi_size_or_error_t nsapi_error_size = NSAPI_ERROR_DEVICE_ERROR;
153-
nsapi_size_t read_blk, usorf_sz, count = 0, length = size*2;
153+
nsapi_size_t read_blk, usorf_sz, count = 0, length = size;
154154
bool success = true;
155155
char ipAddress[NSAPI_IP_SIZE];
156156
int port = 0;
@@ -183,7 +183,7 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
183183
if (usorf_sz > length) {
184184
usorf_sz = length;
185185
}
186-
_at.read_hex_string((char *)buffer + count, usorf_sz*2+1);
186+
_at.read_hex_string((char *)buffer + count, usorf_sz);
187187
_at.resp_stop();
188188

189189
// Must use what +NSORF returns here as it may be less or more than we asked for
@@ -194,8 +194,8 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
194194
}
195195

196196
if (usorf_sz > 0) {
197-
count += (usorf_sz*2);
198-
length -= (usorf_sz*2);
197+
count += (usorf_sz);
198+
length -= (usorf_sz);
199199
} else {
200200
// read() should not fail
201201
success = false;
@@ -225,7 +225,7 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
225225
address->set_port(port);
226226
}
227227

228-
return nsapi_error_size = count/2;
228+
return nsapi_error_size = count;
229229
}
230230

231231
nsapi_error_t UBLOX_N2XX_CellularStack::socket_close_impl(int sock_id)

0 commit comments

Comments
 (0)