Skip to content

Commit 454a356

Browse files
author
Mirela Chirica
committed
Cellular: Documenting the support for Non-IP data delivery feature
1 parent f1934a0 commit 454a356

File tree

3 files changed

+93
-2
lines changed

3 files changed

+93
-2
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 Non-IP datagrams using Control Plane CIoT EPS optimisation feature of the NB-IoT networks. This feature is implemented in ControlPlane_netif class. [`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 `open` method, which takes a CellularContext pointer.
6+
7+
[`CellularContext`](https://os.mbed.com/docs/development/mbed-os-api-doxy/_cellular_context_8h.html) is setting up the modem into the Control Plane CIoT EPS optimisation mode of operation if it is requested and cellular network supports it.
8+
9+
Control Plane CIoT EPS optimisation mode can be requested either on CellularDevice's [`create_context`](https://os.mbed.com/docs/development/mbed-os-api-doxy/classmbed_1_1_cellular_device.html#a43b9e992dff1cb5d880acec576e9d06f) or configured in cellular mbed_lib.json:
10+
11+
```json
12+
{
13+
"name": "cellular",
14+
"config": {
15+
"control-plane-opt": {
16+
"help": "Enables control plane CIoT EPS optimisation",
17+
"value": true
18+
}
19+
}
20+
}
21+
```
22+
ControlPlane
23+
### CellularNonIPSocket class reference
24+
25+
[![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)
26+
27+
The following code demonstrates how to create and use a cellular Non-IP socket:
28+
```
29+
30+
#include "mbed.h"
31+
#include "CellularNonIPSocket.h"
32+
#include "CellularDevice.h"
33+
34+
// Network interface
35+
NetworkInterface *iface;
36+
37+
int main() {
38+
// Bring up the cellular interface
39+
iface = CellularContext::get_default_nonip_instance();
40+
MBED_ASSERT(iface);
41+
42+
// sim pin, apn, credentials and possible plmn are taken automatically from json when using NetworkInterface::set_default_parameters()
43+
iface->set_default_parameters();
44+
45+
printf("Cellular Non-IP Socket example\n");
46+
if(NSAPI_ERROR_OK != iface->connect() || NSAPI_STATUS_GLOBAL_UP != iface->get_connection_status()) {
47+
printf("Error connecting\n");
48+
return -1;
49+
}
50+
51+
CellularNonIPSocket sock;
52+
53+
nsapi_error_t retcode = sock.open((CellularContext*)iface);
54+
55+
if (retcode != NSAPI_ERROR_OK) {
56+
printf("CellularNonIPSocket.open() fails, code: %d\n", retcode);
57+
return -1;
58+
}
59+
60+
const char *send_string = "TEST";
61+
62+
if(0 > sock.send((void*) send_string, sizeof(send_string))) {
63+
printf("Error sending data\n");
64+
return -1;
65+
}
66+
67+
printf("Success sending data\n");
68+
69+
char recv_buf[4];
70+
if(0 > sock.recv((void *)recv_buf, sizeof(recv_buf))) {
71+
printf("Error receiving data\n");
72+
return -1;
73+
}
74+
75+
printf("Success receiving data\n");
76+
77+
// Close the socket and bring down the network interface
78+
sock.close();
79+
iface->disconnect();
80+
return 0;
81+
}
82+
83+
```

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 Non-IP datagrams using Control Plane CIoT EPS optimisation feature of the NB-IoT cellular networks.
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/technology/connectivity/connectivity.md

Lines changed: 8 additions & 1 deletion
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

@@ -101,6 +102,12 @@ Near-field communication (NFC) is a short range (few centimeters) wireless techn
101102

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

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

106113
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)