Skip to content

Commit bc4255f

Browse files
author
Ari Parkkila
committed
Cellular: Add NIDD for U-blox/N2XX
1 parent 57cea39 commit bc4255f

File tree

6 files changed

+104
-2
lines changed

6 files changed

+104
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
3434
1, // PROPERTY_IPV4_STACK
3535
0, // PROPERTY_IPV6_STACK
3636
0, // PROPERTY_IPV4V6_STACK
37+
1, // PROPERTY_NON_IP_PDP_TYPE
38+
0, // PROPERTY_AT_CGEREP
3739
};
3840

3941
UBLOX_N2XX::UBLOX_N2XX(FileHandle *fh): AT_CellularDevice(fh)
@@ -58,6 +60,11 @@ void UBLOX_N2XX::NPIN_URC()
5860
_at->read_string(simstr, sizeof(simstr));
5961
}
6062

63+
AT_CellularNetwork *UBLOX_N2XX::open_network_impl(ATHandler &at)
64+
{
65+
return new UBLOX_N2XX_CellularNetwork(at, *this);
66+
}
67+
6168
AT_CellularContext *UBLOX_N2XX::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)
6269
{
6370
return new UBLOX_N2XX_CellularContext(at, this, apn, cp_req, nonip_req);
@@ -93,8 +100,8 @@ nsapi_error_t UBLOX_N2XX::get_sim_state(SimState &state)
93100
_at->lock();
94101
_at->flush();
95102
//Special case: Command put in cmd_chr to make a 1 liner
96-
_at->at_cmd_str("", "+CFUN=1", simstr, sizeof(simstr));
97-
error = _at->unlock_return_error();
103+
error = _at->at_cmd_str("", "+CFUN=1", simstr, sizeof(simstr));
104+
_at->unlock();
98105

99106
int len = strlen(simstr);
100107
if (len > 0 || error == NSAPI_ERROR_OK) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "AT_CellularNetwork.h"
3434
#include "UBLOX_N2XX_CellularSMS.h"
3535
#include "UBLOX_N2XX_CellularContext.h"
36+
#include "UBLOX_N2XX_CellularNetwork.h"
3637

3738
namespace mbed {
3839

@@ -50,6 +51,7 @@ class UBLOX_N2XX : public AT_CellularDevice {
5051

5152
protected: // AT_CellularDevice
5253

54+
virtual AT_CellularNetwork *open_network_impl(ATHandler &at);
5355
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
5456
#if MBED_CONF_CELLULAR_USE_SMS
5557
virtual AT_CellularSMS *open_sms_impl(ATHandler &at);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ NetworkStack *UBLOX_N2XX_CellularContext::get_stack()
4444
}
4545
#endif
4646

47+
const char* UBLOX_N2XX_CellularContext::get_nonip_context_type_str()
48+
{
49+
return "NONIP";
50+
}
51+
4752
} /* namespace mbed */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class UBLOX_N2XX_CellularContext: public AT_CellularContext {
3434
virtual NetworkStack *get_stack();
3535
#endif
3636

37+
virtual const char* get_nonip_context_type_str();
3738
};
3839

3940
} /* namespace mbed */
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2019, 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_N2XX_CellularNetwork.h"
19+
20+
using namespace mbed;
21+
22+
UBLOX_N2XX_CellularNetwork::UBLOX_N2XX_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularNetwork(atHandler, device)
23+
{
24+
}
25+
26+
nsapi_error_t UBLOX_N2XX_CellularNetwork::clear()
27+
{
28+
nsapi_error_t err = AT_CellularNetwork::clear();
29+
#if MBED_CONF_CELLULAR_CONTROL_PLANE_OPT
30+
if (!err) {
31+
#ifdef MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN
32+
(void) _at.at_cmd_discard("+CGDCONT", "=", "%d%s%s", 1, "NONIP", MBED_CONF_NSAPI_DEFAULT_CELLULAR_APN);
33+
#endif
34+
(void) _at.at_cmd_discard("+CIPCA", "=", "%d%d", 3, 1); // EPS Attach without PDN connection
35+
_at.lock();
36+
_at.cmd_start("AT+NCONFIG=\"AUTOCONNECT\",\"FALSE\""); // disable auto connect to IP context
37+
_at.cmd_stop_read_resp();
38+
_at.unlock();
39+
}
40+
#endif
41+
return err;
42+
}
43+
44+
nsapi_error_t UBLOX_N2XX_CellularNetwork::set_ciot_optimization_config(CIoT_Supported_Opt supported_opt,
45+
CIoT_Preferred_UE_Opt preferred_opt,
46+
Callback<void(CIoT_Supported_Opt)> network_support_cb)
47+
{
48+
_ciotopt_network_support_cb = network_support_cb;
49+
nsapi_error_t err = _at.at_cmd_discard("+CRTDCP", "=", "%d", 1);
50+
return err;
51+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2019, 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_N2XX_CELLULAR_NETWORK_H_
19+
#define UBLOX_N2XX_CELLULAR_NETWORK_H_
20+
21+
#include "AT_CellularNetwork.h"
22+
23+
namespace mbed {
24+
25+
class UBLOX_N2XX_CellularNetwork : public AT_CellularNetwork {
26+
public:
27+
UBLOX_N2XX_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device);
28+
virtual nsapi_error_t clear();
29+
virtual nsapi_error_t set_ciot_optimization_config(CIoT_Supported_Opt supported_opt,
30+
CIoT_Preferred_UE_Opt preferred_opt,
31+
Callback<void(CIoT_Supported_Opt)> network_support_cb);
32+
};
33+
34+
} // namespace mbed
35+
36+
#endif // UBLOX_N2XX_CELLULAR_NETWORK_H_

0 commit comments

Comments
 (0)