Last Updated on : 2024-11-20 08:51:48download
This topic describes the APIs used to implement the functionality of the router and repeater.
typedef struct {
CHAR_T dev_name[TY_ROUTER_DEV_NAME_MAX];
CHAR_T mac[TY_ROUTER_MAC_STR_LEN];
TY_WIFI_TYPE wifi_types; // 1-2.4G, 2-5G
} TUYA_ROUTER_DEV_LIST_S;
Functional specification
The information about devices online.
Member description
Member | Description |
---|---|
dev_name | The device name. |
mac | The MAC address of the device. |
wifi_types | The bands of the wireless network:
|
typedef struct {
CHAR_T ssid[TY_ROUTER_LOGIN_STR_MAX];
BOOL_T b_encrypted;
TY_WIFI_SIG_STRENGTH signal_strength;
} TUYA_ROUTER_WIFI_LIST_S;
Functional specification
The list of access points (AP).
Member description
Member | Description |
---|---|
ssid | The SSID of the AP. |
b_encrypted | Specify whether to encrypt the network. |
signal_strength | Signal strength of the network. |
typedef struct {
TY_WIFI_TYPE wifi_types;
CHAR_T ssid[TY_ROUTER_LOGIN_STR_MAX];
CHAR_T pwd[TY_ROUTER_LOGIN_STR_MAX];
} TUYA_ROUTER_HOTSPOT_S;
Functional specification
The AP information on the router side.
Member description
Member | Description |
---|---|
wifi_types | The bands of the wireless network:
|
ssid | The SSID of the AP. |
pwd | The password of the AP. |
typedef struct {
BOOL_T allow; // allow network
BOOL_T limit; // the speed limit
UINT_T up_limit; // the max limit of upload speed
UINT_T down_limit; // the max limt of download speed
} TUYA_ROUTER_STA_CONF_S;
Functional specification
The AP information on the router side.
Member description
Member | Description |
---|---|
allow | Specify whether to allow access to the wireless network. |
limit | The speed limit. |
up_limit | The maximum upload speed. |
down_limit | The maximum download speed. |
typedef struct {
BRAND_CONN_TYPE_T brand_conn_type; // brand type
PPPOE_INFO_T pppoe_info; // PPPOE
STATIC_IP_T static_ip_info; // static ip
WIFI_INFO_T wifi_info; // WiFi
} BRAND_CONN_SETTING_INFO;
Functional specification
The AP information on the router side.
Member description
Member | Description |
---|---|
brand_conn_type | The types of bandwidth:
|
pppoe_info | For more information, see PPPOE_INFO_T. |
static_ip_info | For more information, see STATIC_IP_T. |
wifi_info | For more information, see WIFI_INFO_T. |
typedef struct {
CHAR_T account[WIFI_SSID_LEN + 1];
CHAR_T pwd[WIFI_PASSWD_LEN + 1];
} PPPOE_INFO_T;
Functional specification
The PPPoE account information.
Member description
Member | Description |
---|---|
account | The account name. |
pwd | The password. |
typedef struct {
CHAR_T ap_ssid[WIFI_SSID_LEN+1]; // ap ssid info
CHAR_T ap_passwd[WIFI_PASSWD_LEN+1]; // ap passwd info
} WIFI_INFO_T;
Functional specification
The wireless network information.
Member description
Member | Description |
---|---|
ap_ssid | The device name. |
ap_passwd | The MAC address of the device. |
typedef struct {
char ip[16]; /* ip addr: xxx.xxx.xxx.xxx */
char mask[16]; /* net mask: xxx.xxx.xxx.xxx */
char gw[16]; /* gateway: xxx.xxx.xxx.xxx */
char primary_dns[16];
char secondary_dns[16];;
} STATIC_IP_T;
Functional specification
The static IP address configuration.
Member description
Member | Description |
---|---|
ip | The IP address. |
mask | The subnet mask. |
gw | The address of the gateway. |
primary_dns | DNS server address 1. |
secondary_dns | DNS server address 2. |
typedef struct {
TY_ROUTER_CMD_HANDLE_CB cmd_handle_cb; // cmd handler
TY_ROUTER_GET_SOURCE_CB get_source_cb; // get ssid & passwod info connected hotspot source.
TY_ROUTER_SET_SOURCE_CB set_source_cb; // to connect hostpot source
TY_ROUTER_GET_HOTSPOT_CB get_hotspot_cb; // get hotspot of own router/repeater
TY_ROUTER_SET_HOTSPOT_CB set_hotspot_cb; // setting hotspot of own router/repeater
TY_ROUTER_QUERY_PWD_CB router_query_pwd_cb; // query WIFI passowrd
TY_ROUTER_SET_PWD_CB router_set_pwd_cb; // set WIFI password
TY_ROUTER_GET_CONN_TYPE_CB router_get_brand_conn_type_cb; // get connection type callback
TY_ROUTER_SET_CONN_TYPE_CB router_set_brand_conn_type_cb; // set connection type callback
} TUYA_ROUTER_CBS_S;
Functional specification
The callbacks.
Member description
Member | Description |
---|---|
cmd_handle_cb | For more information, see cmd_handle_cb. |
get_source_cb | For more information, see get_source_cb. |
set_source_cb | For more information, see set_source_cb. |
get_hotspot_cb | For more information, see get_hotspot_cb. |
set_hotspot_cb | For more information, see set_hotspot_cb. |
router_query_pwd_cb | For more information, see router_query_pwd_cb. |
router_set_pwd_cb | For more information, see router_set_pwd_cb. |
router_get_brand_conn_type_cb | For more information, see router_get_brand_conn_type_cb. |
router_set_brand_conn_type_cb | For more information, see router_set_brand_conn_type_cb. |
typedef struct {
TY_ROUTER_STA_CMD_CB sta_cmd_cb; // station control cmd handler
} TUYA_ROUTER_STA_CBS_S;
Functional specification
The station mode callbacks.
Member description
Member | Description |
---|---|
sta_cmd_cb | For more information, see sta_cmd_cb. |
OPERATE_RET tuya_router_svc_init(IN CONST TUYA_ROUTER_CBS_S *p_route_cbs,
IN CONST TUYA_ROUTER_STA_CBS_S *p_sta_cbs);
Functional description
Initializes the router services. You need to register the callbacks.
Parameter description
Parameter name | Description |
---|---|
p_route_cbs | The pointer to the router service callbacks. For more information, see TUYA_ROUTER_CBS_S. |
p_sta_cbs | The pointer to the station mode callbacks. For more information, see TUYA_ROUTER_STA_CBS_S. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET tuya_router_rept_online_list(IN CONST USHORT_T dev_count,
IN CONST TUYA_ROUTER_DEV_LIST_S *p_list);
Functional description
Reports the list of devices online that are connected to the router.
Parameter description
Parameter name | Description |
---|---|
dev_count | The number of devices online. |
p_list | The pointer to the list of devices online. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET tuya_router_rept_wifi_list(IN CONST USHORT_T dev_count,
IN CONST TUYA_ROUTER_WIFI_LIST_S *p_list);
Functional description
Reports the list of APs available.
Parameter description
Parameter name | Description |
---|---|
dev_count | The number of APs. |
p_list | The list of APs. For more information, see TUYA_ROUTER_WIFI_LIST_S. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET tuya_router_rept_source(IN CONST CHAR_T *ssid, IN CONST CHAR_T *pwd);
Functional description
Reports the SSID and password of the connected router.
Parameter description
Parameter name | Description |
---|---|
ssid | The SSID of the router. |
pwd | 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 . |
OPERATE_RET tuya_router_rept_hotspot(IN CONST TUYA_ROUTER_HOTSPOT_S *p_hotspot, IN CONST USHORT_T num);
Functional description
Reports the AP information on the router side.
Parameter description
Parameter name | Description |
---|---|
p_hotspot | The AP information on the router side. For more information, see TUYA_ROUTER_HOTSPOT_S. |
num | The number of APs. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET tuya_router_rept_sta_allow_net(IN CONST CHAR_T *mac,
IN CONST BOOL_T allow,
IN CONST UINT_T sta_dpid);
Functional description
Sets the limit to internet access for a specific device.
Parameter description
Parameter name | Description |
---|---|
mac | The MAC address of the device connected to the router. |
allow |
|
sta_dpid | The DP ID of station configuration for 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 . |
OPERATE_RET tuya_router_rept_sta_limit(IN CONST CHAR_T *mac,
IN CONST BOOL_T limit,
IN CONST UINT_T sta_dpid);
Functional description
Sets the limit to bandwidth throttling for a specific device.
Parameter description
Parameter name | Description |
---|---|
mac | The MAC address of a specific device connected to the router. |
limit | The specified bandwidth throttling. |
sta_dpid | The DP ID of station configuration for 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 . |
OPERATE_RET tuya_router_rept_sta_up_limit(IN CONST CHAR_T *mac,
IN CONST UINT_T speed,
IN CONST UINT_T sta_dpid);
Functional description
Sets the maximum upload speed for a specific device.
Parameter description
Parameter name | Description |
---|---|
mac | The MAC address of a specific device connected to the router. |
speed | The maximum upload speed, in kbps. |
sta_dpid | The DP ID of station configuration for 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 . |
OPERATE_RET tuya_router_rept_sta_down_limit(IN CONST CHAR_T *mac,
IN CONST UINT_T speed,
IN CONST UINT_T sta_dpid);
Functional description
Sets the maximum download speed for a specific device.
Parameter description
Parameter name | Description |
---|---|
mac | The MAC address of a specific device connected to the router. |
speed | The maximum download speed, in kbps. |
sta_dpid | The DP ID of station configuration for 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 . |
OPERATE_RET tuya_router_rept_sta_all(IN CONST CHAR_T *mac,
IN CONST TUYA_ROUTER_STA_CONF_S *config,
IN CONST UINT_T sta_dpid);
Functional description
Reports the configuration for a specific device.
Parameter description
Parameter name | Description |
---|---|
mac | The MAC address of a specific device connected to the router. |
config | The specified bandwidth throttling. |
sta_dpid | The DP ID of station configuration for 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 . |
OPERATE_RET tuya_router_sta_data_parse(IN CONST CHAR_T *data);
Functional description
Parses the object data of the station configuration of the router.
Parameter description
Parameter name | Description |
---|---|
data | Parses the object data of the station configuration 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 . |
OPERATE_RET tuya_router_rept_pwd(IN CONST TUYA_ROUTER_PWD_E type, IN CONST CHAR_T *pwd);
Functional description
Reports the password of the AP.
Parameter description
Parameter name | Description |
---|---|
type | The MAC address of a specific device connected to the router. |
pwd | The specified bandwidth throttling. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET tuya_router_brand_conn_type_resp(CHAR_T error_code,
CONST CHAR_T *data[],
UCHAR_T data_num);
Functional description
Reports the configuration for a specific device.
Parameter description
Parameter name | Description |
---|---|
error_code | The error code.
|
data | The internet connection type, which can be PPPOE , DHCP , STATIC_IP , WIRED_REPEAT , or WIFI_REPEAT . |
data_num | The length of data. |
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
OPERATE_RET tuya_router_brand_conn_setting_resp(CHAR_T error_code);
Functional description
Reports the result of the internet connection setting.
Parameter description
Parameter name | Description |
---|---|
error_code | The error code.
|
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
VOID tuya_router_set_ext_net_stat(BOOL_T on);
Functional description
Reports the status of internet connection.
Parameter description
Parameter name | Description |
---|---|
on |
|
Return value
Return value | Description |
---|---|
OPRT_OK | Operation succeeded. |
Error code | For more information about the error code, see tuya_error_code.h . |
VOID cmd_handle_cb(IN CONST TY_ROUTER_CMD_E cmd);
Functional description
The callback to process commands, which is to be registered by you.
Parameter description
Parameter name | Description |
---|---|
cmd | The types of commands:
|
Return value
Return value | Description |
---|---|
VOID | / |
VOID get_source_cb(VOID);
Functional description
The callback to notify the application of getting the AP information of the router, which is to be registered by you. Then, call tuya_router_rept_source to report the obtained information.
Parameter description
Parameter name | Description |
---|---|
VOID | / |
Return value
Return value | Description |
---|---|
VOID | / |
VOID get_hotspot_cb(VOID);
Functional description
The callback to notify the application of getting the AP information of the router that the device is connected to, which is to be registered by you. Then, call tuya_router_rept_hotspot to report the obtained information.
Parameter description
Parameter name | Description |
---|---|
VOID | / |
Return value
Return value | Description |
---|---|
VOID | / |
VOID set_source_cb(IN CONST CHAR_T *ssid, IN CONST CHAR_T *pwd)
Functional description
The callback to set the AP information of the router, which is to be registered by you.
Parameter description
Parameter name | Description |
---|---|
ssid | The SSID of the AP. |
pwd | The password of the AP. |
Return value
Return value | Description |
---|---|
VOID | / |
VOID set_hotspot_cb(IN CONST TUYA_ROUTER_HOTSPOT_S *p_hotspot, IN CONST USHORT_T num)
Functional description
The callback to set the AP information of the router that the device is connected to, which is to be registered by you.
Parameter description
Parameter name | Description |
---|---|
p_hotspot | The AP information. |
num | The format of p_hotspot . |
Return value
Return value | Description |
---|---|
VOID | / |
VOID router_query_pwd_cb(IN CONST TUYA_ROUTER_PWD_E type)
Functional description
The callback to query the password of the AP, which is to be registered by you.
Parameter description
Parameter name | Description |
---|---|
type | The types of frequency bands:
|
Return value
Return value | Description |
---|---|
VOID | / |
VOID router_set_pwd_cb(IN CONST TUYA_ROUTER_PWD_E type, IN CONST CHAR_T *pwd)
Functional description
The callback to set the password of the AP, which is to be registered by you.
Parameter description
Parameter name | Description |
---|---|
type | The frequency band. |
pwd | The password of the AP. |
Return value
Return value | Description |
---|---|
VOID | / |
VOID router_get_brand_conn_type_cb(VOID)
Functional description
The callback router_get_brand_conn_type_cb
in the TUYA_ROUTER_CBS_S to query the internet connection types supported by the router, which is to be registered by you. Call tuya_router_brand_conn_type_resp on receiving the callback.
Parameter description
Parameter name | Description |
---|---|
VOID | / |
Return value
Return value | Description |
---|---|
VOID | / |
VOID router_set_brand_conn_type_cb(IN CONST BRAND_CONN_SETTING_INFO *set)
Functional description
The callback to set the internet connection type, which is to be registered by you. Call tuya_router_brand_conn_setting_resp to get the result of the configuration.
Parameter description
Parameter name | Description |
---|---|
VOID | / |
Return value
Return value | Description |
---|---|
VOID | / |
VOID sta_cmd_cb(IN CONST TY_ROUTER_STA_CMD_E cmd,
IN CONST CHAR_T *mac,
IN CONST UINT_T value)
Functional description
The station commands callbacks, which are to be registered by you.
Parameter description
Parameter name | Description |
---|---|
cmd | The type of station commands:
|
mac | The MAC address of the station. |
value | The specified value. For example, the value of TY_STA_CMD_DOWN_LIMIT represents the specified maximum download speed. |
Return value
Return value | Description |
---|---|
VOID | / |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback