Skip to content

Commit 0123f25

Browse files
author
Amanda Butler
authored
Merge pull request #489 from AriParkkila/new_engine
Cellular technology overview and porting updated
2 parents 8b1b8b0 + 6852088 commit 0123f25

File tree

8 files changed

+208
-83
lines changed

8 files changed

+208
-83
lines changed

docs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@
110110
"type": "markdown",
111111
"url": "https://github.com/ARMmbed/Handbook/blob/new_engine/docs/reference/technology/connectivity/wifi.md"
112112
},
113+
{
114+
"type": "markdown",
115+
"url": "https://github.com/ARMmbed/Handbook/blob/new_engine/docs/reference/technology/connectivity/cellular.md"
116+
},
113117
{
114118
"type": "markdown",
115119
"url": "https://github.com/ARMmbed/Handbook/blob/new_engine/docs/reference/technology/mesh/quick_start_intro.md"

docs/images/api-cellular-connect.png

45.5 KB
Loading

docs/images/api-cellular-device.png

12.5 KB
Loading

docs/images/api-cellular-ip-stack.png

10.6 KB
Loading

docs/images/api-cellular-overview.png

38.4 KB
Loading
19.9 KB
Loading
Lines changed: 38 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,10 @@
1-
## CellularInterface
1+
## Cellular module porting
22

3-
This document provides guidelines and details for setting up a cellular device driver with Mbed OS. Please see the [working principles when working with a cellular C++ API](https://os.mbed.com/docs/latest/reference/network-socket.html) for more information.
3+
This document provides guidelines how to make a cellular modem adaptation for Mbed OS. Please see [Cellular API usage](cellular-api.html) about how to use cellular modules from an application point of view.
44

5-
### Implementing CellularInterface
5+
### Adding modem target support
66

7-
You can implement a cellular network interface in different ways depending on your requirements and physical setup. For example:
8-
9-
<span class="images">![](https://s3-us-west-2.amazonaws.com/mbed-os-docs-images/Cell_AT.png)<span>Figure 1</span></span>
10-
11-
**Case 1: An implementation using on-chip network stacks (AT only mode, refer to figure 1)**
12-
13-
- Pros
14-
- Lighter RAM memory consumption and flash footprint.
15-
- More autonomous modem operation.
16-
17-
- Cons
18-
- Needs chip-specific implementation of an abstraction layer over AT-sockets to glue them together with standard Mbed OS NSAPI sockets.
19-
- Subtle variations in different on-chip network stacks and NSAPI implementations make maintenance difficult and require more testing.
20-
21-
<span class="images">![](https://s3-us-west-2.amazonaws.com/mbed-os-docs-images/Cell_PPP.png)<span>Figure 2</span></span>
22-
23-
**Case 2: An implementation using Mbed OS provided network stacks (PPP mode, refer to figure 2)**
24-
25-
- Pros
26-
- A well-established network stack with full Mbed OS support.
27-
- The inherent network stack provides all socket APIs.
28-
29-
- Cons
30-
- Heavier RAM memory consumption and bigger flash footprint.
31-
- All modems do not support PPP mode making AT only mode the only available choice.
32-
- Multiplexing command mode and data mode are not yet available.
33-
34-
#### Adding modem target support
35-
36-
For new targets, you may need to modify [targets.json](https://os.mbed.com/docs/v5.7/tools/adding-and-configuring-targets.html). `targets.json` defines all the target platforms that Mbed OS supports. If Mbed OS supports your specific target, an entry for your target is in this file. Define a global macro in your target description that tells the build system that your target has a modem, and the data connection type is attached with MCU.
7+
For new targets, you may need to modify [targets.json](/docs/development/tools/adding-and-configuring-targets.html), which defines all the target platforms that Mbed OS supports. If Mbed OS supports your specific target, an entry for your target is in this file. To tell the Mbed OS build configuration that your target board has an onboard cellular module, you need to define `modem_is_on_board` and `modem_data_connection_type`.
378

389
For example,
3910

@@ -62,7 +33,7 @@ For example,
6233
},
6334
```
6435

65-
Use standard pin names. A standard naming convention for pin names is required for standard modem pins in your target's **_'targets/TARGET_FAMILY/YOUR_TARGET/PinNames.h'_**. The example below shows the full UART capable modem. If any of these pins is not connected physically, mark it **_'NC'_**. Also indicate pin polarity.
36+
In addition you need to map onboard modem pin aliases to your target board pin names and polarity in `targets/TARGET_FAMILY/YOUR_TARGET/PinNames.h`. If any of the pins are not connected, mark it 'NC'. An example UART configuration:
6637

6738
```C
6839
typedef enum {
@@ -74,7 +45,7 @@ typedef enum {
7445
MDMDSR = P0_19, // Data Set Ready
7546
MDMDTR = P0_20, // Data Terminal Ready
7647
MDMRI = P0_21, // Ring Indicator
77-
MDMRTS = P0_22, // Request to Send
48+
MDMRTS = P0_22, // Ready to Receive
7849

7950
} PinName;
8051

@@ -85,71 +56,55 @@ typedef enum {
8556

8657
```
8758

88-
You must define all pins. Implement `onboard_modem_api.h`. The target board must provide an implementation of the [onboard_modem_API](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/onboard__modem__api_8h_source.html).
59+
### Adding a new cellular target
8960

90-
#### Modifying cellular targets
61+
You need to specify in [CellularTargets.h](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_cellular_targets_8h_source.html), which `<manufacturer-module>` is mounted on your board.
9162

92-
Setup for some predefined targets is available in [CellularTargets.h](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_cellular_targets_8h_source.html). For a new target, you need to modify `CellularTargets.h`. In `CellularTargets.h`, you need to specify a cellular device in addition to UART pins connecting the Mbed OS CPU to the modem. For example, if the new device MY_NEW_TARGET defined above in the "Adding modem target support" chapter is connected with QUECTEL BG96, you would need the following changes marked in between `// !!!!` in `CellularTargets.h`:
63+
```target
64+
65+
#elif <your target>
66+
#define CELLULAR_DEVICE <manufacturer-module>
9367
94-
```C
95-
...
96-
#elif TARGET_UBLOX_C027
97-
#define CELLULAR_DEVICE UBLOX_C027
98-
// !!!!
99-
// cellular device to be connected with MY_NEW_TARGET is specified below:
100-
#elif TARGET_MY_NEW_TARGET
101-
#define CELLULAR_DEVICE QUECTEL_BG96
102-
// !!!!
103-
#else
104-
#error Cellular target not defined, see cellular/targets.h
105-
//#define CELLULAR_TARGET <target-modem>
106-
//#define MDMTXD <pin-name>
107-
//#define MDMRXD <pin-name>
108-
#endif
109-
#endif
110-
// !!!!
111-
// cellular target and UART pins connecting MY_NEW_TARGET with the modem are specified below:
112-
#define CELLULAR_TARGET TARGET_MY_NEW_TARGET
113-
#define MDMTXD PTC17
114-
#define MDMRXD PTC16
115-
// !!!!
116-
...
11768
```
11869

119-
If none of the existing modems is compatible with the new modem, then create new modem implementation under [features/cellular/framework/targets](https://github.com/ARMmbed/mbed-os/blob/master/features/cellular/framework/targets). A device class inheriting [AT_CellularDevice](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_a_t___cellular_device_8h_source.html) is a minimum. [QUECTEL_BG96](https://github.com/ARMmbed/mbed-os/blob/master/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.h) is an example of the device class. You can create additional overlapping functionality for everything that is available in [features/cellular/framework/targets](https://github.com/ARMmbed/mbed-os/blob/master/features/cellular/framework/targets).
70+
You can browse the existing `manufacturer-modules` under `features/cellular/framework/targets`. If none of those are compatible with your module then you need to make a new cellular module adaptation.
12071

121-
#### Providing an implementation using on-chip network stacks (AT only mode)
72+
### Adding a new cellular module
12273

123-
[QUECTEL_BG96_CellularStack](https://github.com/ARMmbed/mbed-os/blob/master/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h) is an example of a modem specific AT command cellular stack implementation. For example, [mbed-os-example-cellular](https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-cellular/) instantiates the [EasyCellularConnection class](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_easy_cellular_connection_8h_source.html), which in turn instantiates the [CellularConnectionFSM class](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_cellular_connection_f_s_m_8h_source.html). CellularConnectionFSM instantiates classes implementing [the AT command layer](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_a_t___cellular_device_8h_source.html) between the modem and the Mbed OS CPU. For the [QUECTEL BG96](https://github.com/ARMmbed/mbed-os/tree/master/features/cellular/framework/targets/QUECTEL/BG96) classes [QUECTEL_BG96](https://github.com/ARMmbed/mbed-os/blob/master/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96.h), [QUECTEL_BG96_CellularStack](https://github.com/ARMmbed/mbed-os/blob/master/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.h) and [QUECTEL_BG96_CellularNetwork](https://github.com/ARMmbed/mbed-os/blob/master/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularNetwork.h) have been implemented for a modem specific functionality. QUECTEL_BG96_CellularStack implements QUECTEL BG96 specific AT command stack for socket data handling.
74+
Cellular module adaptations are very similar to each other and due to they only need to implement deviation from the default implementation, you can most probably reuse some existing adaptation.
12475

125-
#### Providing an implementation using Mbed OS provided network stacks (PPP mode)
76+
You need to create a new folder as _MANUFACTURER/MODULE/_ for your new cellular module in `features/cellular/framework/targets/`. A device class inheriting [AT_CellularDevice](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_a_t___cellular_device_8h_source.html) is a minimum, and you may need to extend other cellular APIs as well if the default implementation is not sufficient for your cellular module.
12677

127-
If the new modem supports PPP mode, then you can use the existing Mbed OS LWIP stack to control the modem when connecting to a network. To use the LWIP stack, set `lwip.ppp-enabled` to true in an application `mbed_app.json`. [UBLOX LISA](https://github.com/ARMmbed/mbed-os/tree/master/features/cellular/framework/targets/UBLOX/LISA_U) is an example of a modem implementation using PPP mode to connect to a network. For example, [mbed-os-example-cellular](https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-cellular/) instantiates [EasyCellularConnection class](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_easy_cellular_connection_8h_source.html), which in turn instantiates [CellularConnectionFSM class](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_cellular_connection_f_s_m_8h_source.html). CellularConnectionFSM instantiates classes implementing [the AT command layer](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_a_t___cellular_device_8h_source.html) between the modem and the Mbed OS CPU. For LISA classes [UBLOX_LISA_U](https://github.com/ARMmbed/mbed-os/blob/master/features/cellular/framework/targets/UBLOX/LISA_U/UBLOX_LISA_U.h), [UBLOX_LISA_U_CellularNetwork](https://github.com/ARMmbed/mbed-os/blob/master/features/cellular/framework/targets/UBLOX/LISA_U/UBLOX_LISA_U_CellularNetwork.h) and [UBLOX_LISA_U_CellularPower](https://github.com/ARMmbed/mbed-os/blob/master/features/cellular/framework/targets/UBLOX/LISA_U/UBLOX_LISA_U_CellularPower.h) have been implemented for a modem specific functionality. In the AT command layer, [AT_CellularNetwork](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_a_t___cellular_network_8h_source.html) includes functionality calling [nsapi_ppp_connect()](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/netsocket_2nsapi__ppp_8h_source.html) to start the data call through the PPP pipe.
78+
### Socket adaptation
12879

129-
### Testing
80+
You can implement socket API in two ways:
13081

131-
Once you have your target and driver port ready, you can verify your implementation by running port verification tests on your system. You must have `mbed-greentea` installed for this.
82+
- Use the IP stack on the cellular module (AT mode).
83+
- Use the LWIP stack on Mbed OS (PPP mode).
13284

133-
- To run the tests:
134-
1. From the root of your application, enter this command:
85+
If your cellular module has an IP stack, you need to implement AT commands to connect to a network and to control network sockets. If the modem supports PPP mode, you can use LWIP stack to handle sockets and IP connectivity for your modem after connected to a network. A modem can support the both AT and PPP modes, but an application developer need to select at compile time whether to use AT mode or PPP mode in the application's `mbed_app.json` configuration file using `lwip.ppp-enabled` flag.
13586

136-
```
137-
mbed test --compile-list
138-
```
87+
For example implementations of socket adaptation, look for `features/cellular/framework/targets`.
13988

140-
1. Look for the name of a test suite matching `mbed-os-features-cellular-tests-cellular-cellular_all`.
141-
1. Run tests with the command:
89+
When the modem has AT and/or PPP mode support in place and the application developer has selected which mode to use, it's up to the cellular framework to instantiate the correct classes. For example, [mbed-os-example-cellular](https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-cellular/) instantiates [EasyCellularConnection class](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_easy_cellular_connection_8h_source.html), which in turn instantiates [CellularConnectionFSM class](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_cellular_connection_f_s_m_8h_source.html). CellularConnectionFSM instantiates classes implementing [the AT command layer](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_a_t___cellular_device_8h_source.html) between the modem and the Mbed OS CPU. If an application developer has configured PPP mode in `mbed_app.json` then [AT_CellularNetwork](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/_a_t___cellular_network_8h_source.html) connects to a cellular network and calls [nsapi_ppp_connect()](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/netsocket_2nsapi__ppp_8h_source.html) to start the data call through the PPP pipe using LWIP sockets.
90+
91+
### Testing
92+
93+
Once you have your target and driver port ready, you can verify your implementation by running port verification tests on your system. You must have `mbed-greentea` installed for this.
14294

143-
```
144-
mbed test -n "mbed-os-features-cellular-tests-cellular-cellular_all" -m YOURMACHINE -t YOURCOMPILER --app-config YOURCONFIG.json
145-
```
95+
To run the tests:
14696

147-
For more information on the `mbed-greentea` test suite, please visit [its documentation](https://os.mbed.com/docs/v5.7/tools/greentea.html).
97+
1. From the root of your application, enter this command:
14898

149-
You can also run stand-alone tests. The [`UNITTESTS` folder](https://github.com/ARMmbed/mbed-os/tree/master/features/cellular/UNITTESTS) contains unit tests for cellular specific classes. Unit tests are based on the stubbing method.
99+
```
100+
mbed test --compile-list
101+
```
150102
151-
You can run those tests locally by running `./run_tests` script under the [`UNITTESTS` folder](https://github.com/ARMmbed/mbed-os/tree/master/features/cellular/UNITTESTS).
103+
1. Look for the name of a test suite matching `features-cellular-tests-*`.
104+
1. Run tests with the command:
152105
153-
You need the following applications: `cpputest`, `gcov` and `lcov` (`genhtml`) for running the tests by themselves.
106+
```
107+
mbed test -n "mbed-os-features-cellular-tests-*" -m TARGET -t TOOLCHAIN --app-config YOURCONFIG.json
108+
```
154109
155-
After you have run the `run_tests` script, you can find test results in the [`UNITTESTS/results` folder](https://github.com/ARMmbed/mbed-os/tree/master/features/cellular/UNITTESTS) and line and function coverages in the [`UNITTESTS/coverages` folder](https://github.com/ARMmbed/mbed-os/tree/master/features/cellular/UNITTESTS).
110+
For more information on the `mbed-greentea` test suite, please visit [its documentation](/docs/development/tools/greentea.html).

0 commit comments

Comments
 (0)