Wired Connection

Last Updated on : 2022-11-24 09:20:24

This topic describes the APIs used to enable the gateway to be connected to the internet via a wired Ethernet connection.

Structs

NW_IP_S

typedef struct
{
    char ip[16];
    char mask[16];
    char gw[16];
} NW_IP_S;

Functional specification

The IP address information.

Member description

Member Description
ip The IP address of the network adapter.
mask The subnet mask of the network adapter.
gw The default gateway of the network adapter.

NW_MAC_S

typedef struct
{
    uint8_t mac[TY_MAC_ADDR_LEN];
}NW_MAC_S;

Functional specification

The MAC address information.

Member description

Member Description
mac The MAC address, stored byte by byte with the symbol : removed.

API reference

tuya_adapter_wired_get_ip

OPERATE_RET tuya_adapter_wired_get_ip(OUT NW_IP_S *ip)

Functional description

Gets the IP address of the wired network adapter.

Parameter description

Parameter name Description
ip The IP address information. For more information, see NW_IP_S.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_adapter_wired_station_conn

BOOL_T tuya_adapter_wired_station_conn(VOID)

Functional description

Gets the status of the wired connection.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
TRUE The wired connection is established.
FALSE The wired connection is not established.

tuya_adapter_wired_get_mac

OPERATE_RET tuya_adapter_wired_get_mac(OUT NW_MAC_S *mac)

Functional description

Gets the MAC address of the wired network adapter. This is a reserved interface so implementation is not needed.

Parameter description

Parameter name Description
mac The MAC address information. For more information, see NW_MAC_S.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_adapter_wired_set_mac

OPERATE_RET tuya_adapter_wired_set_mac(IN CONST NW_MAC_S *mac)

Functional description

Sets the MAC address of the wired network adapter. This is a reserved interface so implementation is not needed.

Parameter description

Parameter name Description
mac The MAC address information. For more information, see NW_MAC_S.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_adapter_wired_if_connect_internet

OPERATE_RET tuya_adapter_wired_if_connect_internet(IN CONST CHAR_T *ssid,
                                                   IN CONST CHAR_T *passwd)

Functional description

Connects the gateway to the router. This API works only when you use the wireless and wired combo SDK and tuya_adapter_wired_wifi_need_cfg returns TRUE. This is a reserved interface so implementation is not needed.

Parameter description

Parameter name Description
ssid The SSID of the router.
password The password of the router.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_adapter_wired_wifi_need_cfg

BOOL_T tuya_adapter_wired_wifi_need_cfg(VOID)

Functional description

Specifies whether the wireless connection is supported. This API works only when you use the wireless and wired combo SDK. This is a reserved interface so implementation is not needed.

Parameter description

Parameter name Description
VOID /

Return value

Return value Description
TRUE Wireless connection is supported.
FALSE Wireless connection is not supported.

tuya_adapter_wired_wifi_station_get_conn_ap_rssi

OPERATE_RET tuya_adapter_wired_wifi_station_get_conn_ap_rssi(OUT SCHAR_T *rssi)

Functional description

Gets the signal strength of the wireless network. This API works only when you use the wireless and wired combo SDK and the gateway accesses the internet via the wireless network.

Parameter description

Parameter name Description
rssi Assign the obtained signal strength to this variable.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

tuya_adapter_wired_get_nw_stat

OPERATE_RET tuya_adapter_wired_get_nw_stat(GW_BASE_NW_STAT_T *stat)

Functional description

Gets the network status. This is a reserved interface so implementation is not needed.

Parameter description

Parameter name Description
status The network status:
  • GB_STAT_LAN_UNCONN: The wired connection is not established.
  • GB_STAT_LAN_CONN: The wired connection is established but the MQTT is not connected.
  • GB_STAT_CLOUD_CONN: The wired connection is established and the MQTT is connected.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.

Return value

Return value Description
OPRT_OK Operation succeeded.
Error code For more information about the error code, see tuya_error_code.h.