Skip to main content

Bring-up 3: Wi-Fi and network

The third stage connects your chip to the network: associate with an AP, obtain an IP, and reach the internet over TCP and TLS. This is the foundation the cloud connection sits on.

Goalโ€‹

TuyaOpen can scan and join a Wi-Fi AP, get an IP address, resolve DNS, and open a TLS socket to an internet host.

Files to implementโ€‹

FileWhat you implement
tkl_wifi.cScan, connect/disconnect, station/AP/mode switch, MAC get/set, RF calibration, country code
tkl_network.c or tkl_lwip.cThe socket layer โ€” implement one, depending on whose lwIP you use (below)
tkl_hash.c / tkl_symmetry.c (optional)Only if you use your SDK's crypto instead of TuyaOpen's Mbed TLS

Detailsโ€‹

  • Pick one network adapter:

    Adapt only one. Toggle in tos.py config menu โ†’ configure tuyaopen โ†’ configure enable/disable liblwip.

  • TLS / crypto. Use your SDK's Mbed TLS or TuyaOpen's (configure mbedtls โ†’ Enable user custom). Either way, a good hardware random number generator is essential โ€” weak entropy breaks the TLS handshake.

  • Wi-Fi events. Drive the WIFI_EVENT_CB so TuyaOpen sees connect/disconnect/got-IP transitions; the station state machine and reconnect logic depend on these.

Verifyโ€‹

From a test app: scan and join your AP, confirm an IP via your logs, resolve a hostname (DNS), and open a TLS connection to an internet endpoint. You succeed when a TLS socket connects and exchanges data reliably.

Next: Bring-up 4: Cloud connection.

See alsoโ€‹