TuyaOS
netcfg_module.h
浏览该文件的文档.
1
12#ifndef __NETCFG_MODULE__
13#define __NETCFG_MODULE__
14
15#include "tuya_hal_wifi.h"
16#include "uni_pointer.h"
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21
22
23/*
24 配网类型的宏定义由32bits整型表示:
25 | high 16bits | low 16bits |
26 | vendor type | cfg type |
27
28 1)固定前缀netcfg
29 2)协议提供方:ty,jd,
30 3)链路方式wifi,ble,camera等,品牌
31 4)特性后缀,如smartcfg,ap,airkiss
32
33 NETCFG_TY_WIFI_SMARTCFG
34 NETCFG_TY_WIFI_AP
35 NETCFG_JD_WIFI_SMART
36 NETCFG_WX_WIFI_AIRKISS
37 NETCFG_TY_BLE
38 NETCFG_TY_CAMERA_QR
39*/
40
41/*
42 配网提供方:
43 tuya, jd, weixin
44
45*/
46#define VENDOR_TUYA (0x1 << 0)
47#define VENDOR_JD (0x1 << 1)
48#define VENDOR_WEIXIN (0x1 << 2)
49#define VENDOR_AMAZON (0x1 << 3)
50
51#define WIFI_SMARTCFG (0x1 << 0)
52#define WIFI_AP (0x1 << 1)
53#define BLE (0x1 << 2)
54#define CAMERA_QR (0x1 << 3)
55#define WIFI_SMARTCFG_COEXIST (0x1 << 4)
56#define WIFI_AP_COEXIST (0x1 << 5)
57#define WIFI_FFS (0x1 << 6)
58#define WIFI_PEGASUS (0x1 << 7)//无感配网
59#define API_USER (0x1 << 8)//用户通过api配网
60
61
62/*netcfg type definitions*/
63// ez
64#define NETCFG_TY_WIFI_SMARTCFG ((VENDOR_TUYA << 16) | WIFI_SMARTCFG)
65// ez in WF_START_SMART_AP_CONCURRENT
66#define NETCFG_TY_WIFI_SMARTCFG_COEXIST ((VENDOR_TUYA << 16) | WIFI_SMARTCFG_COEXIST)
67//ap
68#define NETCFG_TY_WIFI_AP ((VENDOR_TUYA << 16) | WIFI_AP)
69//ap in WF_START_SMART_AP_CONCURRENT
70#define NETCFG_TY_WIFI_AP_COEXIST ((VENDOR_TUYA << 16) | WIFI_AP_COEXIST)
71//ble
72#define NETCFG_TY_BLE ((VENDOR_TUYA << 16) | BLE)
73//qr
74#define NETCFG_TY_CAMERA_QR ((VENDOR_TUYA << 16) | CAMERA_QR)
75//user or uart
76#define NETCFG_TY_API_USER ((VENDOR_TUYA << 16) | API_USER)
77#define NETCFG_JD_WIFI_SMART ((VENDOR_JD << 16) | WIFI_SMARTCFG)
78//wechat airkiss
79#define NETCFG_WX_WIFI_AIRKISS ((VENDOR_WEIXIN << 16) | WIFI_SMARTCFG)
80//amazon ffs netcfg
81#define NETCFG_AMAZON_WIFI_FFS ((VENDOR_AMAZON << 16) | (WIFI_FFS))
82//tuya pegasus netcfg
83#define NETCFG_TY_WIFI_PEGASUS ((VENDOR_TUYA << 16) | WIFI_PEGASUS)
84
85#define NETCFG_STOP_ALL_CFG_MODULE (0)
86
87#define DEF_AP_SSID_PF "SmartLife"
88
89typedef struct {
90 int enable_station_ap;
91 WF_AP_CFG_IF_S *pDevApCfg;
93
94#define WL_TOKEN_LEN (16)
95
100typedef struct {
102 uint8_t ssid[WIFI_SSID_LEN + 1];
104 uint8_t s_len;
106 uint8_t passwd[WIFI_PASSWD_LEN + 1];
108 uint8_t p_len;
110 uint8_t token[WL_TOKEN_LEN + 1];
112 uint8_t t_len;
114
118typedef struct apSsidPasswd_s {
120 uint8_t* pSsid;
122 uint8_t* pPasswd;
124
125
137typedef int (* FN_NETCFG_CB)(PTR_SSID_PASSWORD_TOKEN info, int type);
138
151typedef int (* FN_NETCFG_START)(FN_NETCFG_CB cb, void * args, int type);
152
163typedef int (* FN_NETCFG_STOP)(int type);
164
169typedef struct {
171 LIST_HEAD node;
173 int type;
181 void * args;
185
195
206
220
232
244int netcfg_start(int type, FN_NETCFG_CB netcfg_finish_cb, void *args);
245
256int netcfg_stop(int type);
257
258
270
271/*
272 fun_desc:
273 开启除了type之外所有配网
274*/
275
287
299
309
310#ifdef __cplusplus
311}
312#endif
313
314
315#endif
int netcfg_module_register(int type, FN_NETCFG_START start, FN_NETCFG_STOP stop)
register netcfg type
int netcfg_stop_other_all(int type)
stop all netcfg type except the specified type
int netcfg_start(int type, FN_NETCFG_CB netcfg_finish_cb, void *args)
start netcfg type
int netcfg_start_other_all(int type)
start all netcfg type except the specified type
int netcfg_module_uninit(VOID_T)
uninit netcfg module.
int netcfg_module_init(VOID_T)
init netcfg module.
int netcfg_module_unregister(int type)
unregister netcfg type
int(* FN_NETCFG_START)(FN_NETCFG_CB cb, void *args, int type)
netcfg start function.
Definition: netcfg_module.h:151
int netcfg_stop(int type)
stop netcfg type
int(* FN_NETCFG_CB)(PTR_SSID_PASSWORD_TOKEN info, int type)
netcfg finished callback function.
Definition: netcfg_module.h:137
int netcfg_set_transporter_switch_interval(int ms_interval)
set channel switch interval(default:110ms)
int(* FN_NETCFG_STOP)(int type)
netcfg stop function.
Definition: netcfg_module.h:163
struct apSsidPasswd_s ApSsidPasswd_t
ssid and password info
BOOL_T is_netcfg_module_inited(VOID_T)
whether netcfg module is inited or not
Definition: netcfg_module.h:89
netcfg handler
Definition: netcfg_module.h:169
LIST_HEAD node
Definition: netcfg_module.h:171
FN_NETCFG_STOP stop
Definition: netcfg_module.h:177
void * args
Definition: netcfg_module.h:181
FN_NETCFG_CB netcfg_finish_cb
Definition: netcfg_module.h:179
int type
Definition: netcfg_module.h:173
FN_NETCFG_START start
Definition: netcfg_module.h:175
bool isStarted
Definition: netcfg_module.h:183
ssid password and token info
Definition: netcfg_module.h:100
uint8_t p_len
Definition: netcfg_module.h:108
uint8_t s_len
Definition: netcfg_module.h:104
uint8_t t_len
Definition: netcfg_module.h:112
ssid and password info
Definition: netcfg_module.h:118
uint8_t * pPasswd
Definition: netcfg_module.h:122
uint8_t * pSsid
Definition: netcfg_module.h:120
tuya bidirection list module