設定網路功能Configure networking

在您宣告自己的 Azure Sphere 裝置之後,請為該裝置設定網路功能,使其能夠從 Azure Sphere 安全性服務接收無線 (OTA) 更新,並可以與服務 (例如 Azure IoT 中樞) 通訊。After you claim your Azure Sphere device, configure it for networking so that it can receive over-the-air (OTA) updates from the Azure Sphere Security Service and communicate with services such as an Azure IoT Hub.

設定網路功能之前,您必須:Before you can configure networking, you must:

重要

本主題描述如何將 Azure Sphere 裝置連線至 Wi-Fi 網路。This topic describes how to connect your Azure Sphere device to a Wi-Fi network. 如果您的裝置支援不同的網路功能機制且不支援 Wi-Fi,請使用該機制將它連線至網際網路,並繼續接收裝置更新If your device supports a different networking mechanism and does not support Wi-Fi, connect it to the internet using that mechanism and proceed to Receive device update.

在您的 Azure Sphere 裝置上設定 Wi-FiSet up Wi-Fi on your Azure Sphere device

請依照下列步驟在 Azure Sphere 裝置上設定 Wi-Fi:Follow these steps to configure Wi-Fi on your Azure Sphere device:

  1. 透過 USB 將您的 Azure Sphere 面板連接至電腦。Connect your Azure Sphere board to your PC over USB.

  2. 開啟 Azure Sphere 開發人員命令提示字元。Open an Azure Sphere Developer Command Prompt.

  3. 如果網路環境需要裝置的 MAC 位址,請先註冊該位址。Register the device's MAC address if your network environment requires it. 使用下列命令來取得 MAC 位址,然後根據適用於您環境的程序註冊它:Use the following command to get the MAC address, and then register it according to the procedure for your environment:

    azsphere device wifi show-status

  4. 使用 azsphere device wifi add 命令,將 Wi-Fi 網路新增至裝置,如下所示:Add your Wi-Fi network to the device by using the azsphere device wifi add command as follows:

    azsphere device wifi add --ssid <yourSSID> --key <yourNetworkKey>

    將 <yourSSID> 取代為您的網路名稱,並將 <yourNetworkKey> 取代為您的 WPA/WPA2 金鑰。Replace <yourSSID> with the name of your network and <yourNetworkKey> with your WPA/WPA2 key. Azure Sphere 裝置不支援 WEP,也無法連線至隱藏的 SSID。Azure Sphere devices do not support WEP, nor can they connect to hidden SSIDs. 網路 SSID 會區分大小寫。Network SSIDs are case-sensitive. 例如︰For example:

    azsphere device wifi add --ssid My5GNetwork --key secretnetworkkey

    若要新增開放式網路,請省略 --key 旗標。To add an open network, omit the --key flag.

    如果您的網路 SSID 或金鑰包含內嵌空格,請以引號括住 SSID 或金鑰。If your network SSID or key has embedded spaces, enclose the SSID or key in quotation marks. 如果 SSID 或金鑰包含引號,請使用反斜線來跳脫引號。If the SSID or key includes a quotation mark, use a backslash to escape the quotation mark. 如果反斜線是值的一部分,則不需要逸出。Backslashes do not require escape if they are part of a value. 例如︰For example:

    azsphere device wifi add --ssid "New SSID" --key "key \"value\" with quotes"

    面板上的網路功能通常會需要幾秒的時間來設置,但也可能需要更長的時間,視您的網路環境而定。It typically takes several seconds for networking to be ready on the board, but might take longer, depending on your network environment.

注意

在 Azure Sphere 裝置初次連線至網際網路,並經過 24 小時的時間間隔之後,該裝置會在每次開機時檢查軟體更新。The Azure Sphere device checks for software updates each time it boots, when it initially connects to the internet, and at 24-hour intervals thereafter. 如果有 Azure Sphere OS 的更新可供使用,下載及安裝更新最多可能需要 15 分鐘的時間,其間可能會重新啟動裝置。If an Azure Sphere OS update is available, download and installation could take as much as 15 minutes and might cause the device to restart.

  1. 使用 azsphere device wifi show-status 命令可檢查連線狀態。Use the azsphere device wifi show-status command to check the status of the connection. 在更新期間,azsphere device wifi show-status 命令可能會暫時顯示未知的組態狀態。During update, the azsphere device wifi show-status command may temporarily show an unknown configuration state. 下列範例會顯示 WPA2 成功安全連線的結果:The following example shows successful results for a secure WPA2 connection:

    azsphere device wifi show-status
    
    SSID : NETGEAR21  
    Configuration state : enabled  
    Connection state : connected  
    Security state : psk  
    Frequency : 2442  
    Mode : station  
    Key management : WPA2-PSK  
    WPA State : COMPLETED  
    IP Address : 192.168.1.15  
    MAC Address : 52:cf:ff:3a:76:1b
    Command completed successfully in 00:00:01.3976308.
    

azsphere device wifi 命令會支援其他多個選項。The azsphere device wifi command supports several additional options. 輸入 azsphere device wifi 可取得完整清單,或輸入 azsphere device wifi option --help 來取得個別選項的說明。Type azsphere device wifi for a complete list, or azsphere device wifi option --help for help on an individual option.

如果遇到 Wi-Fi 問題,請先確定您的 Wi-Fi 網路使用 802.11b/g/n;Azure Sphere 裝置不支援 802.11a。If you encounter Wi-Fi problems, first ensure that your Wi-Fi network uses 802.11b/g/n; Azure Sphere devices do not support 802.11a.

接收裝置更新Receive device update

當網路功能開始可以使用時,裝置會檢查適用於 Azure Sphere 作業系統 (OS) 和目前應用程式 (如果有的話) 的無線 (OTA) 更新。When networking initially becomes available, the device checks for over-the-air (OTA) updates for the Azure Sphere operating system (OS) and the current application (if one exists). 如果有更新可用,下載應該會在 15 到 20 分鐘內完成。If updates are available, download should complete within 15-20 minutes.

若要檢查更新狀態,可在 Azure Sphere 開發人員命令提示字元中輸入下列命令:To check on update status, type the following command in an Azure Sphere Developer Command Prompt:

azsphere device show-ota-status

注意

Azure Sphere OS 更新是分段程序,此期間可能少於 15 分鐘,也可能更久,視網際網路連線速度而定。Azure Sphere OS update is a staged process over a period that may be less than 15 minutes but can be longer depending on the internet connectivity. 在各階段之間,當下一組更新下載完成時,面板會機能性地顯示,但在更新期間,您應預期面板每次會有數分鐘無回應的情況。Between stages, the board will appear functional while the next group of updates is downloaded, but during the update you should expect the board to be unresponsive for several minutes at a time.

後續步驟Next Steps