Skip to content

Commit

Permalink
Merge pull request #44 from david-cermak/fix/modem_dte_tx_chunks
Browse files Browse the repository at this point in the history
feat(cdc/modem): Add support to write big payloads in chunks (IEC-128)
  • Loading branch information
tore-espressif authored Jun 26, 2024
2 parents d938736 + 66248ec commit 4bf729f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
7 changes: 7 additions & 0 deletions host/class/cdc/esp_modem_usb_dte/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.2.1

- Added support to transmit larger payloads than the buffer_size of DTE

### Known issues
- ESP32-P4 cannot receive fragmented AT responses from a modem. Thus, some SimCom modems do not work with this version

## 1.2.0

- Fixed C++ build error for `usb_host_config_t` backward compatibility
Expand Down
16 changes: 12 additions & 4 deletions host/class/cdc/esp_modem_usb_dte/esp_modem_usb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void usb_host_task(void *arg)
namespace esp_modem {
class UsbTerminal : public Terminal, private CdcAcmDevice {
public:
explicit UsbTerminal(const esp_modem_dte_config *config, int term_idx)
explicit UsbTerminal(const esp_modem_dte_config *config, int term_idx): buffer_size(config->dte_buffer_size)
{
const struct esp_modem_usb_term_config *usb_config = (struct esp_modem_usb_term_config *)(config->extension_config);

Expand Down Expand Up @@ -117,8 +117,15 @@ class UsbTerminal : public Terminal, private CdcAcmDevice {
int write(uint8_t *data, size_t len) override
{
ESP_LOG_BUFFER_HEXDUMP(TAG, data, len, ESP_LOG_DEBUG);
if (this->CdcAcmDevice::tx_blocking(data, len) != ESP_OK) {
return -1;
uint8_t *ptr = data;
size_t remain = len;
while (remain > 0) {
int batch = std::min(buffer_size, remain);
if (this->CdcAcmDevice::tx_blocking(ptr, batch) != ESP_OK) {
return -1;
}
remain -= batch;
ptr += batch;
}
return len;
}
Expand Down Expand Up @@ -176,7 +183,8 @@ class UsbTerminal : public Terminal, private CdcAcmDevice {
default:
abort();
}
};
}
size_t buffer_size;
};
TaskHandle_t UsbTerminal::usb_host_lib_task = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion host/class/cdc/esp_modem_usb_dte/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## IDF Component Manager Manifest File
version: "1.2.0"
version: "1.2.1"
description: USB DTE plugin for esp_modem component
url: https://github.com/espressif/esp-usb/tree/master/host/class/cdc/esp_modem_usb_dte

Expand Down

0 comments on commit 4bf729f

Please sign in to comment.