Skip to content

Commit fcdac9e

Browse files
felseradbridge
authored andcommitted
Rebase and changes for Dragonfly nano support
1 parent 8a778bd commit fcdac9e

File tree

12 files changed

+307
-87
lines changed

12 files changed

+307
-87
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ static void test_activate_context()
200200
static void test_connect()
201201
{
202202
TEST_ASSERT(nw->connect() == NSAPI_ERROR_OK);
203+
char count = 0;
204+
while ((nw->get_connection_status() != NSAPI_STATUS_GLOBAL_UP) && (count++ < 60)) {
205+
wait(1);
206+
}
203207
nsapi_connection_status_t st = nw->get_connection_status();
204208
TEST_ASSERT(st == NSAPI_STATUS_GLOBAL_UP);
205209
}
@@ -226,7 +230,7 @@ static void test_other()
226230
// can't test values as they are optional
227231
nsapi_error_t err = nw->get_rate_control(reports, timeUnit, uplinkRate);
228232
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
229-
if (strcmp(devi, "QUECTEL_BG96") != 0 && strcmp(devi, "TELIT_HE910") != 0) { // QUECTEL_BG96 does not give any specific reason for device error
233+
if (strcmp(devi, "QUECTEL_BG96") != 0 && strcmp(devi, "TELIT_HE910") != 0 && strcmp(devi, "SARA4_PPP") != 0) { // QUECTEL_BG96 does not give any specific reason for device error
230234
if (err == NSAPI_ERROR_DEVICE_ERROR) {
231235
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
232236
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
@@ -237,7 +241,7 @@ static void test_other()
237241
err = nw->get_apn_backoff_timer(uplinkRate);
238242
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR || err == NSAPI_ERROR_PARAMETER);
239243
if (err == NSAPI_ERROR_DEVICE_ERROR) {
240-
if (strcmp(devi, "QUECTEL_BG96") != 0 && strcmp(devi, "TELIT_HE910") != 0) { // QUECTEL_BG96 does not give any specific reason for device error
244+
if (strcmp(devi, "QUECTEL_BG96") != 0 && strcmp(devi, "TELIT_HE910") != 0 && strcmp(devi, "SARA4_PPP") != 0) { // QUECTEL_BG96 does not give any specific reason for device error
241245
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
242246
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
243247
}
@@ -323,7 +327,7 @@ static void test_other()
323327

324328
TEST_ASSERT(nw->set_blocking(true) == NSAPI_ERROR_OK);
325329

326-
if (strcmp(devi, "QUECTEL_BG96") != 0) {
330+
if (strcmp(devi, "QUECTEL_BG96") != 0 && strcmp(devi, "SARA4_PPP") != 0) {
327331
// QUECTEL_BG96 timeouts with this one, tested with 3 minute timeout
328332
CellularNetwork::operator_names_list op_names;
329333
err = nw->get_operator_names(op_names);
@@ -347,7 +351,7 @@ static void test_other()
347351
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
348352
if (err == NSAPI_ERROR_DEVICE_ERROR) {
349353
// if device error then we must check was that really device error or that modem/network does not support the commands
350-
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) {
354+
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0 || strcmp(devi, "SARA4_PPP") == 0)) {
351355
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
352356
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
353357
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
@@ -361,7 +365,7 @@ static void test_other()
361365
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
362366
if (err == NSAPI_ERROR_DEVICE_ERROR) {
363367
// if device error then we must check was that really device error or that modem/network does not support the commands
364-
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) {
368+
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0 || strcmp(devi, "SARA4_PPP") == 0)) {
365369
TEST_ASSERT((((AT_CellularNetwork *)nw)->get_device_error().errType == 3) && // 3 == CME error from the modem
366370
((((AT_CellularNetwork *)nw)->get_device_error().errCode == 100) || // 100 == unknown command for modem
367371
(((AT_CellularNetwork *)nw)->get_device_error().errCode == 50))); // 50 == incorrect parameters // seen in wise_1570 for not supported commands
@@ -374,6 +378,8 @@ static void test_disconnect()
374378
nsapi_connection_status_t st = nw->get_connection_status();
375379
TEST_ASSERT(st == NSAPI_STATUS_GLOBAL_UP);
376380
TEST_ASSERT(nw->disconnect() == NSAPI_ERROR_OK);
381+
// wait to process URC's, received after disconnect
382+
rtos::Thread::wait(500);
377383
}
378384

379385
static void test_detach()
@@ -387,7 +393,7 @@ static void test_detach()
387393

388394
TEST_ASSERT(nw->detach() == NSAPI_ERROR_OK);
389395
// wait to process URC's, received after detach
390-
rtos::Thread::wait(50);
396+
rtos::Thread::wait(500);
391397
st = nw->get_connection_status();
392398
TEST_ASSERT(st == NSAPI_STATUS_DISCONNECTED);
393399
}

features/cellular/framework/AT/AT_CellularDevice.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,20 @@ CellularInformation *AT_CellularDevice::open_information(FileHandle *fh)
171171
void AT_CellularDevice::close_network()
172172
{
173173
if (_network) {
174-
release_at_handler(&_network->get_at_handler());
174+
<<<<<<< HEAD
175+
_network_ref_count--;
176+
if (_network_ref_count == 0) {
177+
ATHandler *atHandler = &_network->get_at_handler();
178+
delete _network;
179+
_network = NULL;
180+
release_at_handler(atHandler);
181+
}
182+
=======
183+
ATHandler *at_handler = &_network->get_at_handler();
175184
delete _network;
185+
release_at_handler(at_handler);
176186
_network = NULL;
187+
>>>>>>> Rebase and changes for Dragonfly nano support
177188
}
178189
}
179190

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ nsapi_error_t AT_CellularNetwork::open_data_channel()
388388
{
389389
#if NSAPI_PPP_AVAILABLE
390390
tr_info("Open data channel in PPP mode");
391-
//<<<<<<< HEAD
392391
if (is_supported(AT_CGDATA)) {
393392
_at.cmd_start("AT+CGDATA=\"PPP\",");
394393
_at.write_int(_cid);
@@ -398,16 +397,6 @@ nsapi_error_t AT_CellularNetwork::open_data_channel()
398397
std::sprintf(cmd_buf, "ATD*99***%d#", _cid);
399398
_at.cmd_start(cmd_buf);
400399
}
401-
//=======
402-
//
403-
//#ifdef TARGET_MTS_DRAGONFLY_L471QG
404-
// _at.cmd_start("ATD*99***1#");
405-
//#else
406-
// _at.cmd_start("AT+CGDATA=\"PPP\",");
407-
// _at.write_int(_cid);
408-
//#endif
409-
//
410-
//>>>>>>> changes to support mts dragonfly nano ppp
411400
_at.cmd_stop();
412401

413402
_at.resp_start("CONNECT", true);

features/cellular/framework/common/CellularTargets.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ namespace mbed {
3737
#endif
3838
#elif TARGET_UBLOX_C027
3939
#define CELLULAR_DEVICE UBLOX_PPP
40-
#elif TARGET_DRAGONFLY_L471QG
41-
#define CELLULAR_DEVICE UBLOX_PPP
40+
#elif TARGET_MTS_DRAGONFLY_L471QG
41+
#define CELLULAR_DEVICE SARA4_PPP
4242
//#else
4343
//#error Cellular target not defined, see cellular/targets.h
4444
//#define CELLULAR_TARGET <target-modem>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2017, 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 "SARA4_PPP.h"
19+
#include "SARA4_PPP_CellularNetwork.h"
20+
#include "SARA4_PPP_CellularPower.h"
21+
22+
using namespace mbed;
23+
using namespace events;
24+
25+
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
26+
AT_CellularBase::AT_CGSN_WITH_TYPE,
27+
AT_CellularBase::AT_CGDATA,
28+
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
29+
};
30+
31+
SARA4_PPP::SARA4_PPP(EventQueue &queue) : AT_CellularDevice(queue)
32+
{
33+
AT_CellularBase::set_unsupported_features(unsupported_features);
34+
}
35+
36+
SARA4_PPP::~SARA4_PPP()
37+
{
38+
}
39+
40+
CellularNetwork *SARA4_PPP::open_network(FileHandle *fh)
41+
{
42+
if (!_network) {
43+
ATHandler *atHandler = get_at_handler(fh);
44+
if (atHandler) {
45+
_network = new SARA4_PPP_CellularNetwork(*atHandler);
46+
if (!_network) {
47+
release_at_handler(atHandler);
48+
}
49+
}
50+
}
51+
return _network;
52+
}
53+
54+
CellularPower *SARA4_PPP::open_power(FileHandle *fh)
55+
{
56+
if (!_power) {
57+
ATHandler *atHandler = get_at_handler(fh);
58+
if (atHandler) {
59+
_power = new SARA4_PPP_CellularPower(*atHandler);
60+
if (!_power) {
61+
release_at_handler(atHandler);
62+
}
63+
}
64+
}
65+
return _power;
66+
}
67+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2017, 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 SARA4_PPP_H_
19+
#define SARA4_PPP_H_
20+
21+
#include "AT_CellularDevice.h"
22+
23+
namespace mbed {
24+
25+
class SARA4_PPP : public AT_CellularDevice {
26+
27+
public:
28+
SARA4_PPP(events::EventQueue &queue);
29+
virtual ~SARA4_PPP();
30+
31+
public: // CellularDevice
32+
virtual CellularNetwork *open_network(FileHandle *fh);
33+
virtual CellularPower *open_power(FileHandle *fh);
34+
};
35+
36+
} // namespace mbed
37+
38+
#endif // SARA4_PPP_H_
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2017, 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 "SARA4_PPP_CellularNetwork.h"
19+
20+
using namespace mbed;
21+
22+
SARA4_PPP_CellularNetwork::SARA4_PPP_CellularNetwork(ATHandler &atHandler) : AT_CellularNetwork(atHandler)
23+
{
24+
}
25+
26+
SARA4_PPP_CellularNetwork::~SARA4_PPP_CellularNetwork()
27+
{
28+
}
29+
30+
bool SARA4_PPP_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_stack)
31+
{
32+
return requested_stack == IPV4_STACK ? true : false;
33+
}
34+
35+
AT_CellularNetwork::RegistrationMode SARA4_PPP_CellularNetwork::has_registration(RegistrationType reg_type)
36+
{
37+
//<<<<<<< HEAD
38+
return (reg_type == C_REG || reg_type == C_GREG) ? RegistrationModeLAC : RegistrationModeDisable;
39+
//=======
40+
//#ifdef TARGET_DRAGONFLY_L471QG
41+
// return (reg_type == C_REG || reg_type == C_EREG);
42+
//#else
43+
// return (reg_type == C_REG || reg_type == C_GREG || reg_type == C_EREG);
44+
//#endif
45+
//>>>>>>> Fixed spacing/tabs and clean up targets.json
46+
}
47+
48+
nsapi_error_t SARA4_PPP_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat)
49+
{
50+
_op_act = RAT_CATM1;
51+
return NSAPI_ERROR_OK;
52+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2017, 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 SARA4_PPP_CELLULAR_NETWORK_H_
19+
#define SARA4_PPP_CELLULAR_NETWORK_H_
20+
21+
#include "AT_CellularNetwork.h"
22+
23+
namespace mbed {
24+
25+
class SARA4_PPP_CellularNetwork : public AT_CellularNetwork {
26+
public:
27+
SARA4_PPP_CellularNetwork(ATHandler &atHandler);
28+
virtual ~SARA4_PPP_CellularNetwork();
29+
30+
protected:
31+
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack);
32+
33+
virtual RegistrationMode has_registration(RegistrationType rat);
34+
35+
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opRat);
36+
};
37+
38+
} // namespace mbed
39+
40+
#endif // SARA4_PPP_CELLULAR_NETWORK_H_
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2017, 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 "SARA4_PPP_CellularPower.h"
19+
20+
#include "onboard_modem_api.h"
21+
22+
using namespace mbed;
23+
24+
SARA4_PPP_CellularPower::SARA4_PPP_CellularPower(ATHandler &atHandler) : AT_CellularPower(atHandler)
25+
{
26+
27+
}
28+
29+
SARA4_PPP_CellularPower::~SARA4_PPP_CellularPower()
30+
{
31+
32+
}
33+
34+
nsapi_error_t SARA4_PPP_CellularPower::on()
35+
{
36+
::onboard_modem_init();
37+
::onboard_modem_power_up();
38+
return NSAPI_ERROR_OK;
39+
}
40+
41+
nsapi_error_t SARA4_PPP_CellularPower::off()
42+
{
43+
::onboard_modem_power_down();
44+
return NSAPI_ERROR_OK;
45+
}

0 commit comments

Comments
 (0)