Skip to content
dstroy0Public

About

Fully deterministic protocol core, self-contained highly-optimized ecosystem.

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

2,083 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

ProtoCore

ProtoCore (@dstroy0)

Version License Documentation Features

ESP32 Build Arduino Build Test & Analyze Interoperability Harness CodeQL Quality Gate Pentest Format Code

Markdown Formatting CSpell Documentation Feature Tables Web Assets Change Log Release Arduino Library

A network server for a microcontroller, with many protocols, a fully deterministic memory footprint, RFC 7230 compliant request parsing, and an architecture in the layers of the OSI model. It serves HTTP/1.1/2/and 3 over QUIC, HTTPS/TLS/DTLS, SSH (full OpenSSH interoperability), Telnet, SNMP, and post quantum crypto.

Supported today: ESP32, each of its 13 variant profiles. The core is neutral C, with no code for one vendor. Arm and TI C2000 are in progress, and docs/ROADMAP.md records the work.

Active development

Warning

  1. Expect breaking changes.
  2. We fix things the right way and put security and correctness first.
  3. We do not write a shim for backwards compatibility.
  4. We only support the latest version of the library, of each toolchain and of each platform.
  5. Each release has a version tag.

Warning

  • Pin an exact version if you need stability until we lock the core. The code is the source of truth.
  • Read CHANGELOG.md before every upgrade.

Audit status

Warning

NO 3RD PARTY AUDITED THIS LIBRARY

No third party reviewed this library. We did not lock the core yet. A locked core makes contribution and collaboration practical, and outside ideas had no time to flow in. We measure the current verification state, and we do not claim it.

Warning

YOU ARE THE 3RD PARTY

Your contributions are valuable. Please report your findings. If no one recorded your bug before and it is genuine, we give you clear credit in src/, in docs/BUGS.md and in each other system it touches. That can be the architecture, the API or a subsystem. You choose the form of the credit: your name, a handle, an email address or no name.

docs/AUDIT.md docs/STANDARDS.md

Host test suite 6,625 tests pass across 386 native environments
Measured coverage 82.4% line, 73.8% branch over 383 instrumented files
External audit none - no third party has reviewed this library

CI measures the coverage over all of src/, and it excludes nothing. The numbers come from test/coverage.xml and test/TEST_REPORT.md, and CI writes both files.

Overview

tools/ci_tooling/generate/gen_api_flow.py writes this block from the public API, protocore_builtins.c and presentation/. Do not change it by hand. The picture is an SVG with native text labels, and thus it stays sharp at each scale and you can select the text. Its Mermaid source is docs/diagrams/api_flow.mmd.

How to read it: follow the arrows. A request comes in at the top from a client. It travels down through the four OSI layers: L4 wire bytes, L5 protocol pick, L6 decode into a request and L7 your routes. Your handler runs, and the response goes back out along the green arrows. Each box shows a step in plain English, with the exact function under it. You only write the two amber parts: register your routes (top) and your handler (middle).

The one idea to keep: the library turns each HTTP version (1.1, 2, 3) into the same request, and answers it through one response path. So your routes and your handler never see which protocol a client used.

Color Layer
Amber outline L4 Transport - raw bytes on/off the wire
Green L5 Session - the two seams that pick the protocol in and frame the reply out
Blue L6 Presentation - decrypt + turn bytes into a request
Indigo L7 Application - route matching + your handlers
Solid amber fill the parts you write
Request lifecycle: a request travels down the OSI layers to your handler; the response returns

Quick start

This is a verbatim copy of examples/Foundation/Basic/Basic.ino, and CI builds that sketch. If the API changes, that sketch fails to build and this block changes with it.

#include "protocore.h"
#include "network_drivers/physical/physical/physical.h"

static const char *SSID = "YOUR_SSID";
static const char *PASSWORD = "YOUR_PASSWORD";


// Every handler takes the connection's slot_id and the parsed request, and
// replies through send_text(). Pass slot_id back so the reply reaches the
// connection that asked.
void handle_root(uint8_t slot_id, HttpReq *req)
{
    send_text(slot_id, 200, "text/plain", "Welcome to ProtoCore!");
}

void setup()
{
    Serial.begin(115200);

    PhysicalV.wifi.ssid = SSID;
    PhysicalV.wifi.password = PASSWORD;
    Physical.wifi_init(protocore_physical_span());
    while (!protocore_physical_wifi_up())
    {
        delay(250);
    }

    uint32_t ip = protocore_physical_egress_ipv4(); // library egress IP (network byte order), no Arduino WiFi
    Serial.printf("IP: %u.%u.%u.%u\n", (unsigned)(ip & 0xFF), (unsigned)((ip >> 8) & 0xFF),
                  (unsigned)((ip >> 16) & 0xFF), (unsigned)((ip >> 24) & 0xFF));

    on_http("/", HTTP_GET, handle_root);

    // begin() returns 1 on success and a negative value on failure (listener
    // pool full or lwIP error). -1 is truthy. Thus test for "< 0", not "!result".
    int32_t result = begin_http(80, NULL);
    if (result < 0)
    {
        Serial.printf("begin() failed (error %d)\n", result);
        return;
    }
    Serial.println("Server started on port 80");
}

void loop()
{
    // Drives the full pipeline each iteration:
    //   1. Timeout sweep (force-closes idle connections)
    //   2. Event queue drain (TCP connect/data/disconnect events)
    //   3. HttpRoute dispatch for completed requests
    //   4. Auto-sends 400 / 413 / 414 / 501 for parser error states
    // No request is processed off this call. Thus loop() must never block.
    handle();
}

Set SSID / PASSWORD, flash, and open Serial at 115200 for the IP. Full walkthrough: examples/Foundation/Basic.

πŸ“š Documentation

Read the Full Documentation Here πŸ“–

Interactive build configuration tool βš™οΈ: pick the features you need, set their values, and copy out a platformio.ini build_flags block (or the #defines). The tool resolves each dependency, and it writes only the values that differ from a default. It reads src/protocore_config.h. So it always agrees with the library.

The technical reference documentation is on a web page of its own. The local Markdown copy is at docs/README.md. The feature reference gives each option. The secure boot and flash encryption guide gives the hardening steps for a production deployment. To connect a codec to a PLC, an inverter, a power grid sensor or another board, read the hardware connection and settings guide. It gives the transceiver, the port and the settings for each one.

Features

Each feature is optional. A build carries only the HTTP/1.1 core until you name a flag. So the footprint is what you asked for, not what the library ships with. The map below is live: click a layer to browse that group.

261 features, each one a PROTOCORE_ENABLE_* flag of the build that is off until you ask for it. Core HTTP/1.1 parsing, routing, middleware, JSON, templates and chunked responses are always on, and they are not flags.

Feature map: the OSI stack and the feature groups on each layer
Layer Features For example
Foundation 17 Config IO, Config Store, Device ID, DMA Peripheral Ingest, …
Physical & Data Link (L1-L2) 31 ADS1115, BLE GATT, Bus Capture, CC1101, …
Network (L3) 7 Dns Resolver, DNS Wire Codec, Happy Eyeballs, IPv6, …
Transport (L4) 8 Accept Throttle, IP Allowlist, Keep-Alive, Per IP Throttle, …
Session (L5) 5 SSH, SSH Compression, SSH SCP, SSH SFTP, …
Presentation (L6) 21 Auth, Auth Lockout, CBOR, CloudEvents, …
Application (L7) 172 AD9238, Adaptive mDNS, ADS (Beckhoff), AMQP, …

Browse all of them β†’: a filter, a group for each layer and one line for each feature. The full descriptions are in FEATURES.md. Both pages come from it, and thus they cannot drift.

Build-flag dependencies

Most features are independent. A few build on another feature and do not compile without it. The build stops on each hard dependency with a clear #error. Thus an illegal combination fails fast, and does not give a linker error that says less. Enable a child flag only together with its parent.

tools/ci_tooling/generate/gen_flag_deps.py writes this block from the PROTOCORE_ENABLE_<A>_NEEDS_<B> symbols in src/protocore_config.h. Do not change it by hand. The picture is an SVG. Each node is a link to the entry of its feature, and a hover text on it names what it needs. Graphviz source: docs/diagrams/flag_deps.dot.

Each green node is a parent feature, and each blue node is a child that needs it. Without the parent, a hard #error stops the build. A green TLS mark on a node means that the feature also needs PROTOCORE_ENABLE_TLS. The mark takes the place of an edge, and thus no lines cross. Hover on a flag for what it needs, and click it to read the feature. The list below gives the derived flags and the PSRAM-class features, which have no edge, and thus the graph stays a clean family forest.

Build-flag dependencies

Not drawn (so the forest stays uncrossed): PROTOCORE_ENABLE_RANGE also need PROTOCORE_ENABLE_FILE_SERVING; PROTOCORE_ENABLE_PROVISIONING also need PROTOCORE_ENABLE_UDP.

Auto-derived flags - enabling the left flag turns the right one on for you; do not set it yourself.
Enabling this... ...auto-enables
PROTOCORE_ENABLE_OTA PROTOCORE_ENABLE_STREAM_BODY
PROTOCORE_ENABLE_UPLOAD PROTOCORE_ENABLE_STREAM_BODY
PROTOCORE_ENABLE_WEBDAV PROTOCORE_ENABLE_STREAM_BODY
PSRAM-class features - the pool cannot fit internal DRAM; enable `*_IN_PSRAM` or acknowledge with an `*_ACK_DRAM` opt-out.
Feature Gate
PROTOCORE_ENABLE_SSH_ZLIB PSRAM pool
PROTOCORE_ENABLE_TLS MAX_TLS_CONNS gt 1

34 hard dependencies, 2 PSRAM gates, 3 derived flags.

Build Footprint

Most of the jump from a bare sketch to a running server comes from the WiFi/lwIP stack, and not from this library. An empty RTOS/Arduino sketch is already ~228 KB flash / ~21 KB RAM. The larger RAM of TLS is the fixed mbedTLS arena (PROTOCORE_TLS_ARENA_SIZE, 48 KB default). An outbound client links no code until a sketch calls it.

tools/ci_tooling/generate/feature_budget.py writes this block from isolated ESP32 builds. Do not change it by hand.

Measured on esp32dev (Arduino core). The default server (HTTP + WebSocket + SSE + multipart + static files + Basic auth) is 735 KB flash / 64.6 KB RAM on a chip with 1,280 KB flash / 320 KB RAM. Each feature past that is optional and links only what you name.

Build footprint of each feature β†’: 87 features that add measurable flash. Isolated builds measure each one as a range, from the best case to the worst case. In the best case, its dependencies are already in the link. In the worst case, the budget includes them. The absolute total of each example is there too.

The examples for each feature are under examples/.

Compatibility

  • Supported today: ESP32, 13 variant profiles (classic, S2, S3, S31, C2, C3, C5, C6, C61, H2, H21, H4, P4). Each profile has its own flash and PSRAM default values in vendor/board_profiles/esp/.
  • Superscalar hosts: the same core builds and runs on a host machine, and the host test suite runs it there. embedded_types gives the scheduler the arm of a host. On Linux, test/core_setup/hal/host/tap_link.c is the network driver: each frame of one TAP device goes to the stack, and each frame of the stack goes to the device. The program host_tap_echo serves Echo (RFC 862) on it.
  • Frameworks: Arduino Core (2.x and 3.x), PlatformIO, ESP-IDF (as an Arduino component of ESP-IDF)
  • In progress: Arm and TI C2000. The core is neutral C, and the HAL selects on variant capability, and not on a chip check. What remains is the silicon support of each vendor, and docs/ROADMAP.md records it. TI C2000 is the hard case: CHAR_BIT == 16. So there is no 8-bit addressable memory and a byte pointer is not a byte pointer.

Licensing & Commercial Use

This library is dual-licensed.

Open Source. This library is, and will ALWAYS REMAIN, FULLY OPEN-SOURCE under the AGPLv3 (or later). We commit to maintaining a fully featured, parity-matched open-source version available to everyone - from hobbyists and educators to professionals - without hiding any non-proprietary (e.g. custom protocols, intellectual property, confidential telemetry configurations, etc.) feature behind a commercial paywall. It will always be free to use under the AGPLv3 (or later) in any environment that complies with the AGPLv3 (or later) terms. See the LICENSE file.

Commercial. For teams and applications that cannot meet the AGPLv3 copyleft requirements, a commercial license is available. Contact: Douglas Quigg (dstroy0), dquigg123@gmail.com

Educators. Teaching with this? We'd love that. SERIOUSLY. Squirty is meant to keep children engaged on the docs page. The docs and styling are set up to appeal to them, hobbyists, and anyone who wants to learn but doesn't know how to style things or glue services together. The library documentation is extensive, very complete, and useful to professionals as well as educators as a teaching tool/classroom prop. If sharing your source under the AGPLv3 isn't practical for a classroom or lab, or you have concerns that have stopped you from using copyleft licensed software before, email Douglas Quigg (dstroy0) at dquigg123@gmail.com from your school address and we'll see what we can do. ESP32 boards are cheap and a hands-on HTTP / IoT-edge stack is a great way into embedded networking. So we're glad to look at education-focused requests one by one. We can't promise an exception for every situation, but please ask. (This is just for genuine educational use; for products, see the commercial option above.) I can help you set up a github repo your students can push to that will help you review their submissions, and walk you through setting up flags for your rubric items. We really need to make an effort to get as many people as possible into the profession, looking at how things work, figuring out how they work on a deeper level, and entering the profession, we need their ideas, we need them now. All great discoveries have come from fresh perspective.


Squirty the Injection Squid
Squirty the Injection Squid official library mascot.
Copyright Β© Douglas Quigg (dstroy0). All rights reserved.

About

Fully deterministic protocol core, self-contained highly-optimized ecosystem.

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages