Client Transport
Language
- Go.
Runtime Context
- Client HTTP boundary to Phoenix.
Purpose
- Encapsulates JSON HTTP requests for device registration, heartbeat polling, command-result submission, and deferred command-payload retrieval.
Key Files
packages/client/internal/transport/client.gopackages/client/internal/transport/register_test.gopackages/client/internal/transport/client_runtime_test.godocs/src/client-server-interface.md
Public Interfaces
- Types:
ClientPollRequestCommandStatusCommandRequestCommandPayloadCommandResultPollResponseCommandResultsRequest
- Constants:
CommandStatusOKCommandStatusFailed
- Functions and methods:
NewClient(*Client).RegisterDevice(*Client).Poll(*Client).SendCommandResults(*Client).FetchCommandPayload
Dependencies
Internal
internal/configinternal/frpinternal/identityinternal/telemetry
External
- Go
net/http - Go experimental
encoding/json/v2
Client-Server Interaction Details
RegisterDevice:POST {baseURL}/api/v1/devices/register- Sends
mac_address, optionalproduct_name, and optionalmetadata. - Expects
201and responsedata.id. - Approved devices receive
data.api_token; pending devices omit it until approval. - Re-registering the same MAC address updates the existing device record rather than creating a duplicate identity.
Poll:POST {baseURL}/api/v1/devices/{uuid}/heartbeat- Sends
telemetryandconnection_status. - Requires the issued device token as
api_keyquery parameter. - Expects
200or202and optional responsedata.remote_access_tokenplus optionaldata.commands. - HTTP
429indicates the server rate limit rejected the heartbeat.
SendCommandResults:POST {baseURL}/api/v1/devices/{uuid}/command_results- Sends
resultsarray. - Requires the issued device token as
api_keyquery parameter. - Expects
200or202.
FetchCommandPayload:GET {baseURL}/api/v1/devices/{uuid}/command_payloads/{ref}- Requires the issued device token as
api_keyquery parameter. - Expects
200and aCommandPayload.
Traceable references:
packages/client/internal/transport/client.go:21-212docs/src/client-server-interface.md