Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve server failure handling #338

Merged
merged 14 commits into from
Nov 29, 2023
Merged

Improve server failure handling #338

merged 14 commits into from
Nov 29, 2023

Commits on Nov 29, 2023

  1. CMake: add -Werror to C flags

    This would have caught the accidental changes to the git submodules in
    commit 3a0551e ("Dockerfile: bump ESP-ADF to support WIS auth"). As
    we've been aiming for no warnings, let's just turn all warnings into
    errors.
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    d830357 View commit details
    Browse the repository at this point in the history
  2. audio: rename hdl_ev_hs

    We will add another HTTP event callback for the ESP Audio HTTP stream,
    to avoid adding too much conditionals in the callback used by the audio
    pipeline to WIS. Let's rename the current callback function to make it
    more clear it is used by the HTTP stream to the API, similar to the
    function initializing the HTTP stream (init_ap_to_api).
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    143aad1 View commit details
    Browse the repository at this point in the history
  3. audio: enable HTTP Basic Auth in HTTP stream to WIS

    ESP-IDF's http_parser component will detect the username and password in
    the URL, and esp_http_client will set the Authorization header if the
    auth type is set to basic, and the parser found a username and password
    in the URL. If the parser didn't find a username and password,
    esp_http_client will just skip setting the header entirely, so having
    auth type hardcoded to basic is not a problem even if users configure a
    URL without username and password.
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    6451377 View commit details
    Browse the repository at this point in the history
  4. audio: add callback for ESP Audio's HTTP stream

    And enable HTTP Basic Auth unconditionally like we do in commit
    667e073feb8d ("audio: enable HTTP Basic Auth in HTTP stream to WIS").
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    a051818 View commit details
    Browse the repository at this point in the history
  5. audio: reduce HTTP Stream timeout to 2s

    Reduce default HTTP stream timeout from 30s to 2s. Letting a user wait
    longer for a failure on a voice command or TTS response is terrible UX.
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    fad15d3 View commit details
    Browse the repository at this point in the history
  6. audio: add callback for HTTP stream audio element

    With the existing callbacks for the HTTP streams we can only capture
    HTTP response codes. If a problem occurs on a lower layer, this doesn't
    trigger these callbacks. Add an extra callback for the HTTP stream audio
    element, and use an enum to distinguish which audio element sent the
    callback.
    
    When an error occurs, play the error tone from SPIFFS, write an error
    message on the display, and on the console.
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    ceeccb9 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    3b5e399 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    cf84fcc View commit details
    Browse the repository at this point in the history
  9. was: don't wait forever to close WS client

    Using portMAX_DELAY, esp_websocket_client_close might wait forever on
    STOPPED_BIT and we never reach the end of was_deinit_task. Instead, wait
    for 5 seconds.
    
    If esp_websocket_client_close receives STOPPED_BIT within the timeout,
    it returns ESP_OK. If it doesn't receive STOPPED_BIT within the timeout,
    it will do the same as esp_websocket_client_stop but also return ESP_OK.
    Therefore, call esp_websocket_client_stop after
    esp_websocket_client_close to make sure we actually stop the client.
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    7a9dfea View commit details
    Browse the repository at this point in the history
  10. was: explicitly set WS reconnect timeout

    We currently use the default (WEBSOCKET_RECONNECT_TIMEOUT_MS), which is
    not guaranteed to always be 10000.
    
    This is in preparation of reworking the reconnect logic when the client
    is not connected at the time of sending a message.
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    00398b6 View commit details
    Browse the repository at this point in the history
  11. was: drop esp_websocket_client_destroy() completely

    In commit 985375c ("was: drop esp_websocket_client_destroy()")
    we've dropped esp_websocket_client_destroy() in was_deinit_task(), as it
    appeared to cause crashes.
    
    We're still seeing crashes in the WebSocket client, so let's drop the
    use of esp_websocket_client_destroy() completely. Instead, if the WAS
    WebSocket client appears to be not connected, wait
    WAS_RECONNECT_TIMEOUT_MS for it to reconnect, and if after that it's
    still not connected, inform the user.
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    dd00781 View commit details
    Browse the repository at this point in the history
  12. audio: print other HTTP errors on screen

    We already explicitly handle HTTP 401 and 406 from WIS, but we don't
    print anything to the screen when we hit e.g. a 403 or 404. Handle these
    with a generic message printed to the screen, so the user has some
    indication about what is going on. Also trigger the configured audio
    response.
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    73b9bd5 View commit details
    Browse the repository at this point in the history
  13. audio: stop audio recorder on STT error

    On STT error, the pipeline would stop after printing "STT error", and
    the line would be overwritten with "Thinking".
    stintel committed Nov 29, 2023
    Configuration menu
    Copy the full SHA
    6f19495 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    d0bd3e3 View commit details
    Browse the repository at this point in the history