Last Updated on : 2024-01-18 07:51:21download
Wi-Fi Flexible Fast Control (FFC) is Tuya’s proprietary technology that enables Wi-Fi devices to communicate with each other without being connected to a wireless router. It is suitable for communication between remotes and controlled devices. This topic describes the features supported by the controlled device.
There are two types of Wi-Fi FFC remotes: local and online.
Bind with up to five remotes.
Receive commands from the remote.
Synchronize the remote binding information with the cloud.
Unbind from an online remote using the mobile app.
The unbinding process is one-way, without any synchronization between the remote and the controlled device.
Open tuya_iot_config.h
and check if the following macro is defined.
#define ENABLE_WIFI_FFC 1
#define TUYA_WIFI_FFC_SLAVER 1 /*As a controlled device*/
ffc_app.h
typedef enum {
FFC_INIT_STATE = 0,
FFC_CONTROL_STATE,
FFC_BINDING_BEGIN_STATE,
FFC_BINDING_SUCCESS_STATE,
FFC_BINDING_FINSH_STATE,
} ffc_cb_state_t;
typedef int (*ffc_status_cb)(ffc_cb_state_t state);
typedef int (*ffc_recv_cb)(uint8_t *data_cmd, uint16_t data_len);
/**
* @brief ffc init function,must called first
*
* @param[in] role: Remote or controlled device
* @param[in] status_cb: user status callback
* @param[in] recv_cb: user received callback
*
* @return OPRT_OK on success. Others error, please refer to tuya_error_code.h
*
*/
int tuya_iot_wifi_ffc_init(uint8_t role, ffc_status_cb *status_cb, ffc_recv_cb *recv_cb);
There is a window duration for pairing and binding, which can be adjusted by specifying the corresponding parameter. The device will not send any commands or responses related to pairing and binding outside the window duration.
/**
* @brief ffc bind function
*
* @param[in] timeout_s time out
*
* @return OPRT_OK on success. Others error, please refer to tuya_error_code.h
*
*/
int tuya_iot_wifi_ffc_bind(uint16_t timeout_s);
service_ffc_slaver
in TuyaOS example collection contains the complete example code.
The logic differs depending on the type of remote.
If all five remotes are the online type, overwriting does not apply. The device will fail to bind with the sixth remote.
If all five remotes are the local type, overwriting applies. Binding the sixth remote will overwrite the first, and binding the seventh remote will overwrite the second, and so on.
After the second remote is unbound, binding the sixth remote will overwrite the first one instead of taking the second place.
If there is a mix of online and local types among the five remotes, adding a new remote will overwrite the oldest local remote. Binding the sixth remote will overwrite the earliest local remote.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback