Skip to content

Commit d34b047

Browse files
C030_N211 api's update and removed N2XX_CellularNetwork class
1 parent 6c347ea commit d34b047

File tree

6 files changed

+24
-118
lines changed

6 files changed

+24
-118
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,17 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
297297
port = _at.read_int();
298298
usorf_sz = _at.read_int();
299299

300+
if (usorf_sz > size) {
301+
usorf_sz = size;
302+
}
303+
300304
// Must use what +USORF returns here as it may be less or more than we asked for
301305
if (usorf_sz > socket->pending_bytes) {
302306
socket->pending_bytes = 0;
303307
} else {
304308
socket->pending_bytes -= usorf_sz;
305309
}
306310

307-
if (usorf_sz > size) {
308-
usorf_sz = size;
309-
}
310311
_at.read_bytes(&ch, 1);
311312
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
312313
_at.resp_stop();

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ void UBLOX_N2XX::NPIN_URC()
5454
_at->read_string(simstr, sizeof(simstr));
5555
}
5656

57-
AT_CellularNetwork *UBLOX_N2XX::open_network_impl(ATHandler &at)
58-
{
59-
return new UBLOX_N2XX_CellularNetwork(at);
60-
}
61-
6257
AT_CellularContext *UBLOX_N2XX::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)
6358
{
6459
return new UBLOX_N2XX_CellularContext(at, this, apn, cp_req, nonip_req);
@@ -69,7 +64,6 @@ AT_CellularSMS *UBLOX_N2XX::open_sms_impl(ATHandler &at)
6964
return new UBLOX_N2XX_CellularSMS(at);
7065
}
7166

72-
7367
nsapi_error_t UBLOX_N2XX::init()
7468
{
7569
_at->set_at_timeout(5000);

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,20 @@
1818
#ifndef UBLOX_N2XX_H_
1919
#define UBLOX_N2XX_H_
2020

21+
#ifdef TARGET_FF_ARDUINO
22+
#ifndef MBED_CONF_UBLOX_N2XX_TX
23+
#define MBED_CONF_UBLOX_N2XX_TX D1
24+
#endif
25+
#ifndef MBED_CONF_UBLOX_N2XX_RX
26+
#define MBED_CONF_UBLOX_N2XX_RX D0
27+
#endif
28+
#endif /* TARGET_FF_ARDUINO */
29+
2130
#include "mbed.h"
2231
#include "CellularLog.h"
2332
#include "AT_CellularDevice.h"
33+
#include "AT_CellularNetwork.h"
2434
#include "UBLOX_N2XX_CellularSMS.h"
25-
#include "UBLOX_N2XX_CellularNetwork.h"
2635
#include "UBLOX_N2XX_CellularContext.h"
2736

2837
namespace mbed {
@@ -41,7 +50,6 @@ class UBLOX_N2XX : public AT_CellularDevice {
4150

4251
protected: // AT_CellularDevice
4352

44-
virtual AT_CellularNetwork *open_network_impl(ATHandler &at);
4553
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
4654
virtual AT_CellularSMS *open_sms_impl(ATHandler &at);
4755

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

Lines changed: 0 additions & 48 deletions
This file was deleted.

features/cellular/framework/targets/UBLOX/N2XX/UBLOX_N2XX_CellularNetwork.h

Lines changed: 0 additions & 39 deletions
This file was deleted.

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

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_sendto_impl(CellularSocke
119119
return NSAPI_ERROR_PARAMETER;
120120
}
121121

122-
int sent_len = 0, len = 0;
123-
char *dataStr = (char *) malloc((size * 2) + 1);
124-
memset(dataStr, 0, size*2+1);
122+
int sent_len = 0;
123+
char *dataStr = new char [(size * 2) + 1]();
124+
if (!dataStr)
125+
return NSAPI_ERROR_NO_MEMORY;
125126
char_str_to_hex_str((const char*)data, size, dataStr);
126-
len = strlen(dataStr);
127127

128128
_at.cmd_start("AT+NSOST=");
129129
_at.write_int(socket->id);
130130
_at.write_string(address.get_ip_address());
131131
_at.write_int(address.get_port());
132-
_at.write_int(len/2);
132+
_at.write_int(size);
133133
_at.write_string(dataStr);
134134
_at.cmd_stop();
135135

@@ -153,15 +153,12 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
153153
nsapi_size_t read_blk, usorf_sz, count = 0, length = size*2;
154154
bool success = true;
155155
char ipAddress[NSAPI_IP_SIZE];
156-
char *tmpBuf = (char *) malloc(size*2+1);
157-
memset(tmpBuf, 0, size*2+1);
158156
int port = 0;
159157
Timer timer;
160158

161159
if (socket->pending_bytes == 0) {
162160
_at.process_oob();
163161
if (socket->pending_bytes == 0) {
164-
free(tmpBuf);
165162
return NSAPI_ERROR_WOULD_BLOCK;
166163
}
167164
}
@@ -183,6 +180,11 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
183180
_at.read_string(ipAddress, sizeof(ipAddress));
184181
port = _at.read_int();
185182
usorf_sz = _at.read_int();
183+
if (usorf_sz > length) {
184+
usorf_sz = length;
185+
}
186+
_at.read_hex_string((char *)buffer + count, usorf_sz*2+1);
187+
_at.resp_stop();
186188

187189
// Must use what +NSORF returns here as it may be less or more than we asked for
188190
if (usorf_sz >= socket->pending_bytes) {
@@ -191,12 +193,6 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
191193
socket->pending_bytes -= usorf_sz;
192194
}
193195

194-
if (usorf_sz > length) {
195-
usorf_sz = length;
196-
}
197-
_at.read_string(tmpBuf + count, usorf_sz*2+1);
198-
_at.resp_stop();
199-
200196
if (usorf_sz > 0) {
201197
count += (usorf_sz*2);
202198
length -= (usorf_sz*2);
@@ -220,10 +216,7 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
220216

221217
socket->pending_bytes = 0;
222218
if (!count || (_at.get_last_error() != NSAPI_ERROR_OK)) {
223-
free(tmpBuf);
224219
return NSAPI_ERROR_WOULD_BLOCK;
225-
} else {
226-
nsapi_error_size = count;
227220
}
228221

229222
if (success && socket->proto == NSAPI_UDP && address) {
@@ -232,9 +225,6 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
232225
address->set_port(port);
233226
}
234227

235-
hex_str_to_char_str(tmpBuf, count, (char*) buffer);
236-
237-
free(tmpBuf);
238228
return nsapi_error_size = count/2;
239229
}
240230

0 commit comments

Comments
 (0)