Skip to content

rtl8720dn: use shared RPC checks for TLS connections - #908

Closed
hnw wants to merge 1 commit into
tinygo-org:devfrom
hnw:fix/rtl8720dn-tls-errors-v2
Closed

hnw wants to merge 1 commit into
tinygo-org:devfrom
hnw:fix/rtl8720dn-tls-errors-v2

Conversation

@hnw

@hnw hnw commented Oct 12, 2026

Copy link
Copy Markdown

The RTL8720DN driver treats only -1 as a TLS connection failure. The firmware can return other negative codes. It can also return 0 after it closes the socket on a connection failure.

This change rejects every negative TLS result and includes the original code in the error. After a nonnegative result, it checks the internal socket. Socket 0 is valid. A negative socket is an error. The error does not assume why the socket closed.

The two TLS RPCs return (int32, error). They use the shared write and read functions in rpc_util.go. The existing performRequest() and read() methods are thin wrappers around those same functions. The shared path checks UART errors, short writes, incomplete frames, frame length, CRC, and response headers. It skips notification frames and uses the existing 2048 byte payload buffer.

A failed TLS connection rejects send and receive calls. The client remains available to Close(), which stops the socket, destroys the client, and removes its map entry. Repeated close calls do not send more RPCs.

The host test tag replaces hardware setup with a test device. The tests call the driver RPC, Connect(), and Close() methods. These socket methods are in socket.go so the tests can use them without a machine package. make unit-test runs the host tests.

This branch starts from upstream/dev at 8aae6eafa7ca. It implements the requested replacement for #907. The old branch and PR remain unchanged.

Validation

  • make unit-test passed.
  • go test -race -tags rtl8720dn_hosttest ./rtl8720dn passed.
  • make fmt-check and git diff --check passed.
  • Wio Terminal builds for examples/net/tlsclient and examples/net/tcpclient passed with TinyGo 0.42.0.
  • Board connection tests are pending. No Wi-Fi test settings were supplied.

@hnw

hnw commented Oct 12, 2026

Copy link
Copy Markdown
Author

Closing this in favor of #907.

I reworked #907 to handle TLS connection errors without refactoring the shared RPC implementation or modifying generated code. The new approach keeps the changes smaller and more focused.

The updated implementation has also been tested on Wio Terminal hardware.

Thanks!

@hnw hnw closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant