Skip to content

Commit 849fe7b

Browse files
authored
Merge pull request #698 from david-cermak/fix/modem_minor_fixes_on_1.2
[modem]: Support for URC handler in C-API -> v1.2.1
2 parents b65cff3 + 5eadf1e commit 849fe7b

File tree

20 files changed

+84
-72
lines changed

20 files changed

+84
-72
lines changed

.github/workflows/modem__build-host-tests.yml

+3-12
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ jobs:
1313
name: Build examples
1414
strategy:
1515
matrix:
16-
idf_ver: ["latest", "release-v4.4", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3"]
16+
idf_ver: ["latest", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3", "release-v5.4"]
1717
example: ["pppos_client", "modem_console", "modem_tcp_client", "ap_to_pppos", "simple_cmux_client"]
18-
exclude:
19-
- idf_ver: "release-v4.4"
20-
example: modem_tcp_client
2118
include:
2219
- idf_ver: "release-v5.0"
2320
example: "simple_cmux_client"
@@ -26,13 +23,7 @@ jobs:
2623
runs-on: ubuntu-22.04
2724
container: espressif/idf:${{ matrix.idf_ver }}
2825
steps:
29-
- name: Check out code (v3) # @v4 failed due to Node 20's requirement, incompatible with older IDF versions
30-
if: matrix.idf_ver != 'latest' && matrix.idf_ver < 'release-v5.0'
31-
uses: actions/checkout@v3
32-
with:
33-
path: protocols
34-
- name: Check out code (v4)
35-
if: matrix.idf_ver == 'latest' || matrix.idf_ver >= 'release-v5.0'
26+
- name: Check out code
3627
uses: actions/checkout@v4
3728
with:
3829
path: protocols
@@ -53,7 +44,7 @@ jobs:
5344
name: Build tests
5445
strategy:
5546
matrix:
56-
idf_ver: ["release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3", "latest"]
47+
idf_ver: ["release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3", "release-v5.4", "latest"]
5748
test: ["target", "target_ota", "target_iperf"]
5849

5950
runs-on: ubuntu-22.04

components/esp_modem/.cz.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ commitizen:
33
bump_message: 'bump(modem): $current_version -> $new_version'
44
pre_bump_hooks: python ../../ci/changelog.py esp_modem
55
tag_format: modem-v$version
6-
version: 1.2.0
6+
version: 1.2.1
77
version_files:
88
- idf_component.yml

components/esp_modem/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [1.2.1](https://github.com/espressif/esp-protocols/commits/modem-v1.2.1)
4+
5+
### Bug Fixes
6+
7+
- Use higher GPIO range to support new chips ([428fdbbd](https://github.com/espressif/esp-protocols/commit/428fdbbd), [#558](https://github.com/espressif/esp-protocols/issues/558))
8+
- Remove tests and support for IDFv4.4, added IDFv5.4 ([433a033f](https://github.com/espressif/esp-protocols/commit/433a033f))
9+
- Fix typo GENETIC -> GENERIC in mode types ([090b1ff8](https://github.com/espressif/esp-protocols/commit/090b1ff8), [#667](https://github.com/espressif/esp-protocols/issues/667))
10+
- Add support for URC handler into C-API ([295d99df](https://github.com/espressif/esp-protocols/commit/295d99df), [#180](https://github.com/espressif/esp-protocols/issues/180))
11+
312
## [1.2.0](https://github.com/espressif/esp-protocols/commits/modem-v1.2.0)
413

514
### Features

components/esp_modem/examples/ap_to_pppos/README.md

-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,3 @@ By default, this example simply connects to the PPP server using a supported dev
1515
This example however, doesn't rely on sending specific AT commands, just the bare minimum to setup the cellular network.
1616
Thus, if the `EXAMPLE_USE_MINIMAL_DCE` option is enabled, we directly inherit from the `ModuleIf` and implement only the basic commands.
1717
Also, to demonstrate the dce_factory functionality, a new `NetDCE_Factory` is implemented for creating the network module and the DCE.
18-
19-
### Supported IDF versions
20-
21-
This example is only supported from `v4.2`, since is uses NAPT feature.

components/esp_modem/examples/linux_modem/README.md

-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,3 @@ over PPPoS, i.e. over the modem serial line.
1717
* Experiment with the network, after getting the IP from the modem device
1818
- directly in the code
1919
- in the system (need to set `tun` interface IP, dns servers, and routing the desired traffic over the tun interface)
20-
21-
### Supported IDF versions
22-
23-
This example (using the default CMake IDF build system) is only supported from `v4.4`, since is uses `idf.py`'s linux target.

components/esp_modem/examples/modem_console/README.md

-6
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,3 @@ USB example uses Quactel BG96 modem device. BG96 needs a positive pulse on its P
2525
This example supports USB modem hot-plugging and reconnection. There is one limitation coming from esp_console component:
2626
When esp_console REPL is being destroyed (after USB mode disconnection or after `exit` command), it will block on UART read.
2727
You must send a character to it (via idf.py monitor), so it unblocks and properly exits.
28-
29-
### Supported IDF versions
30-
31-
This example is only supported from `v4.2`, due to support of the console repl mode.
32-
33-
USB example is supported from `v4.4`.

components/esp_modem/examples/modem_console/main/Kconfig.projbuild

+5-5
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,28 @@ menu "Example Configuration"
108108
config EXAMPLE_MODEM_UART_TX_PIN
109109
int "TXD Pin Number"
110110
default 25
111-
range 0 31
111+
range 0 56
112112
help
113113
Pin number of UART TX.
114114

115115
config EXAMPLE_MODEM_UART_RX_PIN
116116
int "RXD Pin Number"
117117
default 26
118-
range 0 31
118+
range 0 56
119119
help
120120
Pin number of UART RX.
121121

122122
config EXAMPLE_MODEM_UART_RTS_PIN
123123
int "RTS Pin Number"
124124
default 27
125-
range 0 31
125+
range 0 56
126126
help
127127
Pin number of UART RTS.
128128

129129
config EXAMPLE_MODEM_UART_CTS_PIN
130130
int "CTS Pin Number"
131131
default 23
132-
range 0 31
132+
range 0 56
133133
help
134134
Pin number of UART CTS.
135135

@@ -179,7 +179,7 @@ menu "Example Configuration"
179179
config EXAMPLE_MODEM_PWRKEY_PIN
180180
int "PWRKEY Pin Number"
181181
default 18
182-
range 0 31
182+
range 0 56
183183
help
184184
Pin number connected to modem's power key pin.
185185
endmenu

components/esp_modem/examples/modem_psm/main/Kconfig.projbuild

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ menu "Example Configuration"
2020
config EXAMPLE_MODEM_UART_TX_PIN
2121
int "TXD Pin Number"
2222
default 4
23-
range 0 31
23+
range 0 56
2424
help
2525
Pin number of UART TX.
2626

2727
config EXAMPLE_MODEM_UART_RX_PIN
2828
int "RXD Pin Number"
2929
default 5
30-
range 0 31
30+
range 0 56
3131
help
3232
Pin number of UART RX.
3333

@@ -70,14 +70,14 @@ menu "Example Configuration"
7070
config EXAMPLE_MODEM_PWRKEY_PIN
7171
int "PWRKEY Pin Number"
7272
default 18
73-
range 0 31
73+
range 0 56
7474
help
7575
Pin number connected to modem's power key pin.
7676

7777
config EXAMPLE_MODEM_STATUS_PIN
7878
int "STATUS Pin Number"
7979
default 19
80-
range 0 31
80+
range 0 56
8181
help
8282
Pin number connected to modem's status pin.
8383

components/esp_modem/examples/modem_tcp_client/README.md

-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,3 @@ To enable this mode, please set `EXAMPLE_CUSTOM_TCP_TRANSPORT=y`
2222
This configuration could be used with any network library, which is connecting to a localhost endpoint instead of remote one. This example creates a localhost listener which basically mimics the remote endpoint by forwarding the traffic between the library and the TCP/socket layer of the modem (which is already secure if the TLS is used in the network library)
2323

2424
![with localhost listener](at_client_localhost.png)
25-
26-
### Supported IDF versions
27-
28-
This example is supported from IDF `v5.0`.

components/esp_modem/examples/modem_tcp_client/main/Kconfig.projbuild

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,28 @@ menu "Example Configuration"
3030
config EXAMPLE_MODEM_UART_TX_PIN
3131
int "TXD Pin Number"
3232
default 25
33-
range 0 31
33+
range 0 56
3434
help
3535
Pin number of UART TX.
3636

3737
config EXAMPLE_MODEM_UART_RX_PIN
3838
int "RXD Pin Number"
3939
default 26
40-
range 0 31
40+
range 0 56
4141
help
4242
Pin number of UART RX.
4343

4444
config EXAMPLE_MODEM_UART_RTS_PIN
4545
int "RTS Pin Number"
4646
default 27
47-
range 0 31
47+
range 0 56
4848
help
4949
Pin number of UART RTS.
5050

5151
config EXAMPLE_MODEM_UART_CTS_PIN
5252
int "CTS Pin Number"
5353
default 23
54-
range 0 31
54+
range 0 56
5555
help
5656
Pin number of UART CTS.
5757

components/esp_modem/examples/pppos_client/README.md

-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,3 @@ For USB enabled targets (ESP32-S2, ESP32-S3, or ESP32-P4), it is possible to con
1818
USB example uses Quactel BG96 modem device. BG96 needs a positive pulse on its PWK pin to boot-up.
1919

2020
This example supports USB modem hot-plugging and reconnection.
21-
22-
### Supported IDF versions
23-
24-
This example is only supported from `v4.1`, as this is the default dependency of `esp-modem` component.
25-
26-
USB example is supported from `v4.4`.

components/esp_modem/examples/pppos_client/main/Kconfig.projbuild

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,28 +100,28 @@ menu "Example Configuration"
100100
config EXAMPLE_MODEM_UART_TX_PIN
101101
int "TXD Pin Number"
102102
default 25
103-
range 0 31
103+
range 0 56
104104
help
105105
Pin number of UART TX.
106106

107107
config EXAMPLE_MODEM_UART_RX_PIN
108108
int "RXD Pin Number"
109109
default 26
110-
range 0 31
110+
range 0 56
111111
help
112112
Pin number of UART RX.
113113

114114
config EXAMPLE_MODEM_UART_RTS_PIN
115115
int "RTS Pin Number"
116116
default 27
117-
range 0 31
117+
range 0 56
118118
help
119119
Pin number of UART RTS.
120120

121121
config EXAMPLE_MODEM_UART_CTS_PIN
122122
int "CTS Pin Number"
123123
default 23
124-
range 0 31
124+
range 0 56
125125
help
126126
Pin number of UART CTS.
127127

components/esp_modem/examples/simple_cmux_client/README.md

-8
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,3 @@ The example uses the following configuration options to demonstrate basic esp-mo
1111
* `EXAMPLE_NEED_SIM_PIN`: To unlock the SIM card with a PIN code if needed
1212
* `EXAMPLE_PERFORM_OTA`: To start simple OTA at the end of the example to exercise basic CMUX/modem networking. Please note that the option `CONFIG_UART_ISR_IN_IRAM` is not enabled automatically, so that buffer overflows are expected and CMUX/PPP and networking should recover.
1313
* `EXAMPLE_USE_VFS_TERM`: To demonstrate using an abstract file descriptor to talk to the device (instead of the UART driver directly). This option could be used when implementing a custom VFS driver.
14-
15-
## About the esp_modem
16-
17-
Please check the component [README](../../README.md)
18-
19-
### Supported IDF versions
20-
21-
This example is only supported from `v4.3`, since is uses an experimental `esp_event_cxx` component.

components/esp_modem/examples/simple_cmux_client/main/Kconfig.projbuild

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,28 @@ menu "Example Configuration"
6969
config EXAMPLE_MODEM_UART_TX_PIN
7070
int "TXD Pin Number"
7171
default 25
72-
range 0 31
72+
range 0 56
7373
help
7474
Pin number of UART TX.
7575

7676
config EXAMPLE_MODEM_UART_RX_PIN
7777
int "RXD Pin Number"
7878
default 26
79-
range 0 31
79+
range 0 56
8080
help
8181
Pin number of UART RX.
8282

8383
config EXAMPLE_MODEM_UART_RTS_PIN
8484
int "RTS Pin Number"
8585
default 27
86-
range 0 31
86+
range 0 56
8787
help
8888
Pin number of UART RTS.
8989

9090
config EXAMPLE_MODEM_UART_CTS_PIN
9191
int "CTS Pin Number"
9292
default 23
93-
range 0 31
93+
range 0 56
9494
help
9595
Pin number of UART CTS.
9696
endmenu

components/esp_modem/idf_component.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.2.0"
1+
version: "1.2.1"
22
description: Library for communicating with cellular modems in command and data modes
33
url: https://github.com/espressif/esp-protocols/tree/master/components/esp_modem
44
issues: https://github.com/espressif/esp-protocols/issues

components/esp_modem/include/esp_modem_c_api_types.h

+20-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
extern "C" {
1414
#endif
1515

16+
/* Compatibility macro to be removed in v2.0
17+
*/
18+
#define ESP_MODEM_DCE_GENETIC ESP_MODEM_DCE_GENERIC
19+
1620
typedef struct esp_modem_dce_wrap esp_modem_dce_t;
1721

1822
typedef struct esp_modem_PdpContext_t {
@@ -47,7 +51,7 @@ typedef enum esp_modem_dce_mode {
4751
* @brief DCE devices: Enum list of supported devices
4852
*/
4953
typedef enum esp_modem_dce_device {
50-
ESP_MODEM_DCE_GENETIC, /**< The most generic device */
54+
ESP_MODEM_DCE_GENERIC, /**< The most generic device */
5155
ESP_MODEM_DCE_SIM7600,
5256
ESP_MODEM_DCE_SIM7070,
5357
ESP_MODEM_DCE_SIM7000,
@@ -141,6 +145,21 @@ esp_err_t esp_modem_command(esp_modem_dce_t *dce, const char *command, esp_err_t
141145
*/
142146
esp_err_t esp_modem_set_apn(esp_modem_dce_t *dce, const char *apn);
143147

148+
#ifdef CONFIG_ESP_MODEM_URC_HANDLER
149+
/**
150+
* @brief Sets a handler for unsolicited result codes (URCs) from the modem
151+
*
152+
* This function registers a callback that is triggered whenever an unsolicited
153+
* result code (URC) is received from the modem. URCs are typically sent by the
154+
* modem without a prior command to notify the host about certain events or status changes.
155+
*
156+
* @param dce Modem DCE handle
157+
* @param got_line_cb Callback function which is called whenever a URC line is received
158+
* @return ESP_OK on success, ESP_FAIL on failure
159+
*/
160+
esp_err_t esp_modem_set_urc(esp_modem_dce_t *dce, esp_err_t(*got_line_cb)(uint8_t *data, size_t len));
161+
#endif
162+
144163
/**
145164
* @}
146165
*/

components/esp_modem/include/esp_private/c_api_wrapper.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ inline dce_factory::ModemType convert_modem_enum(esp_modem_dce_device_t module)
4444
case ESP_MODEM_DCE_SIM800:
4545
return esp_modem::dce_factory::ModemType::SIM800;
4646
default:
47-
case ESP_MODEM_DCE_GENETIC:
47+
case ESP_MODEM_DCE_GENERIC:
4848
return esp_modem::dce_factory::ModemType::GenericModule;
4949
}
5050
}

components/esp_modem/src/esp_modem_c_api.cpp

+25-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extern "C" esp_modem_dce_t *esp_modem_new_dev(esp_modem_dce_device_t module, con
6060

6161
extern "C" esp_modem_dce_t *esp_modem_new(const esp_modem_dte_config_t *dte_config, const esp_modem_dce_config_t *dce_config, esp_netif_t *netif)
6262
{
63-
return esp_modem_new_dev(ESP_MODEM_DCE_GENETIC, dte_config, dce_config, netif);
63+
return esp_modem_new_dev(ESP_MODEM_DCE_GENERIC, dte_config, dce_config, netif);
6464
}
6565

6666
extern "C" void esp_modem_destroy(esp_modem_dce_t *dce_wrap)
@@ -451,3 +451,27 @@ extern "C" esp_err_t esp_modem_set_apn(esp_modem_dce_t *dce_wrap, const char *ap
451451
dce_wrap->dce->get_module()->configure_pdp_context(std::move(new_pdp));
452452
return ESP_OK;
453453
}
454+
455+
#ifdef CONFIG_ESP_MODEM_URC_HANDLER
456+
extern "C" esp_err_t esp_modem_set_urc(esp_modem_dce_t *dce_wrap, esp_err_t(*got_line_fn)(uint8_t *data, size_t len))
457+
{
458+
if (dce_wrap == nullptr || dce_wrap->dce == nullptr) {
459+
return ESP_ERR_INVALID_ARG;
460+
}
461+
if (got_line_fn == nullptr) {
462+
dce_wrap->dce->set_urc(nullptr);
463+
return ESP_OK;
464+
}
465+
dce_wrap->dce->set_urc([got_line_fn](uint8_t *data, size_t len) {
466+
switch (got_line_fn(data, len)) {
467+
case ESP_OK:
468+
return command_result::OK;
469+
case ESP_FAIL:
470+
return command_result::FAIL;
471+
default:
472+
return command_result::TIMEOUT;
473+
}
474+
});
475+
return ESP_OK;
476+
}
477+
#endif

components/esp_modem/src/esp_modem_uart.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class UartTerminal : public Terminal {
7272
{
7373
auto t = static_cast<UartTerminal *>(task_param);
7474
t->task();
75+
t->task_handle.task_handle = nullptr;
7576
vTaskDelete(nullptr);
7677
}
7778

0 commit comments

Comments
 (0)