Skip to content
sstreamzet/docs
xSpan SDK 0.2.1Open console
Developer docs / xSpan SDK
API and integration guide · Updated 2026-09-23

C/C++ integration

Connect remote support to your product lifecycle. Use the POSIX process adapter for existing glibc applications.

Integration architecture

text
OEM application (your ETK / libc)
  └─ streamzet_product.c  [start / poll / stop]
       └─ streamzet-embedded  [static ARMv5 engine]
            └─ outbound TLS :443 → StreamZet
                 └─ enrollment · terminal · Fleet · dashboard

Compile the small C adapter into the OEM application and ship the qualified static engine alongside it. TLS and the C runtime remain in a separate process. The engine handles transport, enrollment and network reconnect; the host starts, monitors and stops the child.

Required files

FilePurpose
sdk/product/streamzet_product.hPublic C/C++ interface
sdk/product/streamzet_product.cPOSIX adapter compiled with the OEM ETK
sdk/product/example.cStart, monitor, stop and reap example
device/streamzet-embeddedQualified static ARMv5 engine
device/cacert.pemCA bundle for server authentication
registration.key + state/Provisioned and preserved per device

Compile with your product toolchain

sh
# Set CC to the matching OEM ETK C compiler.
"$CC" -std=c99 -D_POSIX_C_SOURCE=200809L \
  -Isdk/product sdk/product/example.c sdk/product/streamzet_product.c \
  -o streamzet-product-example

For C++, compile streamzet_product.c as C, link that object, and include the header. Copy the resulting example to the provisioned reader and run it below. Stop an existing start.sh-managed engine and wait for its full exit before reusing its state.

sh
./streamzet-product-example \
  /mnt/spp/streamzet-jci/streamzet-embedded \
  /mnt/spp/streamzet-jci/registration.key \
  /mnt/spp/streamzet-jci/cacert.pem \
  /mnt/spp/streamzet-jci/state \
  'xSpan R660 001'

Host lifecycle example

c
#include "streamzet_product.h"

static stz_product support = {0};

int start_remote_support(void) {
    const stz_product_config config = {
        .engine_path = "/mnt/spp/streamzet-jci/streamzet-embedded",
        .registration_file = "/mnt/spp/streamzet-jci/registration.key",
        .ca_file = "/mnt/spp/streamzet-jci/cacert.pem",
        .state_directory = "/mnt/spp/streamzet-jci/state",
        .device_name = "xSpan R660 001"
    };
    return stz_product_start(&support, &config);
}

/* Call periodically from the same host thread. */
int poll_remote_support(int *wait_status) {
    return stz_product_poll(&support, wait_status);
}

/* Request stop, then keep polling until the child is reaped. */
int stop_remote_support(void) {
    return stz_product_stop(&support);
}
  • A zero start return value confirms spawn success. Confirm online status in StreamZet.
  • Serialize calls on a handle. Do not let another SIGCHLD handler reap this child.
  • Mark unrelated host file descriptors close-on-exec. The adapter child inherits stdout/stderr.
  • Network reconnect is automatic. Detect process exits through poll and apply the OEM restart policy.
  • Do not run start.sh alongside SDK mode. After a stop request, reap via poll before reusing the handle.

Low-level static library

sdk/musl contains libstreamzet-embedded.a, TLS archives and headers. A new musl ARMv5 application uses stz_create → stz_run on a worker thread → stz_stop → join → stz_destroy, with the documented entropy, persistent identity and single TLS-runtime contracts.