• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 FuZhou Lockzhiner Electronic Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup Lockzhiner
18  *
19  * @file wifi.h
20  */
21 
22 #ifndef LZ_HARDWARE_WIFI_H
23 #define LZ_HARDWARE_WIFI_H
24 
25 #define WIFI_MAX_SSID_LEN    33 // 32 + \0
26 #define WIFI_MAC_LEN         6
27 #define WIFI_MAX_KEY_LEN     65 // 64 + \0
28 
29 typedef struct _WifiScanResult {
30     /** Service set ID (SSID). For its length. */
31     char ssid[WIFI_MAX_SSID_LEN];
32     /** Basic service set ID (BSSID). For its length. */
33     unsigned char bssid[WIFI_MAC_LEN];
34     /** Security type. For details. */
35     int securityType;
36     /** Received signal strength indicator (RSSI) */
37     int rssi;
38     /** Frequency band */
39     int band;
40     /** Frequency in MHz */
41     int frequency;
42 } WifiScanResult;
43 
44 typedef enum {
45     LZ_HARDWARE_WIFI_DISCONNECTED,
46     LZ_HARDWARE_WIFI_CONNECTED,
47 } WifiConnStatus;
48 
49 typedef struct _WifiConnInfo {
50     char ssid[WIFI_MAX_SSID_LEN];
51     unsigned char bssid[WIFI_MAC_LEN];
52     unsigned int channel;
53     WifiConnStatus status;
54 } WifiConnInfo;
55 
56 unsigned int WifiEnable(void);
57 unsigned int WifiDisable(void);
58 unsigned int WifiStartStation(void);
59 unsigned int WifiConnect(unsigned char *ssid, unsigned char *passphrase);
60 unsigned int WifiGetConnectInfo(WifiConnInfo *info);
61 unsigned int WifiDisconnect(unsigned short reasonCode);
62 unsigned int WifiStartScan(void);
63 unsigned int WifiAbortScan(void);
64 unsigned int WifiGetScanResult(WifiScanResult **result, unsigned int *size);
65 unsigned int WifiRegisterEvent(void);
66 unsigned int WifiUnregisterEvent(void);
67 unsigned int WifiConfigAP(unsigned char *ssid, unsigned char *preSharedKey, unsigned short channel);
68 unsigned int WifiStartAP(void);
69 unsigned int WifiStopAP(void);
70 unsigned int WifiResidentSet(int enter);
71 
72 #endif
73 
74