Skip to content

Commit ca1989b

Browse files
author
Amanda Butler
authored
Merge pull request #928 from mirelachirica/nonip
Cellular: Documenting the support for Non-IP data delivery feature
2 parents 252282f + 303292f commit ca1989b

File tree

4 files changed

+113
-3
lines changed

4 files changed

+113
-3
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
## Non-IP cellular socket
2+
3+
The CellularNonIPSocket class provides, through standard socket `send` and `recv` member functions, the ability to send and receive 3GPP non-IP datagrams (NIDD) using our cellular IoT feature. This feature is implemented in the [`ControlPlane_netif`](https://os.mbed.com/docs/development/mbed-os-api-doxy/classmbed_1_1_control_plane__netif.html) class.
4+
5+
The constructor takes no parameters. To initialize the socket on a specified NetworkInterface, you must call the `open` method, which takes a CellularContext pointer.
6+
7+
[`CellularContext`](https://os.mbed.com/docs/development/mbed-os-api-doxy/_cellular_context_8h.html) sets up the modem into the Control Plane optimization mode of operation if it is requested and if the cellular network supports it.
8+
9+
Control plane optimization is a new feature for cellular IoT (CIoT). With it, the device can use cellular control channels for data communications, to save power and resources by using less radio signaling.
10+
11+
Note: <span class="notes">**Note:** Non-IP use usually requires integration to a cellular operator messaging service. The service supports a web API to send to and receive the non-IP using devices.</span>
12+
13+
You can request Control Plane optimization mode either with CellularDevice's [`create_context`](https://os.mbed.com/docs/development/mbed-os-api-doxy/classmbed_1_1_cellular_device.html#a43b9e992dff1cb5d880acec576e9d06f) or by configuring it in the cellular `mbed_lib.json`:
14+
15+
```json
16+
{
17+
"name": "cellular",
18+
"config": {
19+
"control-plane-opt": {
20+
"help": "Enables control plane CIoT EPS optimisation",
21+
"value": true
22+
}
23+
}
24+
}
25+
```
26+
27+
### CellularNonIPSocket class reference
28+
29+
[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/development/mbed-os-api-doxy/classmbed_1_1_cellular_non_i_p_socket.html)
30+
31+
The following code demonstrates how to create and use a cellular non-IP socket:
32+
33+
```
34+
35+
#include "mbed.h"
36+
#include "CellularNonIPSocket.h"
37+
#include "CellularDevice.h"
38+
39+
// Network interface
40+
NetworkInterface *iface;
41+
42+
int main() {
43+
// Bring up the cellular interface
44+
iface = CellularContext::get_default_nonip_instance();
45+
MBED_ASSERT(iface);
46+
47+
// sim pin, apn, credentials and possible plmn are taken automatically from json when using NetworkInterface::set_default_parameters()
48+
iface->set_default_parameters();
49+
50+
printf("Cellular Non-IP Socket example\n");
51+
if(NSAPI_ERROR_OK != iface->connect() || NSAPI_STATUS_GLOBAL_UP != iface->get_connection_status()) {
52+
printf("Error connecting\n");
53+
return -1;
54+
}
55+
56+
CellularNonIPSocket sock;
57+
58+
nsapi_error_t retcode = sock.open((CellularContext*)iface);
59+
60+
if (retcode != NSAPI_ERROR_OK) {
61+
printf("CellularNonIPSocket.open() fails, code: %d\n", retcode);
62+
return -1;
63+
}
64+
65+
const char *send_string = "TEST";
66+
67+
if(0 > sock.send((void*) send_string, sizeof(send_string))) {
68+
printf("Error sending data\n");
69+
return -1;
70+
}
71+
72+
printf("Success sending data\n");
73+
74+
char recv_buf[4];
75+
if(0 > sock.recv((void *)recv_buf, sizeof(recv_buf))) {
76+
printf("Error receiving data\n");
77+
return -1;
78+
}
79+
80+
printf("Success receiving data\n");
81+
82+
// Close the socket and bring down the network interface
83+
sock.close();
84+
iface->disconnect();
85+
return 0;
86+
}
87+
88+
```

docs/api/networksocket/networksocket.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h2 id="network-socket">Network socket overview</h2>
22

3-
The application programming interface for IP networking is the Socket API. As described in the [IP networking](../reference/ip-networking.html) section, the Socket API relates to OSI layer 4, the Transport layer. In Mbed OS, the Socket API supports both TCP and UDP protocols.
3+
The application programming interface for IP networking is the Socket API. As described in the [IP networking](../reference/ip-networking.html) section, the Socket API relates to OSI layer 4, the Transport layer. In Mbed OS, the Socket API is abstract and supports various protocols such as TCP, UDP and non-IP data delivery for NB-IoT cellular networks.
44

55
<span class="images">![](https://s3-us-west-2.amazonaws.com/mbed-os-docs-images/ip-networking.png)<span>Sockets</span></span>
66

@@ -97,6 +97,7 @@ The network socket API provides a common interface for using sockets on network
9797
- [UDPSocket](udpsocket.html): This class provides the ability to send packets of data over UDP.
9898
- [TCPSocket](tcpsocket.html): This class provides the ability to send a stream of data over TCP.
9999
- [SocketAddress](socketaddress.html): You can use this class to represent the IP address and port pair of a unique network endpoint.
100+
- [CellularNonIPSocket](cellularnonipsocket.html): This class provides the ability to send and receive 3GPP non-IP datagrams (NIDD) using the cellular IoT feature.
100101
- [Network status](network-status.html): API for monitoring network status changes.
101102
- [DNS resolver](dns-resolver.html): API for resolving DNS names
102103

docs/reference/configuration/Connectivity.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,21 @@ Name: cellular.use-apn-lookup
157157
Defined by: library:cellular
158158
Macro name: MBED_CONF_CELLULAR_USE_APN_LOOKUP
159159
Value: 1 (set by library:cellular)
160+
Name: cellular.debug-at
161+
Description: Enable AT debug prints
162+
Defined by: library:cellular
163+
Macro name: MBED_CONF_CELLULAR_DEBUG_AT
164+
Value: 0 (set by library:cellular)
165+
Name: cellular.radio-access-technology
166+
Description: Radio access technology to use. Value in integer: GSM=0, GSM_COMPACT=1, UTRAN=2, EGPRS=3, HSDPA=4, HSUPA=5, HSDPA_HSUPA=6, E_UTRAN=7, CATM1=8 ,NB1=9
167+
Defined by: library:cellular
168+
Macro name: MBED_CONF_CELLULAR_RADIO_ACCESS_TECHNOLOGY
169+
Value: null (set by library:cellular)
170+
Name: cellular.control-plane-opt
171+
Description: Enables control plane CIoT EPS optimisation
172+
Defined by: library:cellular
173+
Macro name: MBED_CONF_CELLULAR_CONTROL_PLANE_OPT
174+
Value: 0 (set by library:cellular)
160175
Name: ppp-cell-iface.apn-lookup
161176
Defined by: library:ppp-cell-iface
162177
Macro name: MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP

docs/reference/technology/connectivity/connectivity.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ For IP devices:
1212
* NB-IoT.
1313
* Bluetooth Low Energy (BLE).
1414

15-
Non-IP devices require a gateway:
15+
Non-IP devices:
1616

1717
* LoRaWAN.
18+
* Cellular.
1819

1920
### Choosing your connectivity method
2021

@@ -92,7 +93,6 @@ Because of its long range (up to 20 km) and low power, it is suitable for low da
9293

9394
The [LoRa](lora-tech.html) section and [LoRa tutorial](../tutorials/LoRa-tutorial.html) describe LoRA networking.
9495

95-
9696
#### NFC
9797

9898
<span class="images">![](https://s3-us-west-2.amazonaws.com/mbed-os-docs-images/n_mark.png)<span>NFC</span></span>
@@ -101,6 +101,12 @@ Near-field communication (NFC) is a short range (few centimeters) wireless techn
101101

102102
To learn how to use NFC with Mbed OS, please refer to the [Mbed OS NFC overview](../apis/nfc.html).
103103

104+
#### NB-IoT cellular
105+
106+
Non-IP Data Delivery (NIDD) is a new feature for communication over NB-IoT. It is enabled by Control Plane cellular IoT EPS optimization and meant to provide improved support of small data transfer. It does this by transporting user data over the control channel, thus reducing the total number of control plane messages when handling a short data transaction.
107+
108+
To learn how to use this feature with Mbed OS, please refer to [CellularNonIPSocket](../apis/cellularnonipsocket.html).
109+
104110
#### Memory needs for Pelion-connected devices
105111

106112
Mbed OS's baseline memory footprint, without Pelion connectivity, is 2.8kb of RAM and 8.2kb of flash. When you add connectivity and full functionality, the footprint grows:

0 commit comments

Comments
 (0)