TuyaOS
netcfg_module.h
浏览该文件的文档.
1
12#ifndef __NETCFG_MODULE__
13#define __NETCFG_MODULE__
14
15#include "tal_wifi.h"
16#include "tuya_list.h"
17#include "stdint.h"
18#include "stdbool.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24
25
26/*
27 配网类型的宏定义由32bits整型表示:
28 | high 16bits | low 16bits |
29 | vendor type | cfg type |
30
31 1)固定前缀netcfg
32 2)协议提供方:ty,jd,
33 3)链路方式wifi,ble,camera等,品牌
34 4)特性后缀,如smartcfg,ap,airkiss
35
36 NETCFG_TY_WIFI_SMARTCFG
37 NETCFG_TY_WIFI_AP
38 NETCFG_JD_WIFI_SMART
39 NETCFG_WX_WIFI_AIRKISS
40 NETCFG_TY_BLE
41 NETCFG_TY_CAMERA_QR
42*/
43
44/*
45 配网提供方:
46 tuya, jd, weixin
47
48*/
49#define VENDOR_TUYA (0x1 << 0)
50#define VENDOR_JD (0x1 << 1)
51#define VENDOR_WEIXIN (0x1 << 2)
52#define VENDOR_AMAZON (0x1 << 3)
53
54#define WIFI_SMARTCFG (0x1 << 0)
55#define WIFI_AP (0x1 << 1)
56#define BLE (0x1 << 2)
57#define CAMERA_QR (0x1 << 3)
58#define WIFI_SMARTCFG_COEXIST (0x1 << 4)
59#define WIFI_AP_COEXIST (0x1 << 5)
60#define WIFI_FFS (0x1 << 6)
61#define WIFI_PEGASUS (0x1 << 7)//无感配网
62#define API_USER (0x1 << 8)//用户通过api配网
63
64
65/*netcfg type definitions*/
66// ez
67#define NETCFG_TY_WIFI_SMARTCFG ((VENDOR_TUYA << 16) | WIFI_SMARTCFG)
68// ez in WF_START_SMART_AP_CONCURRENT
69#define NETCFG_TY_WIFI_SMARTCFG_COEXIST ((VENDOR_TUYA << 16) | WIFI_SMARTCFG_COEXIST)
70//ap
71#define NETCFG_TY_WIFI_AP ((VENDOR_TUYA << 16) | WIFI_AP)
72//ap in WF_START_SMART_AP_CONCURRENT
73#define NETCFG_TY_WIFI_AP_COEXIST ((VENDOR_TUYA << 16) | WIFI_AP_COEXIST)
74//ble
75#define NETCFG_TY_BLE ((VENDOR_TUYA << 16) | BLE)
76//qr
77#define NETCFG_TY_CAMERA_QR ((VENDOR_TUYA << 16) | CAMERA_QR)
78//user or uart
79#define NETCFG_TY_API_USER ((VENDOR_TUYA << 16) | API_USER)
80#define NETCFG_JD_WIFI_SMART ((VENDOR_JD << 16) | WIFI_SMARTCFG)
81//wechat airkiss
82#define NETCFG_WX_WIFI_AIRKISS ((VENDOR_WEIXIN << 16) | WIFI_SMARTCFG)
83//amazon ffs netcfg
84#define NETCFG_AMAZON_WIFI_FFS ((VENDOR_AMAZON << 16) | (WIFI_FFS))
85//tuya pegasus netcfg
86#define NETCFG_TY_WIFI_PEGASUS ((VENDOR_TUYA << 16) | WIFI_PEGASUS)
87
88#define NETCFG_STOP_ALL_CFG_MODULE (0)
89
90#define DEF_AP_SSID_PF "SmartLife"
91
92typedef struct {
93 int enable_station_ap;
94 WF_AP_CFG_IF_S *pDevApCfg;
96
97#define WL_TOKEN_LEN (16)
98
103typedef struct {
105 uint8_t ssid[WIFI_SSID_LEN + 1];
107 uint8_t s_len;
109 uint8_t passwd[WIFI_PASSWD_LEN + 1];
111 uint8_t p_len;
113 uint8_t token[WL_TOKEN_LEN + 1];
115 uint8_t t_len;
117
121typedef struct apSsidPasswd_s {
123 uint8_t* pSsid;
125 uint8_t* pPasswd;
127
128
140typedef int (* FN_NETCFG_CB)(PTR_SSID_PASSWORD_TOKEN info, int type);
141
154typedef int (* FN_NETCFG_START)(FN_NETCFG_CB cb, void * args, int type);
155
166typedef int (* FN_NETCFG_STOP)(int type);
167
172typedef struct {
174 LIST_HEAD node;
176 int type;
184 void * args;
188
198
209
223
235
247int netcfg_start(int type, FN_NETCFG_CB netcfg_finish_cb, void *args);
248
259int netcfg_stop(int type);
260
261
273
274/*
275 fun_desc:
276 开启除了type之外所有配网
277*/
278
290
302
312
313VOID_T netcfg_module_clear(VOID_T);
314
315#ifdef __cplusplus
316}
317#endif
318
319
320#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:154
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:140
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:166
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:92
netcfg handler
Definition: netcfg_module.h:172
LIST_HEAD node
Definition: netcfg_module.h:174
FN_NETCFG_STOP stop
Definition: netcfg_module.h:180
void * args
Definition: netcfg_module.h:184
FN_NETCFG_CB netcfg_finish_cb
Definition: netcfg_module.h:182
int type
Definition: netcfg_module.h:176
FN_NETCFG_START start
Definition: netcfg_module.h:178
bool isStarted
Definition: netcfg_module.h:186
ssid password and token info
Definition: netcfg_module.h:103
uint8_t p_len
Definition: netcfg_module.h:111
uint8_t s_len
Definition: netcfg_module.h:107
uint8_t t_len
Definition: netcfg_module.h:115
ssid and password info
Definition: netcfg_module.h:121
uint8_t * pPasswd
Definition: netcfg_module.h:125
uint8_t * pSsid
Definition: netcfg_module.h:123
Common process