gateway: initial pouch over coap#225
Open
mniestroj wants to merge 9 commits into
Open
Conversation
bf6d27d to
17cdd85
Compare
The header was never intended as part of the public API. Only the gateway and broker endpoint use it. Move it next to its implementation so that the public include tree only contains the supported API. Signed-off-by: Marcin Niestroj <marcin.niestroj@canonical.com>
The 'info' name was generic enough to clash with similarly-named log modules elsewhere. Pick a more specific name. Signed-off-by: Marcin Niestroj <marcin.niestroj@canonical.com>
Cached serial length is zero and zcbor_compare_strings() reports a match against a zero-length expected serial before any server certificate has been received. In that case 'server_cert_provisioned' is reported as true. Skip the comparison until a serial has actually been read. Signed-off-by: Marcin Niestroj <marcin.niestroj@canonical.com>
The single-threaded usage assumption is about to be broken by a new gateway transport (added in a later commit) that calls into the CoAP client from a separate thread. Introduce a mutex covering all socket and buffer state, and lock it around the public entry points. Signed-off-by: Marcin Niestroj <marcin.niestroj@canonical.com>
A subsequent commit will add a gateway transport (gateway.c) that needs to set up the DTLS socket, fetch the server certificate, upload the device certificate and inspect the cached server cert. Make those helpers non-static, drop the sec_tag parameter from pouch_coap_setup_socket() (it already had the value cached from pouch_coap_client_init()), move the sec_tag validation into the helper. Add pouch_coap_server_cert_get() so the gateway can pass the cert on to the broker bearer. No behaviour change for existing callers. Signed-off-by: Marcin Niestroj <marcin.niestroj@canonical.com>
The Zephyr CoAP port already exposes the gateway address as CONFIG_POUCH_COAP_GW_URI in port/zephyr/transport/coap/Kconfig, but the sysbuild config and the test workflow were still pushing the value via the old CONFIG_GOLIOTH_COAP_HOST_URI name (now removed from the port). Align the sysbuild Kconfig and the CI export with the active port symbol, and switch from a full coap[s]:// URL to a hostname so the names match the actual usage on the port side. Signed-off-by: Marcin Niestroj <marcin.niestroj@canonical.com>
54abe97 to
b1e9559
Compare
Introduce a pluggable cloud transport interface so the gateway core can forward pouches and certificates without hard-coding any concrete transport. A transport implements three operations (ensure_ready/forward_pouch/upload_device_cert) and registers itself through pouch_gateway_cloud_transport_register(). The matching dispatcher helpers in src/gateway/cloud.c look up the active transport and return -ENODEV when none is registered, keeping the gateway core trivially testable. A concrete CoAP transport is added in a later commit. This commit only adds the abstraction. Signed-off-by: Marcin Niestroj <marcin.niestroj@canonical.com>
Wire the gateway core and the gateway/gateway_custom_connect samples to the new pouch CoAP stack. Implement the pouch_gateway_cloud_transport vtable on top of the CoAP client helpers, gated by CONFIG_POUCH_GATEWAY_CLOUD_TRANSPORT_COAP (default y when both POUCH_GATEWAY and POUCH_TRANSPORT_COAP_CLIENT are enabled). The transport is registered by calling pouch_coap_gateway_init() after pouch_coap_client_init(). Rewrite cert, uplink and downlink on top of the cloud vtable. The uplink now concatenates the full pouch into a pouch_buf and forwards it through pouch_gateway_cloud_forward_pouch() in one call instead of streaming block-by-block, dropping the bespoke block.[ch] pool in favour of pouch_buf/blockbuf. cert.c routes the device cert upload through the vtable and loads the built-in server cert from a module_init() entry point instead of lazily on connect. Move pouch/gateway/downlink.h into src/gateway/ since it is no longer part of the public API. Extract the Zephyr GATT broker sources into a dedicated subdirectory CMakeLists, move the broker endpoint sources into the generic transport library behind CONFIG_POUCH_GATEWAY, and link the gateway library against the pouch core instead of re-adding it as a subdirectory. Make POUCH_GATEWAY depend on POUCH. The samples load mTLS DTLS credentials from a LittleFS partition and import the device private key into PSA, dropping the PSK flow. Sysbuild gains GATEWAY_MOUNT_CREDS to mount a per-build creds volume into native_sim, and the pytest harness for 'gateway' provisions an EC keypair with a CA-signed device cert automatically. Signed-off-by: Marcin Niestroj <marcin.niestroj@canonical.com>
Add native_sim ztest suites that exercise the gateway core directly against a stub cloud transport and a malloc-backed blockbuf, without pulling in Bluetooth or the broker GATT library. The cloud suite covers transport registration and dispatcher fallbacks. The uplink suite covers open/write/close including the resp_cb plumbing and the cloud-disabled (-ENODEV) path. The downlink suite covers single- and multi-block paths, abort and end-on-error. Signed-off-by: Marcin Niestroj <marcin.niestroj@canonical.com>
b1e9559 to
adc4d4e
Compare
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.
No description provided.