Skip to content

Commit

Permalink
fix(modem): Fix DUAL_MODE regression from cb6e03a
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cermak authored and espressif-abhikroy committed Oct 19, 2023
2 parents f591b7f + 2aada0f commit cc293a2
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 248 deletions.
109 changes: 55 additions & 54 deletions .github/workflows/publish-docs-component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Publish Tag, Release, Docs, Component
runs-on: ubuntu-latest
# Skip running on forks since it won't have access to secrets
if: github.repository == 'espressif/esp-protocols'
#if: github.repository == 'espressif/esp-protocols'
steps:
- name: Checkout esp-protocols
uses: actions/checkout@v3
Expand All @@ -43,56 +43,57 @@ jobs:
tag_name: ${{ env.BUMP_TAG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate docs
shell: bash
run: |
sudo apt-get update
sudo apt-get -y install doxygen clang python3-pip
python -m pip install breathe recommonmark esp-docs==1.4.1
for comp in `ls components`; do
if [[ -d $GITHUB_WORKSPACE/docs/${comp} ]]; then
cd $GITHUB_WORKSPACE/docs/${comp}
if [[ "${{ env.BUMP_COMPONENT }}" == "${comp}" ]]; then
echo "Building specific version of ${comp} (${{ env.BUMP_VERSION }})"
./generate_docs ${{ env.BUMP_VERSION }}
else
echo "Building latest version of ${comp}"
./generate_docs
fi
fi
done
- name: Deploying generated docs
shell: bash
run: |
source $GITHUB_WORKSPACE/docs/utils.sh
add_doc_server_ssh_keys $DOCS_DEPLOY_KEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER
export GIT_VER=$(git describe --always)
export GITHUB_REF_NAME=latest
for comp in `ls components`; do
if [[ -d $GITHUB_WORKSPACE/docs/${comp} ]]; then
echo "Deploying latest of ${comp}"
export DOCS_BUILD_DIR=$GITHUB_WORKSPACE/docs/${comp}
export DOCS_DEPLOY_PATH=$DOCS_DEPLOY_PATH_ORIG/${comp}
cd $GITHUB_WORKSPACE/docs/${comp}
deploy-docs
fi
done;
# Deploy docs with version path
if [[ "${{ env.BUMP_VERSION }}" != "" ]] && [[ -d $GITHUB_WORKSPACE/docs/${{ env.BUMP_COMPONENT }} ]]; then
echo "Deploying specific version of ${{ env.BUMP_COMPONENT }} (${{ env.BUMP_VERSION }})"
cd $GITHUB_WORKSPACE/docs/${{ env.BUMP_COMPONENT }}
export GITHUB_REF_NAME=${{ env.BUMP_VERSION }}
deploy-docs
fi
- name: Upload components to component service
uses: espressif/upload-components-ci-action@v1
with:
directories: >
components/asio;
components/esp_modem;
components/esp_mqtt_cxx;
components/esp_websocket_client;
components/mdns;
components/console_simple_init;
namespace: "espressif"
api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}
# - name: Generate docs
# shell: bash
# run: |
# sudo apt-get update
# sudo apt-get -y install doxygen clang python3-pip
# python -m pip install breathe recommonmark esp-docs==1.4.1
# for comp in `ls components`; do
# if [[ -d $GITHUB_WORKSPACE/docs/${comp} ]]; then
# cd $GITHUB_WORKSPACE/docs/${comp}
# if [[ "${{ env.BUMP_COMPONENT }}" == "${comp}" ]]; then
# echo "Building specific version of ${comp} (${{ env.BUMP_VERSION }})"
# ./generate_docs ${{ env.BUMP_VERSION }}
# else
# echo "Building latest version of ${comp}"
# ./generate_docs
# fi
# fi
# done
# - name: Deploying generated docs
# shell: bash
# run: |
# source $GITHUB_WORKSPACE/docs/utils.sh
# add_doc_server_ssh_keys $DOCS_DEPLOY_KEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER
# export GIT_VER=$(git describe --always)
# export GITHUB_REF_NAME=latest
# for comp in `ls components`; do
# if [[ -d $GITHUB_WORKSPACE/docs/${comp} ]]; then
# echo "Deploying latest of ${comp}"
# export DOCS_BUILD_DIR=$GITHUB_WORKSPACE/docs/${comp}
# export DOCS_DEPLOY_PATH=$DOCS_DEPLOY_PATH_ORIG/${comp}
# cd $GITHUB_WORKSPACE/docs/${comp}
# deploy-docs
# fi
# done;
# # Deploy docs with version path
# if [[ "${{ env.BUMP_VERSION }}" != "" ]] && [[ -d $GITHUB_WORKSPACE/docs/${{ env.BUMP_COMPONENT }} ]]; then
# echo "Deploying specific version of ${{ env.BUMP_COMPONENT }} (${{ env.BUMP_VERSION }})"
# cd $GITHUB_WORKSPACE/docs/${{ env.BUMP_COMPONENT }}
# export GITHUB_REF_NAME=${{ env.BUMP_VERSION }}
# deploy-docs
# fi
# - name: Upload components to component service
# uses: espressif/upload-components-ci-action@v1
# with:
# directories: >
# components/asio;
# components/esp_modem;
# components/esp_mqtt_cxx;
# components/esp_websocket_client;
# components/mdns;
# components/console_simple_init;
# components/console_cmd_ifconfig;
# namespace: "espressif"
# api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ Please refer to instructions in [ESP-IDF](https://github.com/espressif/esp-idf)
### console_simple_init

* Brief introduction [README](components/console_simple_init/README.md)

### console_cmd_ifconfig

* Brief introduction [README](components/console_cmd_ifconfig/README.md)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
idf:
version: '*'
version: ">=5.0"
console_simple_init:
version: "*"
override_path: '../../../'
96 changes: 0 additions & 96 deletions components/esp_modem/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions components/esp_modem/src/esp_modem_dte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ DTE::DTE(std::unique_ptr<Terminal> terminal):
DTE::DTE(const esp_modem_dte_config *config, std::unique_ptr<Terminal> t, std::unique_ptr<Terminal> s):
buffer(config->dte_buffer_size),
cmux_term(nullptr), primary_term(std::move(t)), secondary_term(std::move(s)),
mode(modem_mode::UNDEF)
mode(modem_mode::DUAL_MODE)
{
set_command_callbacks();
}

DTE::DTE(std::unique_ptr<Terminal> t, std::unique_ptr<Terminal> s):
buffer(dte_default_buffer_size),
cmux_term(nullptr), primary_term(std::move(t)), secondary_term(std::move(s)),
mode(modem_mode::UNDEF)
mode(modem_mode::DUAL_MODE)
{
set_command_callbacks();
}
Expand Down
93 changes: 0 additions & 93 deletions components/esp_websocket_client/.gitignore

This file was deleted.

45 changes: 45 additions & 0 deletions components/esp_websocket_client/esp_websocket_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,51 @@ esp_err_t esp_websocket_client_set_headers(esp_websocket_client_handle_t client,
return ret;
}

esp_err_t esp_websocket_client_append_header(esp_websocket_client_handle_t client, const char *key, const char *value)
{
// Validate the input parameters
if (client == NULL || key == NULL || value == NULL) {
return ESP_ERR_INVALID_ARG;
}

websocket_config_storage_t *cfg = client->config;

// Calculate the length for "key: value\r\n"
size_t len = strlen(key) + strlen(value) + 5; // 5 accounts for ": \r\n" and null-terminator

// If no previous headers exist
if (cfg->headers == NULL) {
cfg->headers = (char *)malloc(len);
if (cfg->headers == NULL) {
ESP_LOGE(TAG, "Failed to allocate...");
return ESP_ERR_NO_MEM;
}
snprintf(cfg->headers, len, "%s: %s\r\n", key, value);
return ESP_OK;
}

// Extend the current headers to accommodate the new key-value pair
size_t current_len = strlen(cfg->headers);
size_t new_len = current_len + len;

// Allocate memory for new headers
char *new_headers = (char *)malloc(new_len);
if (new_headers == NULL) {
ESP_LOGE(TAG, "Failed to allocate...");
return ESP_ERR_NO_MEM;
}

// Copy old headers and append the new header
strcpy(new_headers, cfg->headers);
snprintf(new_headers + current_len, len, "%s: %s\r\n", key, value);

// Free old headers and assign the new header pointer to cfg->headers
free(cfg->headers);
cfg->headers = new_headers;

return ESP_OK;
}

static esp_err_t esp_websocket_client_recv(esp_websocket_client_handle_t client)
{
int rlen;
Expand Down
Loading

0 comments on commit cc293a2

Please sign in to comment.