2021-04-13 20:29:55 +02:00
# ESP MODEM
This component is used to communicate with modems in the command mode (using AT commands), as well as the data mode
2022-10-11 16:31:57 +02:00
(over PPPoS protocol).
2021-04-13 20:29:55 +02:00
The modem device is modeled with a DCE (Data Communication Equipment) object, which is composed of:
* DTE (Data Terminal Equipment), which abstracts the terminal (currently only UART implemented).
* PPP Netif representing a network interface communicating with the DTE using PPP protocol.
* Module abstracting the specific device model and its commands.
```
2022-10-11 16:31:57 +02:00
+-----+
2021-04-13 20:29:55 +02:00
| DTE |--+
+-----+ | +-------+
+-->| DCE |
+-------+ | |o--- set_mode(command/data)
| Module|--->| |
+-------+ | |o--- send_commands
+->| |
2022-10-11 16:31:57 +02:00
+------+ | +-------+
| PPP |--+
2021-04-13 20:29:55 +02:00
| netif|------------------> network events
2022-10-11 16:31:57 +02:00
+------+
2021-04-13 20:29:55 +02:00
```
## Modem components
### DCE
This is the basic operational unit of the esp_modem component, abstracting a specific module in software,
2022-10-11 16:31:57 +02:00
which is basically configured by
2021-04-13 20:29:55 +02:00
* the I/O communication media (UART), defined by the DTE configuration
* the specific command library supported by the device model, defined with the module type
* network interface configuration (PPPoS config in lwip)
After the object is created, the application interaction with the DCE is in
* issuing specific commands to the modem
* switching between data and command mode
### DTE
2021-05-26 16:41:19 +08:00
Is an abstraction of the physical interface connected to the modem. Current implementation supports only UART
2021-04-13 20:29:55 +02:00
2021-05-26 16:41:19 +08:00
### PPP netif
2021-04-13 20:29:55 +02:00
2021-05-26 16:41:19 +08:00
Is used to attach the specific network interface to a network communication protocol used by the modem. Currently implementation supports only PPPoS protocol.
2021-04-13 20:29:55 +02:00
### Module
Abstraction of the specific modem device. Currently the component supports SIM800, BG96, SIM7600.
## Use cases
2021-05-26 16:41:19 +08:00
Users interact with the esp-modem using the DCE's interface, to basically
2021-04-13 20:29:55 +02:00
* Switch between command and data mode to connect to the internet via cellular network.
* Send various commands to the device (e.g. send SMS)
2022-10-11 16:31:57 +02:00
The applications typically register handlers for network events to receive notification on the network availability and
2021-04-13 20:29:55 +02:00
IP address changes.
Common use cases of the esp-modem are also listed as the examples:
* `examples/pppos_client` -- simple client which reads some module properties and switches to the data mode to connect to a public mqtt broker.
2021-05-26 16:41:19 +08:00
* `examples/modem_console` -- is an example to exercise all possible module commands in a console application.
2021-07-23 09:42:25 +02:00
* `examples/ap_to_pppos` -- this example focuses on the network connectivity of the esp-modem and provides a WiFi AP that forwards packets (and uses NAT) to and from the PPPoS connection.
2021-04-13 20:29:55 +02:00
## Extensibility
### CMUX
Implementation of virtual terminals is an experimental feature, which allows users to also issue commands in the data mode,
2021-05-26 16:41:19 +08:00
after creating multiple virtual terminals, designating some of them solely to data mode, others solely to command mode.
2021-04-13 20:29:55 +02:00
### DTE's
2022-09-30 12:01:50 +02:00
Currently, we support only UART (and USB as a preview feature), but modern modules support other communication interfaces, such as USB, SPI.
2021-04-13 20:29:55 +02:00
### Other devices
2021-06-17 16:46:45 +02:00
Adding a new device is a must-have requirement for the esp-modem component. Different modules support different commands,
2021-04-13 20:29:55 +02:00
or some commands might have a different implementation. Adding a new device means to provide a new implementation
as a class derived from `GenericModule` , where we could add new commands or modify the existing ones.
2022-09-30 12:01:50 +02:00
## Configuration
Modem abstraction is configurable both compile-time and run-time.
### Component Kconfig
Compile-time configuration is provided using menuconfig. Please check the description for the CMUX mode configuration options.
### Runtime configuration
Is defined using standard configuration structures for `DTE` and `DCE` objects separately. Please find documentation of
* :cpp:class:`esp_modem_dte_config_t`
* :cpp:class:`esp_modem_dce_config_t`