Skip to content

Commit 17a525c

Browse files
author
Cruz Monrreal
authored
Merge pull request #7619 from u-blox/cellular_ublox_udp_tcp_imp
UBLOX cellular api's for UDP and TCP
2 parents e02466a + f512668 commit 17a525c

File tree

12 files changed

+1234
-5
lines changed

12 files changed

+1234
-5
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ static void test_detach()
374374
TEST_ASSERT(st == NSAPI_STATUS_DISCONNECTED);
375375

376376
TEST_ASSERT(nw->detach() == NSAPI_ERROR_OK);
377+
// wait to process URC's, received after detach
378+
rtos::Thread::wait(50);
377379
st = nw->get_connection_status();
378380
TEST_ASSERT(st == NSAPI_STATUS_DISCONNECTED);
379381
}

features/cellular/framework/AT/AT_CellularStack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class AT_CellularStack : public NetworkStack, public AT_CellularBase {
9696
bool started; // socket has been opened on modem stack
9797
bool tx_ready; // socket is ready for sending on modem stack
9898
bool rx_avail; // socket has data for reading on modem stack
99+
nsapi_size_t pending_bytes; // The number of received bytes pending
99100
};
100101

101102
/**

features/cellular/framework/common/CellularTargets.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ namespace mbed {
3030
#elif TARGET_MTB_MTS_DRAGONFLY
3131
#define CELLULAR_DEVICE TELIT_HE910
3232
#elif TARGET_UBLOX_C030
33+
#ifdef TARGET_UBLOX_C030_N211
34+
#define CELLULAR_DEVICE UBLOX_AT
35+
#else
3336
#define CELLULAR_DEVICE UBLOX_PPP
37+
#endif
3438
#elif TARGET_UBLOX_C027
3539
#define CELLULAR_DEVICE UBLOX_PPP
3640
#else
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2018, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "UBLOX_AT.h"
19+
#include "UBLOX_AT_CellularNetwork.h"
20+
#include "UBLOX_AT_CellularPower.h"
21+
22+
using namespace mbed;
23+
using namespace events;
24+
25+
UBLOX_AT::UBLOX_AT(EventQueue &queue) : AT_CellularDevice(queue)
26+
{
27+
}
28+
29+
UBLOX_AT::~UBLOX_AT()
30+
{
31+
}
32+
33+
CellularNetwork *UBLOX_AT::open_network(FileHandle *fh)
34+
{
35+
if (!_network) {
36+
ATHandler *atHandler = get_at_handler(fh);
37+
if (atHandler) {
38+
_network = new UBLOX_AT_CellularNetwork(*atHandler);
39+
if (!_network) {
40+
release_at_handler(atHandler);
41+
}
42+
}
43+
}
44+
return _network;
45+
}
46+
47+
CellularPower *UBLOX_AT::open_power(FileHandle *fh)
48+
{
49+
if (!_power) {
50+
ATHandler *atHandler = get_at_handler(fh);
51+
if (atHandler) {
52+
_power = new UBLOX_AT_CellularPower(*atHandler);
53+
if (!_power) {
54+
release_at_handler(atHandler);
55+
}
56+
}
57+
}
58+
return _power;
59+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2018, Arm Limited and affiliates.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef UBLOX_AT_H_
19+
#define UBLOX_AT_H_
20+
21+
#include "AT_CellularDevice.h"
22+
23+
namespace mbed
24+
{
25+
26+
class UBLOX_AT : public AT_CellularDevice
27+
{
28+
29+
public:
30+
UBLOX_AT(events::EventQueue &queue);
31+
virtual ~UBLOX_AT();
32+
33+
public: // CellularDevice
34+
virtual CellularNetwork *open_network(FileHandle *fh);
35+
virtual CellularPower *open_power(FileHandle *fh);
36+
37+
public: // NetworkInterface
38+
void handle_urc(FileHandle *fh);
39+
};
40+
41+
} // namespace mbed
42+
43+
#endif // UBLOX_AT_H_

0 commit comments

Comments
 (0)