wlan-connection.md 6.4 KB
Newer Older
M
mamingshuai 已提交
1
# WLAN Connection<a name="EN-US_TOPIC_0000001152048651"></a>
W
wenjun 已提交
2

N
NEEN 已提交
3
-   [Building](#section191121332125319)
M
mamingshuai 已提交
4 5
-   [Burning Images](#section19458165166)
-   [Connecting WLAN Module to the Internet.](#section194671619167)
[
[yang] 已提交
6 7

This example shows how to connect the WLAN module to the gateway using attention \(AT\) commands.
W
wenjun 已提交
8

N
NEEN 已提交
9
## Building<a name="section191121332125319"></a>
W
wenjun 已提交
10

Y
yangni 已提交
11 12
This section describes how to perform the WLAN module building on a Linux server.

M
mamingshuai 已提交
13
If the Linux environment is installed using Docker, perform the building by referring to  [Using Docker to Prepare the Build Environment](../get-code/tool-acquisition.md). If the Linux environment is installed using a software package, perform the following steps:
W
wenjun 已提交
14

[
[yang] 已提交
15
1.  Open the HUAWEI DevEco Device Tool and choose  **View**  \>  **Terminal**.
W
wenjun 已提交
16 17 18 19

    **Figure  1**  Starting the IDE terminal tool<a name="fig1975813338510"></a>  
    

N
NEEN 已提交
20
    ![](figures/1.png)
W
wenjun 已提交
21

N
NEEN 已提交
22
    On the  **TERMINAL**  panel, run the ssh command, for example,  **ssh** **_user_@_ipaddr_**, to connect to the Linux server.
W
wenjun 已提交
23

N
NEEN 已提交
24
    **Figure  2**  TERMINAL panel<a name="fig91165301546"></a>  
W
wenjun 已提交
25 26
    

N
NEEN 已提交
27
    ![](figures/2.png)
W
wenjun 已提交
28

N
NEEN 已提交
29
2.  Go to the root directory of the code, run the  **hb set**  and  **.**  commands on the  **TERMINAL**  panel, and select the  **wifiiot\_hispark\_pegasus**  version.
N
NEEN 已提交
30 31 32 33

    **Figure  3**  Selecting the target build version<a name="fig17727115215612"></a>  
    

N
NEEN 已提交
34
    ![](figures/3.png)
N
NEEN 已提交
35 36

3.  Run the  **hb build**  command to start building.
W
wenjun 已提交
37

N
NEEN 已提交
38
    **Figure  4**  Running commands on the TERMINAL panel<a name="fig5493164414573"></a>  
W
wenjun 已提交
39 40
    

N
NEEN 已提交
41
    ![](figures/4.png)
W
wenjun 已提交
42

N
NEEN 已提交
43 44 45 46
4.  Check whether the building is successful. If yes,  **wifiiot\_hispark\_pegasus build success**  will be displayed, as shown in the following figure.

    **Figure  5**  Successful building<a name="fig1262101218463"></a>  
    
W
wenjun 已提交
47

N
NEEN 已提交
48
    ![](figures/5.png)
W
wenjun 已提交
49

N
NEEN 已提交
50
5.  Check whether the following files are generated in the  **./out/wifiiot/**  directory.
[
[yang] 已提交
51 52

    ```
N
NEEN 已提交
53
    ls -l out/hispark_pegasus/wifiiot_hispark_pegasus/
[
[yang] 已提交
54
    ```
W
wenjun 已提交
55

N
NEEN 已提交
56
    **Figure  6**  Directory for storing the generated files<a name="fig38521346164618"></a>  
W
wenjun 已提交
57 58
    

N
NEEN 已提交
59
    ![](figures/3-0.png)
W
wenjun 已提交
60 61


M
mamingshuai 已提交
62
## Burning Images<a name="section19458165166"></a>
W
wenjun 已提交
63

[
[yang] 已提交
64
You can use the DevEco tool to perform the image burning of the Hi3861 WLAN module. For details about how to use the tool, see  [HUAWEI DevEco Device Tool User Guide](https://device.harmonyos.com/en/docs/ide/user-guides/service_introduction-0000001050166905).
W
wenjun 已提交
65

N
NEEN 已提交
66 67
1.  Connect the PC and the target development board through the USB port. For details, please refer to  [Introduction to the Hi3861 Development Board](https://device.harmonyos.com/en/docs/start/introduce/oem_wifi_start_des-0000001050168548).
2.  <a name="en-us_topic_0000001056563976_li848662117291"></a>Open Device Manager, then check and record the serial port number corresponding to the development board.
W
wenjun 已提交
68

N
NEEN 已提交
69 70
    >![](public_sys-resources/icon-note.gif) **NOTE:** 
    >If the serial port number is not displayed correctly, follow the steps described in  [Installing the Serial Port Driver on the Hi3861 Series Development Boards](https://device.harmonyos.com/cn/docs/ide/user-guides/hi3861-drivers-0000001058153433).
W
wenjun 已提交
71

N
NEEN 已提交
72
    ![](figures/en-us_image_0000001073388838.png)
W
wenjun 已提交
73

N
NEEN 已提交
74
3.  Open DevEco Device Tool and go to  **Projects**  \>  **Settings**.
W
wenjun 已提交
75

N
NEEN 已提交
76
    ![](figures/en-us_image_0000001078404538.png)
W
wenjun 已提交
77

D
duanxichao 已提交
78 79
4.  On the  **Partition Configuration**  tab page, modify the settings. In general cases, you can leave the fields at their default settings.
5.  On the  **hi3861**  tab page, set the programming options.
W
wenjun 已提交
80

N
NEEN 已提交
81 82 83
    -   **upload\_port**: Select the serial port number obtained in step  [2](#en-us_topic_0000001056563976_li848662117291).
    -   **upload\_protocol**: Select the programming protocol  **burn-serial**.
    -   **upload\_partitions**: Select the file to be programmed.  **hi3861\_app**  is selected by default.
W
wenjun 已提交
84

N
NEEN 已提交
85
    ![](figures/en-us_image_0000001078244328.png)
W
wenjun 已提交
86

N
NEEN 已提交
87
6.  When you finish modifying, click  **Save**  in the upper right corner.
D
duanxichao 已提交
88
7.  Open the project file. In the DevEco Device Tool window, go to  **PROJECT TASKS**  \>  **hi3861**  \>  **Upload**  to start programming.
W
wenjun 已提交
89

D
duanxichao 已提交
90
    ![](figures/en-us_image_0000001163569275.png)
W
wenjun 已提交
91

N
NEEN 已提交
92
8.  When the following information is displayed, press the RST button on the development board to restart it.
W
wenjun 已提交
93

N
NEEN 已提交
94
    ![](figures/en-us_image_0000001074285712.png)
W
wenjun 已提交
95

N
NEEN 已提交
96 97 98
9.  Start programming. When the following message is displayed, it indicates that the programming is successful.

    ![](figures/en-us_image_0000001074445364.png)
W
wenjun 已提交
99 100


M
mamingshuai 已提交
101
## Connecting WLAN Module to the Internet.<a name="section194671619167"></a>
W
wenjun 已提交
102

N
NEEN 已提交
103
After completing version building and burning, do as follows to connect the WLAN module to the Internet using AT commands.
W
wenjun 已提交
104

N
NEEN 已提交
105
1.  Click the icon of  **DevEco: Serial Monitor**  at the bottom of DevEco Studio to keep the connection between the Windows workstation and the WLAN module.
W
wenjun 已提交
106

N
NEEN 已提交
107 108
    **Figure  7**  Opening the DevEco serial port<a name="fig12489182991119"></a>  
    
N
NEEN 已提交
109

N
NEEN 已提交
110
    ![](figures/5-1.png)
W
wenjun 已提交
111

N
NEEN 已提交
112
2.  Reset the WLAN module. The message  **ready to OS start**  is displayed on the  **TERMINAL**  panel, indicating that the WLAN module is started successfully.
W
wenjun 已提交
113

N
NEEN 已提交
114
    **Figure  8**  Successful resetting of the WLAN module <a name="fig496084516332"></a>  
N
NEEN 已提交
115 116
    

N
NEEN 已提交
117
    ![](figures/6.png)
W
wenjun 已提交
118

N
NEEN 已提交
119
3.  Run the following AT commands in sequence via the DevEco serial port terminal to start the STA mode, connect to the specified AP, and enable Dynamic Host Configuration Protocol \(DHCP\).
W
wenjun 已提交
120 121

    ```
N
NEEN 已提交
122 123 124 125 126 127
    AT+STARTSTA                             # Start the STA mode.
    AT+SCAN                                 # Scan for available APs.
    AT+SCANRESULT                           # Display the scanning result.
    AT+CONN="SSID",,2,"PASSWORD"            # Connect to the specified AP. (SSID and PASSWORD represent the name and password of the hotspot to be connected, respectively.)
    AT+STASTAT                              # View the connection result.
    AT+DHCP=wlan0,1                         # Request the IP address of wlan0 from the AP using DHCP.
N
NEEN 已提交
128 129
    ```

N
NEEN 已提交
130
4.  Check whether the WLAN module is properly connected to the gateway, as shown in the following figure.
N
NEEN 已提交
131 132

    ```
N
NEEN 已提交
133 134
    AT+IFCFG                                # View the IP address assigned to an interface of the module.
    AT+PING=X.X.X.X                         # Check the connectivity between the module and the gateway. Replace X.X.X.X with the actual gateway address.
W
wenjun 已提交
135 136
    ```

N
NEEN 已提交
137
    **Figure  9**  Successful networking of the WLAN module<a name="fig1166371318339"></a>  
N
NEEN 已提交
138
    
W
wenjun 已提交
139

N
NEEN 已提交
140
    ![](figures/截图.png)
W
wenjun 已提交
141 142