Documentation

Documentation

Includes

stdint.h

#include <stdint.h>
#include 

Macros

Marco __TUYA_FFC_APP_H__

#define __TUYA_FFC_APP_H__


      

Marco FFC_MASTER

#define FFC_MASTER                   1


      

Marco FFC_SLAVER

#define FFC_SLAVER                   2


      

Marco FFC_LOWPOWER_EVENT

#define FFC_LOWPOWER_EVENT           "ffc.lowpower"


      

Marco ffc_init

#define ffc_init       tuya_iot_wifi_ffc_init


      

Marco ffc_bind

#define ffc_bind       tuya_iot_wifi_ffc_bind


      

Marco ffc_unbind

#define ffc_unbind     tuya_iot_wifi_ffc_unbind


      

Marco ffc_send

#define ffc_send       tuya_iot_wifi_ffc_send


      

Marco ffc_control

#define ffc_control    tuya_iot_wifi_ffc_control

      

Functions

Func tuya_iot_wifi_ffc_init

int tuya_iot_wifi_ffc_init(uint8_t role, ffc_status_cb *status_cb, ffc_recv_cb *recv_cb);
/**
 * @brief ffc init function,must called first
 *
 * @param[in] role master or slaver
 * @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
 *
 */

Func tuya_iot_wifi_ffc_bind

int tuya_iot_wifi_ffc_bind(uint16_t timeout_s);
/**
 * @brief ffc bind function
 *
 * @param[in] timeout_s time out
 *
 * @return OPRT_OK on success. Others error, please refer to tuya_error_code.h
 *
 */

Func tuya_iot_wifi_ffc_unbind

int tuya_iot_wifi_ffc_unbind(uint16_t timeout_s);
/**
 * @brief ffc unbind function
 *
 * @param[in] timeout_s time out
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 *
 */

Func tuya_iot_wifi_ffc_send

int tuya_iot_wifi_ffc_send(uint8_t *data, uint16_t len);
/**
 * @brief ffc send
 *
 * @param[in] data send buf
 * @param[in] len send length
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 *
 */

Func tuya_iot_wifi_ffc_control

int tuya_iot_wifi_ffc_control(int flag, void *data);
/**
 * @brief ffc control
 *
 * @param[in] flag control flag
 * @param[in] data control data
 *
 * @return OPRT_OK on success. Others error, please refer to tuya_error_code.h
 *
 */

Vars

Consts

Types

Typedefs

Typedef ffc_cb_state_t;

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 ffc_status_cb

typedef int (*ffc_status_cb)(ffc_cb_state_t state);


      

Typedef ffc_recv_cb

typedef int (*ffc_recv_cb)(uint8_t *data_cmd, uint16_t data_len);


      

Typedef ffc_master_type_t;

typedef enum {
   FFC_MASTER_TYPE_LOCAL   = 0,
   FFC_MASTER_TYPE_FITTINGS = 1,
   FFC_MASTER_TYPE_DEVICE  = 2,
   FFC_MASTER_TYPE_ONLINE  = FFC_MASTER_TYPE_DEVICE,
   FFC_MASTER_TYPE_MAX,
} ffc_master_type_t;
//! FFC_MASTER_TYPE_LOCAL -> FFC_MASTER_TYPE_FITTINGS

Typedef ffc_fittings_event_t;

typedef enum {
   FFC_FITTINGS_SYNC_EVENT,
   FFC_FITTINGS_ACTIVE_EVENT,
} ffc_fittings_event_t;


      

Typedef ffc_fittings_msg_t;

typedef struct {
   ffc_fittings_event_t   event;
   ffc_master_type_t      type;
   uint8_t                mac[6];
   uint8_t                key[16];
   uint16_t               seq;
   uint8_t                uuid[25 + 1];
   uint8_t                pid[20 + 1];
} ffc_fittings_msg_t;


      

Typedef ffc_fittings_cb

typedef int (*ffc_fittings_cb)(ffc_fittings_msg_t *msg);


      

Typedef ffc_group_t;

typedef enum {
   FFC_GROUP_0 = 0,
   FFC_GROUP_1,
   FFC_GROUP_2,
   FFC_GROUP_3,
   FFC_GROUP_MAX,
} ffc_group_t;


      

Typedef ffc_flag_t;

typedef enum {
   FFC_CHANNEL_SCAN_FLAG  = 1,
   FFC_MASTER_GROUP_SET_FLAG,
   FFC_MASTER_TYPE_SET_FLAG,
} ffc_flag_t;


      

Typedef ffc_cfg_t;

typedef struct {
   /** uuid,assigned by TUYA */
   uint8_t    uuid[25 + 1];
   /** pid,assigned by TUYA */
   uint8_t    pid[20 + 1];
   /** auzkey,assigned by TUYA */
   uint8_t    auzkey[32 + 1];
   /** mac address */
   uint8_t    mac[6];
   /** wifi channel */
   uint8_t    channel[13];
   /** channel count */
   uint8_t    channel_count;
   /** flag */
   uint32_t   flag;
} ffc_cfg_t;
/**
 * @brief ffc configure struct
 */

Typedef ffc_ops_t;

typedef struct {
   /** new channel set */
   int (*channel_set)(uint8_t new_channel);
   /** one channel get */
   uint8_t (*channel_get)(void);
   /** set frame */
   int (*send_frame)(uint8_t *frame, uint16_t frame_len, uint8_t src_mac[6], uint8_t dst_mac[6]);
} ffc_ops_t;
/**
 * @brief ffc operation struct
 */

Typedef ffc_cb_t;

typedef struct {
   /** user status call back */
   ffc_status_cb  status_cb;
   /** user received callback */
   ffc_recv_cb    recv_cb;
   /** ffc active cb */
   ffc_fittings_cb fittings_cb;
} ffc_cb_t;
/**
 * @brief callback define when ffc init
 */