

# 建立多點傳送群組以及將裝置新增至群組
<a name="lorawan-create-multicast-groups"></a>

您可以使用主控台或 CLI 建立多點傳送群組。如果是首次建立多點傳送群組，建議您使用主控台來新增多點傳送群組。您可以使用 CLI 來管理多點傳送群組，並在群組中新增或移除裝置。

在與新增的終端裝置交換訊號後，AWS IoT Core for LoRaWAN 會使用終端裝置建立共用金鑰，並設定資料傳輸的參數。

## 必要條件
<a name="lorawan-create-multicast-groups-prereq"></a>

在可以建立多點傳送群組以及將裝置新增至群組之前：
+ 透過指定 FUOTA 組態參數 `GenAppKey` 和 `FPorts`，準備好多點傳送和 FUOTA 設定的裝置。如需詳細資訊，請參閱[準備好用於多點傳送和 FUOTA 組態的裝置](lorawan-prepare-devices-multicast.md)。
+ 檢查裝置是否支援 B 類或 C 類操作模式。您可以依裝置支援的裝置類別，選擇啟用了 **Supports Class B** (支援 B 類) 或 **Supports Class C** (支援 C 類)模式的裝置設定檔，或者同時啟用了這兩種模式的設定檔。如需有關裝置設定檔的詳細資訊，請參閱 [將設定檔新增至 AWS IoT Core for LoRaWAN](lorawan-define-profiles.md)。

  在多點傳送工作階段開始時，B 類或 C 類分發時段會用來將下行訊息傳送至群組中的裝置上。

## 使用主控台建立多點傳送群組
<a name="lorawan-create-multicast-groups-console"></a>

若要使用主控台建立多點傳送群組，請前往 AWS IoT 主控台的 [Multicast groups](https://console.aws.amazon.com/iot/home#/wireless/multicastGroups) (多點傳送群組) 頁面，然後選擇 **Create multicast group** (建立多點傳送群組)。

1. 

**建立多點傳送群組**

   若要建立多點傳送群組，請指定群組的多點傳送屬性和標籤。

   1. 

**指定多點傳送屬性**  
若要指定多點傳送屬性，請輸入多點傳送群組的以下資訊。
      + **名稱**：輸入多點傳送群組的唯一名稱。名稱僅可包含字母、數字、連字號和底線。不可含有空格。
      + **描述**：可以選擇為多點傳送群組提供描述。描述的長度最高可達 2,048 個字元。

   1. 

**多點傳送群組的標籤**  
可以選擇提供任何鍵/值對作為多點傳送群組的**標籤**。若要繼續建立多點傳送群組，請選擇 **Next** (下一步)。

1. 

**將裝置新增至多點傳送群組**

   可以將個別裝置或裝置群組新增至多點傳送群組。若要新增裝置：

   1. 

**指定 RFRegion**  
指定 **RFRegion** 或多點傳送群組的頻帶。多點傳送群組的 **RFRegion** 必須符合新增至多點傳送群組的裝置 **RFRegion**。如需有關 **RFRegion** 的詳細資訊，請參閱 [考慮為閘道和裝置連線選取 LoRa 頻帶](lorawan-rfregion-permissions.md#lorawan-frequency-bands)。

   1. 

**選取多點傳送裝置類別**  
選擇是否讓多點傳送群組中的裝置在多點傳送工作階段開始時切換至 B 類或 C 類模式。B 類工作階段可以在一般下行槽上接收下行訊息，而 C 類工作階段則可以隨時接收下行訊息。

   1. 

**選擇要新增至群組的裝置。**  
選擇要個別還是大量新增裝置至多點傳送群組。
      + 若要個別新增裝置，請輸入要新增至群組的各裝置無線裝置 ID。
      + 若要大量新增裝置，可以依據裝置設定檔或標籤來篩選要新增的裝置。若要採用裝置設定檔，可以新增具有可支援 B 類或 C 類或這兩類的裝置設定檔的裝置。

   1. 若要建立多點傳送群組，請選擇 **Create** (建立)。

      多點傳送群組詳細資料和新增的裝置會出現在群組中。如需有關多點傳送群組和裝置狀態的資訊，以及疑難排解任何問題的相關資訊，請參閱 [監控及疑難排解多點傳送群組和群組中裝置的狀態](lorawan-multicast-status.md)。

在建立多點傳送群組之後，可以選擇 **Action** (動作)，以編輯、刪除或新增裝置至多點傳送群組。在新增裝置後，便可排定工作階段，將下行承載傳送至群組中的裝置。

## 使用 API 來建立多點傳送群組
<a name="lorawan-create-multicast-groups-api"></a>

若要使用 API 建立多點傳送群組，並將裝置新增至群組：

1. 

**建立多點傳送群組**

   若要建立多點傳送群組，請使用 [https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_CreateMulticastGroup.html](https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_CreateMulticastGroup.html) API 操作或 [https://docs.aws.amazon.com/cli/latest/reference/iotwireless/create-multicast-group.html](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/create-multicast-group.html) CLI 命令。您可以提供 `input.json` 檔案作為 `create-multicast-group` 命令的輸入。

   ```
   aws iotwireless create-multicast-group \
       --cli-input-json file://input.json
   ```

   其中：

   **input.json 的內容**

   ```
   {   
      "Description": "Multicast group to send downlink payload and perform FUOTA.",
      "LoRaWAN": { 
         "DlClass": "ClassB",
         "RfRegion": "US915"
      },
      "Name": "MC_group_FUOTA"  
   }
   ```

   您建立多點傳送群組之後，便可使用以下 API 操作或 CLI 命令來更新、刪除或取得多點傳送群組的相關資訊。
   + [https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_UpdateMulticastGroup](https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_UpdateMulticastGroup) 或 [https://docs.aws.amazon.com/cli/latest/reference/iotwireless/update-multicast-group.html](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/update-multicast-group.html) 
   + [https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_UpdateMulticastGroup](https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_UpdateMulticastGroup) 或 [https://docs.aws.amazon.com/cli/latest/reference/iotwireless/get-multicast-group.html](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/get-multicast-group.html) 
   + [https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_ListMulticastGroups](https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_ListMulticastGroups) 或 [https://docs.aws.amazon.com/cli/latest/reference/iotwireless/list-multicast-groups.html](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/list-multicast-groups.html) 
   + [https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_DeleteMulticastGroup](https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_DeleteMulticastGroup) 或 [https://docs.aws.amazon.com/cli/latest/reference/iotwireless/delete-multicast-group.html](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/delete-multicast-group.html) 

1. 

**將裝置新增至多點傳送群組**

   可以個別或大量新增裝置至多點傳送群組。
   + 若要大量新增裝置至多點傳送群組，請使用 [https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_StartBulkAssociateWirelessDeviceWithMulticastGroup.html](https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_StartBulkAssociateWirelessDeviceWithMulticastGroup.html) API 操作或 [https://docs.aws.amazon.com/cli/latest/reference/iotwireless/start-bulk-associate-wireless-device-with-multicast-group.html](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/start-bulk-associate-wireless-device-with-multicast-group.html) CLI 命令。若要篩選要大量關聯至多點傳送群組的裝置，請提供查詢字串。以下內容會顯示如何新增裝置群組，該群組具有一組與特定 ID 連結的裝置設定檔。

     ```
     aws iotwireless start-bulk-associate-wireless-device-with-multicast-group \
         --id "12abd34e-5f67-89c2-9293-593b1bd862e0" \
         --cli-input-json file://input.json
     ```

     其中：

     **input.json 的內容**

     ```
     {
          "QueryString": "DeviceProfileName: MyWirelessDevice AND DeviceProfileId: d6d8ef8e-7045-496d-b3f4-ebcaa1d564bf",
          "Tags": [
             {
                 "Key": "Multicast",
                 "Value": "ClassB"
             }
         ]
     }
     ```

     此處，`multicast-groups/d6d8ef8e-7045-496d-b3f4-ebcaa1d564bf/bulk` 是用來將裝置與群組建立關聯的 URL。
   + 若要個別新增裝置至多點傳送群組，請使用 [https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_AssociateWirelessDeviceWithMulticastGroup.html](https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_AssociateWirelessDeviceWithMulticastGroup.html) API 操作或 [https://docs.aws.amazon.com/cli/latest/reference/iotwireless/associate-wireless-device-with-multicast-group.html](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/associate-wireless-device-with-multicast-group.html) CLI 。為要新增至群組的每個裝置提供無線裝置 ID。

     ```
     aws iotwireless associate-wireless-device-with-multicast-group \
         --id "12abd34e-5f67-89c2-9293-593b1bd862e0" \
         --wireless-device-id "ab0c23d3-b001-45ef-6a01-2bc3de4f5333"
     ```

   在建立多點傳送群組之後，便可使用以下 API 操作或 CLI 命令來取得多點傳送群組的相關資訊，或取消關聯裝置。
   + [https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_DisassociateWirelessDeviceFromMulticastGroup.html](https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_DisassociateWirelessDeviceFromMulticastGroup.html) 或 [https://docs.aws.amazon.com/cli/latest/reference/iotwireless/disassociate-wireless-device-from-multicast-group.html](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/disassociate-wireless-device-from-multicast-group.html) 
   + [https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_StartBulkDisassociateWirelessDeviceFromMulticastGroup.html](https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_StartBulkDisassociateWirelessDeviceFromMulticastGroup.html) 或 [https://docs.aws.amazon.com/cli/latest/reference/iotwireless/start-bulk-disassociate-wireless-device-from-multicast-group.html](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/start-bulk-disassociate-wireless-device-from-multicast-group.html) 
   + [https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_ListWirelessDevices](https://docs.aws.amazon.com/iot-wireless/2020-11-22/apireference/API_ListWirelessDevices) 或 [https://docs.aws.amazon.com/cli/latest/reference/iotwireless/list-wireless-devices.html](https://docs.aws.amazon.com/cli/latest/reference/iotwireless/list-wireless-devices.html) 
**注意**  
`ListWirelessDevices` API 操作可用來列出一般無線裝置，以及與多點傳送群組或 FUOTA 任務相關聯的無線裝置。  
若要列出與多點傳送群組相關聯的無線裝置，請使用 `ListWirelessDevices` API 操作搭配 `MulticastGroupID` 作為篩選條件。
若要列出與 FUOTA 任務相關聯的無線裝置，請使用 `ListWirelessDevices` API 操作搭配 `FuotaTaskID` 作為篩選條件。

## 後續步驟
<a name="lorawan-create-multicast-next-steps"></a>

在建立多點傳送群組並新增裝置之後，便可繼續新增裝置，並監控多點傳送群組和裝置的狀態。如果已成功將裝置新增至群組中，則可以設定並排定傳送下行訊息至裝置。在傳送下行訊息之前，裝置狀態必須為 **Multicast setup ready** (多點傳送設定就緒)。在排定下行訊息後，該狀態會變更為 **Session attempting** (工作階段嘗試中)。如需詳細資訊，請參閱[排定將下行訊息傳送至多點傳送群組中的裝置](lorawan-multicast-schedule-downlink.md)。

如果要更新多點傳送群組中裝置的韌體，可以使用 AWS IoT Core for LoRaWAN 執行無線韌體更新 (FUOTA)。如需詳細資訊，請參閱[AWS IoT Core for LoRaWAN 裝置的無線韌體更新 (FUOTA)](lorawan-mc-fuota-overview.md)。

如果尚未新增裝置，或是在多點傳送群組或裝置狀態中看到錯誤訊息，將滑鼠游標移至錯誤訊息上方，即可取得更多資訊並解決問題。若仍能看到錯誤訊息，且需要如何疑難排解和解決問題的詳細資訊，請參閱 [監控及疑難排解多點傳送群組和群組中裝置的狀態](lorawan-multicast-status.md)。