Add C implementations of device-connect-edge and -agent-tools#53
Open
atsyplikhin wants to merge 1 commit into
Open
Add C implementations of device-connect-edge and -agent-tools#53atsyplikhin wants to merge 1 commit into
atsyplikhin wants to merge 1 commit into
Conversation
Two new packages porting the device side and the external-agent side of
Device Connect to C, mirroring the Python packages and built in the same
spirit as the MHP C SDK wire node (reusing its proven JSON / JSON-RPC /
NATS-transport / security modules).
packages/device-connect-edge-c/ (libdc_edge.a):
- driver: register @rpc-style functions by name, advertise events, set
identity/status. DC RPC semantics -- method is the function name, params
are the args, the reply carries the raw return value.
- runtime: connect over NATS (cnats), serve device-connect.{tenant}.{id}.cmd,
registerDevice to the registry, heartbeat every device_ttl/3 to hold the
lease (device shows online), answer requestRegistration, re-register on
reconnect, plus invoke_remote (D2D) and emit (events). Consumes the portal's
native *.creds.json directly (auto-converts for cnats; auto-detects
device_id/tenant) or an nsc-chained *.creds.
- example: temp_sensor.c (get_reading/set_target + reading_changed).
packages/device-connect-agent-tools-c/ (libdc_agent_tools.a):
- the four meta-tools over the portal HTTP API (libcurl): describe_fleet,
list_devices, get_device_functions, invoke_device; results parsed to JSON.
- example: dc_agent CLI (fleet/list/functions/invoke).
Each package has a Makefile, unit tests (edge 4, agent-tools 3), and a README.
A c-sdk CI workflow builds + tests both on Linux and macOS (cnats from source
on Linux / brew on macOS; libcurl).
Verified end-to-end against a live DC portal (tenant alpha): 3 C edge devices
provisioned, registered, online (sustained by heartbeat), then discovered and
invoked by the C agent-tools (get_reading/set_target across all three), with
-32601/-32602 error semantics propagating through the portal envelope.
Apache-2.0, per-file SPDX headers (matches the repo).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two new packages porting Device Connect to C — the device side and the external-agent side — mirroring the Python
device-connect-edge/device-connect-agent-tools. Built in the same spirit as the MHP C SDK wire node, reusing its proven JSON / JSON-RPC / NATS-transport / security modules.packages/device-connect-edge-c/(libdc_edge.a)dc/driver.h): register@rpc-style functions by name, advertise events, set identity/status. DC RPC semantics —methodis the function name,paramsare the args, the reply carries the raw return value asresult.dc/runtime.h): connect over NATS (cnats), servedevice-connect.{tenant}.{id}.cmd,registerDeviceto the registry, heartbeat everydevice_ttl/3to hold the lease (device shows online), answerrequestRegistration, re-register on reconnect, plusinvoke_remote(D2D) andemit(events).*.creds.jsondirectly (auto-converts to nsc-chained for cnats; auto-detectsdevice_id/tenant) or an nsc*.creds.temp_sensor.c(get_reading/set_target+ areading_changedevent).packages/device-connect-agent-tools-c/(libdc_agent_tools.a)describe_fleet,list_devices,get_device_functions,invoke_device; responses parsed to JSON.dc_agentCLI (fleet/list/functions/invoke).Testing
make testin each package.alpha): 3 C edge devices provisioned → registered →devices_online: 3sustained by heartbeat → discovered by the C agent-tools (fleet/list/functions) → invoked C→C (set_target→{"ok":true},get_reading→{"temp_c":…}across all three, ~170 ms), with-32601/-32602device errors propagating through the portal envelope..github/workflows/c-sdk.yml): builds + unit-tests both packages on Linux and macOS (cnats from source on Linux / brew on macOS; libcurl).Dependencies
Scope / not yet
dc/transport.hvtable leaves room for MQTT/Zenoh);@periodic/@on/D2D presence-collector and a few niceties are not yet wired (portal-mode register+heartbeat+cmd+invoke_remote is complete).🤖 Generated with Claude Code