developing-the-first-example-program-running-on-hi3861.md 7.3 KB
Newer Older
W
wenjun 已提交
1 2
# Developing the First Example Program Running on Hi3861<a name="EN-US_TOPIC_0000001053302600"></a>

Y
yangni 已提交
3
-   [Building](#section1736014117148)
[
[yang] 已提交
4 5 6 7
-   [Burning Images](#section1610612214150)
-   [Connecting WLAN Module to the Internet](#section168257461059)

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

Y
yangni 已提交
9
## Building<a name="section1736014117148"></a>
W
wenjun 已提交
10

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

N
NEEN 已提交
13
If the Linux environment is installed using Docker, perform the building by referring to  [Using Docker to Prepare the Build Environment](../get-code/acquiring-tools.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 20 21

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

    ![](figures/en-us_image_0000001055040538.png)

Y
yangni 已提交
22
    On the TERMINAL page, run the ssh command, for example,  **ssh** **_user_@_ipaddr_**, to connect to the Linux server.
W
wenjun 已提交
23 24 25 26 27 28

    **Figure  2**  TERMINAL page<a name="fig91165301546"></a>  
    

    ![](figures/en-us_image_0000001054599199.png)

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

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

    ![](figures/en-us_image_0000001078527924.png)

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

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

N
NEEN 已提交
41
    ![](figures/en-us_image_0000001123445553.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/en-us_image_0000001123361875.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/en-us_image_0000001078528390.png)
W
wenjun 已提交
60 61 62 63


## Burning Images<a name="section1610612214150"></a>

[
[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

[
[yang] 已提交
66
1.  Use a USB cable to connect the Windows workstation to the Hi3861 development board.
N
NEEN 已提交
67
2.  Download and install the  [USB-to-Serial port driver](http://www.wch-ic.com/downloads/CH341SER_EXE.html).
[
[yang] 已提交
68
3.  Query the COM port on the device manager, for example, CH340\(COM11\). The serial port integrates functions such as code burning, log printing, and AT commands execution.
W
wenjun 已提交
69

N
NEEN 已提交
70
    **Figure  7**  COM port of the device manager<a name="fig85905394917"></a>  
W
wenjun 已提交
71 72
    ![](figures/com-port-of-the-device-manager.png "com-port-of-the-device-manager")

[
[yang] 已提交
73
4.  Enter the burning configuration page.
W
wenjun 已提交
74

N
NEEN 已提交
75
    **Figure  8**  Basic configurations for image burning<a name="fig16939203111472"></a>  
W
wenjun 已提交
76 77 78 79
    

    ![](figures/en-us_image_0000001054877726.png)

[
[yang] 已提交
80
5.  Set basic parameters.
W
wenjun 已提交
81

[
[yang] 已提交
82
    1.  Set a proper baud rate. A higher baud rate indicates a faster burning speed. Here the default value  **921600**  is recommended.
W
wenjun 已提交
83
    2.  Select a data bit. The default value of  **Data bit**  for the WLAN module is  **8**.
N
NEEN 已提交
84
    3.  Select the version package path  **./out/wifiiot/Hi3861\_wifiiot\_app\_allinone.bin**  and  **Hiburn**  mode.
W
wenjun 已提交
85 86
    4.  Click  **Save**  to save configurations.

N
NEEN 已提交
87
    **Figure  9**  Baud rate and data bit configurations<a name="fig4315145184815"></a>  
W
wenjun 已提交
88 89
    ![](figures/baud-rate-and-data-bit-configurations.png "baud-rate-and-data-bit-configurations")

N
NEEN 已提交
90
    **Figure  10**  Path of the burning package<a name="fig105491550185115"></a>  
W
wenjun 已提交
91 92
    

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

[
[yang] 已提交
95
6.  On the DevEco, click  **Burn** ![](figures/en-us_image_0000001054443694.png)  and select the serial port  **COM11**.
W
wenjun 已提交
96

N
NEEN 已提交
97
    **Figure  11**  Starting a burning<a name="fig051518341529"></a>  
W
wenjun 已提交
98 99
    ![](figures/starting-a-burning.png "starting-a-burning")

[
[yang] 已提交
100
7.  After the serial port is selected,  **Connecting, please reset device...**  is shown below the  **TERMINAL**  tab, indicating that the module is in the to-be-burnt state.
W
wenjun 已提交
101

N
NEEN 已提交
102
    **Figure  12**  Burning process<a name="fig233565715549"></a>  
W
wenjun 已提交
103 104
    ![](figures/burning-process.png "burning-process")

[
[yang] 已提交
105
8.  Press the  **Reset**  key on the module to start burning.  **Execution Successful**  displayed below the  **TERMINAL**  tab indicates the burning is complete.
W
wenjun 已提交
106

N
NEEN 已提交
107
    **Figure  13**  Burning completed<a name="fig191921618564"></a>  
W
wenjun 已提交
108 109 110 111 112
    

    ![](figures/en-us_image_0000001054802306.png)


N
NEEN 已提交
113
## Connecting WLAN Module to the Internet<a name="section168257461059"></a>
W
wenjun 已提交
114

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

[
[yang] 已提交
117
1.  Keep Windows workstation connected to the WLAN module and click  **Serial port**  at the bottom of DevEco to view the configuration page.
W
wenjun 已提交
118

N
NEEN 已提交
119
    **Figure  14**  Opening the DevEco serial port<a name="fig12489182991119"></a>  
[
[yang] 已提交
120
    ![](figures/opening-the-deveco-serial-port.png "opening-the-deveco-serial-port")
W
wenjun 已提交
121

[
[yang] 已提交
122
2.  Select the serial port and set parameters. Enter the actual serial port number. Here the serial port number is  **COM11**; the default values of Baud rate, Data bit, and Stop bit are used;  **1**  is used as the end-line character since a valid input AT command must end with  **\\r\\n**.
N
NEEN 已提交
123

N
NEEN 已提交
124
    **Figure  15**  Setting serial port parameters<a name="fig192312048131213"></a>  
[
[yang] 已提交
125
    ![](figures/setting-serial-port-parameters.png "setting-serial-port-parameters")
W
wenjun 已提交
126 127 128

3.  Reset the WLAN module. The message  **ready to OS start**  is displayed on the terminal page, indicating that the WLAN module is started successfully.

N
NEEN 已提交
129
    **Figure  16**  Successful resetting of the WLAN module <a name="fig496084516332"></a>  
N
NEEN 已提交
130 131
    

[
[yang] 已提交
132
    ![](figures/3.png)
W
wenjun 已提交
133

[
[yang] 已提交
134
4.  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 已提交
135 136

    ```
N
NEEN 已提交
137 138 139 140 141 142
    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 已提交
143 144 145 146 147
    ```

5.  Check whether the WLAN module is properly connected to the gateway, as shown in the following figure.

    ```
N
NEEN 已提交
148 149
    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 已提交
150 151
    ```

N
NEEN 已提交
152
    **Figure  17**  Successful networking of the WLAN module<a name="fig1166371318339"></a>  
N
NEEN 已提交
153
    
W
wenjun 已提交
154

[
[yang] 已提交
155
    ![](figures/4.png)
W
wenjun 已提交
156 157