Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions esp/speaker-netsender/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ Desktop.ini
*.vscode

*.zed/
*.cache
24 changes: 23 additions & 1 deletion esp/speaker-netsender/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,29 @@ Alternatively this can also be run manually via the command line:
clang-tidy --fix <filepath>
```

**Keeping includes that clang-tidy wants to remove:**
## Running the Pipi host tests

The `pipi` logging component has host tests that build and run natively on your Linux machine, so no ESP32 hardware is required. They live in `components/pipi/host_tests/test_pipi` and are a gtest-based ESP-IDF project that targets the `linux` host.

In addition to the ESP-IDF setup described above, your ESP-IDF installation must ship the clang Linux toolchain (`tools/cmake/toolchain-clang-linux.cmake`), as the tests are built with the clang toolchain. The `clang`, `clang++` and `lld` binaries also need to be installed on your system.

To build and run the tests:

```sh
cd components/pipi/host_tests/test_pipi
idf.py build
./build/test_pipi.elf
```

The test target is already pinned to `linux` in the committed `sdkconfig`, so no `set-target` step is required. The project's `CMakeLists.txt` enables the local `gtest` component (defining `RUNNING_UNIT_TESTS`) automatically. Run the tests from the `test_pipi` directory, as the suite creates and `chdir`s into a `test/` subdirectory to isolate its log files. Individual tests can be selected with gtest flags, e.g.:

```sh
./build/test_pipi.elf --gtest_filter=TestEntry.*
```

Note that some ESP-IDF point releases do not include `toolchain-clang-linux.cmake` (e.g. v6.0.2), which will cause the build to fail with a "toolchain file not found" error. If that happens, use an ESP-IDF version that provides it.

## Keeping includes that clang-tidy wants to remove:

clang-tidy sometimes suggests removing ESP-IDF driver headers that are actually needed
as direct includes, because it can see them transitively through other headers.
Expand Down
26 changes: 26 additions & 0 deletions esp/speaker-netsender/components/netsender/include/netsender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@

#pragma once

#include <cstdint>
#include <functional>
#include <mutex>
#include <optional>
#include <stddef.h>
#include <stdint.h>
#include <string>
#include <vector>

#include "esp_err.h"
#include "esp_http_client.h"

#include "sdkconfig.h"

Expand Down Expand Up @@ -116,7 +120,9 @@ struct netsender_configuration_t {
struct netsender_pin_t {
char name[NETSENDER_PIN_SIZE];
std::function<std::optional<int64_t>()> read;
std::function<std::optional<std::vector<uint8_t>>()> read_binary;
std::optional<int64_t> value;
std::vector<uint8_t> data_storage;
uint8_t *data;
};

Expand All @@ -143,6 +149,11 @@ class Netsender {
*/
esp_err_t register_input(char *pin_name, std::function<std::optional<int64_t>()> read_func);

/**
* @brief append a binary read function to an associated pin.
*/
esp_err_t register_binary_input(char *pin_name, std::function<std::optional<std::vector<uint8_t>>()> read_func);

/**
* @brief register a callback to handle variable parsing.
*
Expand Down Expand Up @@ -177,6 +188,21 @@ class Netsender {
*/
bool configured;

/**
* Persistent handle for http requests.
*/
esp_http_client_handle_t http_handle;

/**
* Mutex for persistent http_handle.
*/
std::timed_mutex http_handle_mu;

/**
* @brief init function for http_handle.
*/
esp_err_t init_http_handle();

/**
* Latest varsum value.
*/
Expand Down
Loading
Loading