Comments (9)
Ad1) need to add a urc handler, a planned feature for modem_v1.2
. This library also supports it, but it involves using some advanced c++ API: you can check this example:
Ad2) You can also create a custom command or handler in this library. For example:
std::string output;
auto ret = dce->command("at+cpbf=\"user\"\r", [&output](uint8_t *data, size_t len) {
std::string_view response((char *) data, len);
if (response.find("OK") != std::string::npos) {
output = response;
return command_result::OK;
}
return command_result::TIMEOUT;
}, 1000);
Maybe the default esp_modem_at()
command should return everything, not just the last line (but I believe this per line tokenization is useful in most cases, as it filters out potential echo's and garbage).
from esp-protocols.
Thanks for your suggestions!
My app is written in C, I can't convert it to C++
How can I set_on_read()
from C? dce->set_on_read()
obviously does not compile.
Yes I also was thinking that esp_modem_at()
would return everything, but your concerns are valid too.
For multiline reponses esp_modem_at()
either needs the additional parameter accept_multi_line
or a separate function esp_modem_at_multiline()
so esp_modem_at()
can be left unchanged.
from esp-protocols.
I'm sorry, I don't really have a good suggestion for C right now (other than create a custom DCE as in the console example and wrap it in C-API)
dce->set_on_read() obviously does not compile.
It does compile in that example, but as said above -- uses some C++ magic to conveniently override set_on_read()
in
For multiline reponses esp_modem_at() either needs the additional parameter accept_multi_line separate function esp_modem_at_multiline() so esp_modem_at() can be left unchanged.
Yes, I'd probably add a new function, as you proposed, which could be used more universally. I would also remove the trailing \r
here, so the new function could be used to send any kind of characters, e.g. the +++
:
esp-protocols/components/esp_modem/src/esp_modem_command_library.cpp
Lines 393 to 394 in 7d0eb5c
from esp-protocols.
I managed to add a esp_modem_set_read_cb() in C and that works.
When will v1.2 available?
Another problem:
How can I reconnect to PPP ? I'm using SIM800.
After an established connection I call esp_modem_set_mode(dce, ESP_MODEM_MODE_COMMAND)
and later on (it can be hours later)
esp_modem_set_mode(dce, ESP_MODEM_MODE_DATA);
But that results just in a "User interrupted event" and it doesn't get connected.
The SIM800 sends:
CONNECT
~ÿ}#À!}!}!} }2}"}&} }*} } }#}$À#}'}"}(}"Uƒ~~ÿ}#À!}#}$} }*}"}&} }*} } t"~~ÿ}#À!}!}"} }.}"}&} }*} } }'}"}(}"ÐÓ~~ÿ}#À!}"}%} }4}"}&} }*} } }%}&áÏFˆ}'}"}(}"}=}(~~€!����À¨þþHÌ~~€!����-��àB~~ÿ�À!���…r~
NO CARRIER
A similar question right at the first connection-try after reset:
If it can't get a PPP connection because the provider has no capacity, I get IP_EVENT_PPP_LOST_IP
How can I start a retry? Setting ESP_MODEM_MODE_DATA
doesn't work.
Do I have to destroy and re-create the DCE each time? That sounds a bit awkward.
from esp-protocols.
Now I got it running. The reason was the missing APN
from esp-protocols.
Thanks for the update!
When will v1.2 available?
I'm currently getting ready for v1.1
, should be available next week or so,.
Version v1.2
would add a few features, so I think it should be ready sometime in Feb/March. As for the URC handler, its not a big change and I think I could get it working after the 1.1 release.
from esp-protocols.
Closing, as I think all questions have been answered. Please reopen or create new issues if it's not the case.
from esp-protocols.
Sorry @JB-DX, I have your same issue regarding the URC handler and set_read_cb stuff and I can't convert my app to c++, too. Could you please share your esp_modem_set_read_cb
function implementation? Because I'm not able to make mine work
from esp-protocols.
I assumed that the URC handler would have been implemented by now, but I can't find it.
in esp_modem_c_api.cpp I added this:
extern "C" esp_err_t esp_modem_set_read_cb(esp_modem_dce_t *dce_wrap, esp_modem_terminal_read_cbt read_cb)
{
if (dce_wrap == nullptr || dce_wrap->dce == nullptr || dce_wrap->dte == nullptr) {
return ESP_ERR_INVALID_ARG;
}
if (read_cb) {
dce_wrap->dte->on_read([read_cb](uint8_t *line, size_t leng) {
read_cb(line, leng);
return command_result::TIMEOUT;
});
} else {
dce_wrap->dte->on_read(nullptr);
}
return ESP_OK;
}
and in esp_modem_c_api_types.h add this:
esp_err_t esp_modem_set_read_cb(esp_modem_dce_t *dce_wrap, esp_modem_terminal_read_cbt read_cb);
from esp-protocols.
Related Issues (20)
- mDNS results in esp_netif_lwip log spam (IDFGH-12320) HOT 1
- Freezing of the ESP, triggering the WDT! (ESP-MODEM) (IDFGH-12332) HOT 3
- Response Issue in CMUX Mode (IDFGH-12431) HOT 15
- little help in getting esp_modem and LiliGo-TSIM7080-S3 to work (IDFGH-12454) HOT 3
- esp-modem next step : ppp auth ? (IDFGH-12496) HOT 5
- esp-modem: AT command response truncated sometimes when in CMUX mode (IDFGH-12526) HOT 3
- mdns: ethernet link flap doesn't restart mdns if DHCP in use. (IDFGH-12563) HOT 2
- esp-netif_lwip-ppp: Connection lost, Modem Disconnect from PPP Server (IDFGH-12618) HOT 5
- Choosing The Right Mode For SIMCOM or Any Modem... (AT or DialUP) (IDFGH-12638) HOT 10
- problems with modem_tcp_client and Telit LE910Cx modem (IDFGH-12643) HOT 1
- esp_mqtt_cxx not set last will (IDFGH-12648)
- Kconfig in modem_example limits the UART pins till 31 - should be higher to support s3 (IDFGH-12700) HOT 1
- LwIP PPP connection close and no authentication (IDFGH-12720) HOT 3
- esp_modem freezes when flow control is enabled and module is unresponsive (IDFGH-12739) HOT 1
- C++ example please (IDFGH-12752) HOT 2
- EPPP Reverse link to provide Access Point (IDFGH-12759) HOT 12
- esp_wifi_remote: key-pair generated by generate_test_certs.py not work in example (IDFGH-12801) HOT 10
- Fix code scanning alert - expected '(' for function-style cast or type construction [clang-diagnostic-error] (IDFGH-12824)
- modem pppos_client idf4.4.7 Not compatible with smart_config process (IDFGH-12876) HOT 2
- Websocket - Allow to choose which memory takes (internal, external) for buffer (IDFGH-12913) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp-protocols.