Amazon IoT Wireless examples using Amazon CLI - Amazon Command Line Interface
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.

Amazon IoT Wireless examples using Amazon CLI

The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with Amazon IoT Wireless.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use associate-aws-account-with-partner-account.

Amazon CLI

To associate a partner account with your Amazon account

The following associate-aws-account-with-partner-account example associates the following Sidewalk account credentials with your Amazon account.

aws iotwireless associate-aws-account-with-partner-account \ --sidewalk AmazonId="12345678901234",AppServerPrivateKey="a123b45c6d78e9f012a34cd5e6a7890b12c3d45e6f78a1b234c56d7e890a1234"

Output:

{ "Sidewalk": { "AmazonId": "12345678901234", "AppServerPrivateKey": "a123b45c6d78e9f012a34cd5e6a7890b12c3d45e6f78a1b234c56d7e890a1234" } }

For more information, see Amazon Sidewalk Integration for Amazon IoT Core in the Amazon IoT Developers Guide.

The following code example shows how to use associate-wireless-device-with-thing.

Amazon CLI

To associate a thing to a wireless device

The following associate-wireless-device-with-thing example associates a thing to your wireless device that has the specified ID.

aws iotwireless associate-wireless-device-with-thing \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d" \ --thing-arn "arn:aws:iot:us-east-1:123456789012:thing/MyIoTWirelessThing"

This command produces no output.

For more information, see Add your gateways and wireless devices to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use associate-wireless-gateway-with-certificate.

Amazon CLI

To associate the certificate with the wireless gateway

The following associate-wireless-gateway-with-certificate associates a wireless gateway with a certificate.

aws iotwireless associate-wireless-gateway-with-certificate \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d" \ --iot-certificate-id "a123b45c6d78e9f012a34cd5e6a7890b12c3d45e6f78a1b234c56d7e890a1234"

Output:

{ "IotCertificateId": "a123b45c6d78e9f012a34cd5e6a7890b12c3d45e6f78a1b234c56d7e890a1234" }

For more information, see Add your gateways and wireless devices to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use associate-wireless-gateway-with-thing.

Amazon CLI

To associate a thing to a wireless gateway

The following associate-wireless-gateway-with-thing example associates a thing to a wireless gateway.

aws iotwireless associate-wireless-gateway-with-thing \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d" \ --thing-arn "arn:aws:iot:us-east-1:123456789012:thing/MyIoTWirelessThing"

This command produces no output.

For more information, see Add your gateways and wireless devices to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use create-destination.

Amazon CLI

To create an IoT wireless destination

The following create-destination example creates a destination for mapping a device message to an Amazon IoT rule. Before you run this command, you must have created an IAM role that gives Amazon IoT Core for LoRaWAN the permissions necessary to send data to the Amazon IoT rule.

aws iotwireless create-destination \ --name IoTWirelessDestination \ --expression-type RuleName \ --expression IoTWirelessRule \ --role-arn arn:aws:iam::123456789012:role/IoTWirelessDestinationRole

Output:

{ "Arn": "arn:aws:iotwireless:us-east-1:123456789012:Destination/IoTWirelessDestination", "Name": "IoTWirelessDestination" }

For more information, see Add destinations to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use create-device-profile.

Amazon CLI

To create a new device profile

The following create-device-profile example creates a new IoT wireless device profile.

aws iotwireless create-device-profile

Output:

{ "Arn": "arn:aws:iotwireless:us-east-1:123456789012:DeviceProfile/12345678-a1b2-3c45-67d8-e90fa1b2c34d", "Id": "12345678-a1b2-3c45-67d8-e90fa1b2c34d" }

For more information, see Add profiles to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use create-service-profile.

Amazon CLI

To create a new service profile

The following create-service-profile example creates a new IoT wireless service profile.

aws iotwireless create-service-profile

Output:

{ "Arn": "arn:aws:iotwireless:us-east-1:123456789012:ServiceProfile/12345678-a1b2-3c45-67d8-e90fa1b2c34d", "Id": "12345678-a1b2-3c45-67d8-e90fa1b2c34d" }

For more information, see Add profiles to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use create-wireless-device.

Amazon CLI

To create an IoT wireless device

The following create-wireless-device example creates a wireless device resource of the type LoRaWAN.

aws iotwireless create-wireless-device \ --cli-input-json file://input.json

Contents of input.json:

{ "Description": "My LoRaWAN wireless device" "DestinationName": "IoTWirelessDestination" "LoRaWAN": { "DeviceProfileId": "ab0c23d3-b001-45ef-6a01-2bc3de4f5333", "ServiceProfileId": "fe98dc76-cd12-001e-2d34-5550432da100", "OtaaV1_1": { "AppKey": "3f4ca100e2fc675ea123f4eb12c4a012", "JoinEui": "b4c231a359bc2e3d", "NwkKey": "01c3f004a2d6efffe32c4eda14bcd2b4" }, "DevEui": "ac12efc654d23fc2" }, "Name": "SampleIoTWirelessThing" "Type": LoRaWAN }

Output:

{ "Arn": "arn:aws:iotwireless:us-east-1:123456789012:WirelessDevice/1ffd32c8-8130-4194-96df-622f072a315f", "Id": "1ffd32c8-8130-4194-96df-622f072a315f" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use create-wireless-gateway-task-definition.

Amazon CLI

To create a wireless gateway task definition

The following create-wireless-gateway-task-definition automatically creates tasks using this task definition for all gateways with the specified current version.

aws iotwireless create-wireless-gateway-task-definition \ --cli-input-json file://input.json

Contents of input.json:

{ "AutoCreateTasks": true, "Name": "TestAutoUpdate", "Update":{ "UpdateDataSource" : "s3://cupsalphagafirmwarebin/station", "UpdateDataRole" : "arn:aws:iam::001234567890:role/SDK_Test_Role", "LoRaWAN" :{ "CurrentVersion" :{ "PackageVersion" : "1.0.0", "Station" : "2.0.5", "Model" : "linux" }, "UpdateVersion" :{ "PackageVersion" : "1.0.1", "Station" : "2.0.5", "Model" : "minihub" } } } }

Output:

{ "Id": "b7d3baad-25c7-35e7-a4e1-1683a0d61da9" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use create-wireless-gateway-task.

Amazon CLI

To create the task for a wireless gateway

The following create-wireless-gateway-task example creates a task for a wireless gateway.

aws iotwireless create-wireless-gateway-task \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d" \ --wireless-gateway-task-definition-id "aa000102-0304-b0cd-ef56-a1b23cde456a"

Output:

{ "WirelessGatewayTaskDefinitionId": "aa204003-0604-30fb-ac82-a4f95aaf450a", "Status": "Success" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use create-wireless-gateway.

Amazon CLI

To create a wireless gateway

The following create-wireless-gateway example creates a wireless LoRaWAN device gateway.

aws iotwireless create-wireless-gateway \ --lorawan GatewayEui="a1b2c3d4567890ab",RfRegion="US915" \ --name "myFirstLoRaWANGateway" \ --description "Using my first LoRaWAN gateway"

Output:

{ "Arn": "arn:aws:iotwireless:us-east-1:123456789012:WirelessGateway/12345678-a1b2-3c45-67d8-e90fa1b2c34d", "Id": "12345678-a1b2-3c45-67d8-e90fa1b2c34d" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use delete-destination.

Amazon CLI

To delete an IoT wireless destination

The following delete-destination example deletes the wireless destination resource with the name IoTWirelessDestination that you created.

aws iotwireless delete-destination \ --name "IoTWirelessDestination"

This command produces no output.

For more information, see Add destinations to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use delete-device-profile.

Amazon CLI

To delete a device profile

The following delete-device-profile example deletes a device profile with the specified ID that you created.

aws iotwireless delete-device-profile \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

This command produces no output.

For more information, see Add profiles to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use delete-service-profile.

Amazon CLI

To delete a service profile

The following delete-service-profile example deletes a service profile with the specified ID that you created.

aws iotwireless delete-service-profile \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

This command produces no output.

For more information, see Add profiles to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use delete-wireless-device.

Amazon CLI

To delete a wireless device

The following delete-wireless-device example deletes a wireless device that has the specified ID.

aws iotwireless delete-wireless-device \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

This command produces no output.

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use delete-wireless-gateway-task-definition.

Amazon CLI

To delete a wireless gateway task definition

The following delete-wireless-gateway-task-definition example deletes the wireless gateway task definition that you created with the following ID.

aws iotwireless delete-wireless-gateway-task-definition \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

This command produces no output.

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use delete-wireless-gateway-task.

Amazon CLI

To delete a wireless gateway task

The following delete-wireless-gateway-task example deletes the wireless gateway task that has the specified ID.

aws iotwireless delete-wireless-gateway-task \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

This command produces no output.

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use delete-wireless-gateway.

Amazon CLI

To delete a wireless gateway

The following delete-wireless-gateway example deletes a wireless gateway that has the specified ID.

aws iotwireless delete-wireless-gateway \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

This command produces no output.

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use disassociate-aws-account-from-partner-account.

Amazon CLI

To disassociate the partner account from the Amazon account

The following disassociate-aws-account-from-partner-account example disassociates a partner account from your currently associated Amazon account.

aws iotwireless disassociate-aws-account-from-partner-account \ --partner-account-id "12345678901234" \ --partner-type "Sidewalk"

This command produces no output.

For more information, see Add your gateways and wireless devices to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use disassociate-wireless-device-from-thing.

Amazon CLI

To disassociate the thing from the wireless device

The following disassociate-wireless-device-from-thing example disassociates a wireless device from its currently associated thing.

aws iotwireless disassociate-wireless-device-from-thing \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

This command produces no output.

For more information, see Add your gateways and wireless devices to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use disassociate-wireless-gateway-from-certificate.

Amazon CLI

To disassociate the certificate from the wireless gateway

The following disassociate-wireless-gateway-from-certificate disassociates a wireless gateway from its currently associated certificate.

aws iotwireless disassociate-wireless-gateway-from-certificate \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

This command produces no output.

For more information, see Add your gateways and wireless devices to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use disassociate-wireless-gateway-from-thing.

Amazon CLI

To disassociate the thing from the wireless gateway

The following disassociate-wireless-gateway-from-thing example disassociates a wireless gateway from its currently associated thing.

aws iotwireless disassociate-wireless-gateway-from-thing \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

This command produces no output.

For more information, see Add your gateways and wireless devices to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-destination.

Amazon CLI

To get information about an IoT wireless destination

The following get-destination example gets information about the destination resource with the name IoTWirelessDestination that you created.

aws iotwireless get-destination \ --name "IoTWirelessDestination"

Output:

{ "Arn": "arn:aws:iotwireless:us-east-1:123456789012:Destination/IoTWirelessDestination", "Name": "IoTWirelessDestination", "Expression": "IoTWirelessRule", "ExpressionType": "RuleName", "RoleArn": "arn:aws:iam::123456789012:role/IoTWirelessDestinationRole" }

For more information, see Add destinations to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

  • For API details, see GetDestination in Amazon CLI Command Reference.

The following code example shows how to use get-device-profile.

Amazon CLI

To get information about a device profile

The following get-device-profile example gets information about the device profile with the specified ID that you created.

aws iotwireless get-device-profile \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

Output:

{ "Arn": "arn:aws:iotwireless:us-east-1:123456789012:DeviceProfile/12345678-a1b2-3c45-67d8-e90fa1b2c34d", "Id": "12345678-a1b2-3c45-67d8-e90fa1b2c34d", "LoRaWAN": { "MacVersion": "1.0.3", "MaxDutyCycle": 10, "Supports32BitFCnt": false, "RegParamsRevision": "RP002-1.0.1", "SupportsJoin": true, "RfRegion": "US915", "MaxEirp": 13, "SupportsClassB": false, "SupportsClassC": false } }

For more information, see Add profiles to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-partner-account.

Amazon CLI

To get the partner account information

The following get-partner-account example gets information about your Sidewalk account that has the following ID.

aws iotwireless get-partner-account \ --partner-account-id "12345678901234" \ --partner-type "Sidewalk"

Output:

{ "Sidewalk": { "AmazonId": "12345678901234", "Fingerprint": "a123b45c6d78e9f012a34cd5e6a7890b12c3d45e6f78a1b234c56d7e890a1234" }, "AccountLinked": false }

For more information, see Amazon Sidewalk Integration for Amazon IoT Core in the Amazon IoT Developers Guide.

The following code example shows how to use get-service-endpoint.

Amazon CLI

To get the service endpoint

The following get-service-endpoint example gets the account-specific endpoint for CUPS protocol.

aws iotwireless get-service-endpoint

Output:

{ "ServiceType": "CUPS", "ServiceEndpoint": "https://A1RMKZ37ACAGOT.cups.lorawan.us-east-1.amazonaws.com:443", "ServerTrust": "-----BEGIN CERTIFICATE-----\n MIIESTCCAzGgAwIBAgITBn+UV4WH6Kx33rJTMlu8mYtWDTANBgkqhkiG9w0BAQsF\n ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n b24gUm9vdCBDQSAxMB4XDTE1MTAyMjAwMDAwMFoXDTI1MTAxOTAwMDAwMFowRjEL\n MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEVMBMGA1UECxMMU2VydmVyIENB\n IDFCMQ8wDQYDVQQDEwZBbWF6b24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK\n AoIBAQDCThZn3c68asg3Wuw6MLAd5tES6BIoSMzoKcG5blPVo+sDORrMd4f2AbnZ\n cMzPa43j4wNxhplty6aUKk4T1qe9BOwKFjwK6zmxxLVYo7bHViXsPlJ6qOMpFge5\n blDP+18x+B26A0piiQOuPkfyDyeR4xQghfj66Yo19V+emU3nazfvpFA+ROz6WoVm\n B5x+F2pV8xeKNR7u6azDdU5YVX1TawprmxRC1+WsAYmz6qP+z8ArDITC2FMVy2fw\n 0IjKOtEXc/VfmtTFch5+AfGYMGMqqvJ6LcXiAhqG5TI+Dr0RtM88k+8XUBCeQ8IG\n KuANaL7TiItKZYxK1MMuTJtV9IblAgMBAAGjggE7MIIBNzASBgNVHRMBAf8ECDAG\n AQH/AgEAMA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUWaRmBlKge5WSPKOUByeW\n dFv5PdAwHwYDVR0jBBgwFoAUhBjMhTTsvAyUlC4IWZzHshBOCggwewYIKwYBBQUH\n AQEEbzBtMC8GCCsGAQUFBzABhiNodHRwOi8vb2NzcC5yb290Y2ExLmFtYXpvbnRy\n dXN0LmNvbTA6BggrBgEFBQcwAoYuaHR0cDovL2NydC5yb290Y2ExLmFtYXpvbnRy\n dXN0LmNvbS9yb290Y2ExLmNlcjA/BgNVHR8EODA2MDSgMqAwhi5odHRwOi8vY3Js\n LnJvb3RjYTEuYW1hem9udHJ1c3QuY29tL3Jvb3RjYTEuY3JsMBMGA1UdIAQMMAow\n CAYGZ4EMAQIBMA0GCSqGSIb3DQEBCwUAA4IBAQCFkr41u3nPo4FCHOTjY3NTOVI1\n 59Gt/a6ZiqyJEi+752+a1U5y6iAwYfmXss2lJwJFqMp2PphKg5625kXg8kP2CN5t\n 6G7bMQcT8C8xDZNtYTd7WPD8UZiRKAJPBXa30/AbwuZe0GaFEQ8ugcYQgSn+IGBI\n 8/LwhBNTZTUVEWuCUUBVV18YtbAiPq3yXqMB48Oz+ctBWuZSkbvkNodPLamkB2g1\n upRyzQ7qDn1X8nn8N8V7YJ6y68AtkHcNSRAnpTitxBKjtKPISLMVCx7i4hncxHZS\n yLyKQXhw2W2Xs0qLeC1etA+jTGDK4UfLeC0SF7FSi8o5LL21L8IzApar2pR/\n -----END CERTIFICATE-----\n" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-service-profile.

Amazon CLI

To get information about a service profile

The following get-service-profile example gets information about the service profile with the specified ID that you created.

aws iotwireless get-service-profile \ --id "12345678-a1b2-3c45-67d8-e90fa1b2c34d"

Output:

{ "Arn": "arn:aws:iotwireless:us-east-1:651419225604:ServiceProfile/538185bb-d7e7-4b95-96a0-c51aa4a5b9a0", "Id": "12345678-a1b2-3c45-67d8-e90fa1b2c34d", "LoRaWAN": { "HrAllowed": false, "NwkGeoLoc": false, "DrMax": 15, "UlBucketSize": 4096, "PrAllowed": false, "ReportDevStatusBattery": false, "DrMin": 0, "DlRate": 60, "AddGwMetadata": false, "ReportDevStatusMargin": false, "MinGwDiversity": 1, "RaAllowed": false, "DlBucketSize": 4096, "DevStatusReqFreq": 24, "TargetPer": 5, "UlRate": 60 } }

For more information, see Add profiles to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-wireless-device-statistics.

Amazon CLI

To get operating information about a wireless device

The following get-wireless-device-statistics example gets operating information about a wireless device.

aws iotwireless get-wireless-device-statistics \ --wireless-device-id "1ffd32c8-8130-4194-96df-622f072a315f"

Output:

{ "WirelessDeviceId": "1ffd32c8-8130-4194-96df-622f072a315f" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-wireless-device.

Amazon CLI

To get information about the wireless device

The following get-wireless-device example lists the available widgets in your Amazon account.

aws iotwireless get-wireless-device \ --identifier "1ffd32c8-8130-4194-96df-622f072a315f" \ --identifier-type WirelessDeviceID

Output:

{ "Name": "myLoRaWANDevice", "ThingArn": "arn:aws:iot:us-east-1:123456789012:thing/44b87eb4-9bce-423d-b5fc-973f5ecc358b", "DestinationName": "IoTWirelessDestination", "Id": "1ffd32c8-8130-4194-96df-622f072a315f", "ThingName": "44b87eb4-9bce-423d-b5fc-973f5ecc358b", "Type": "LoRaWAN", "LoRaWAN": { "DeviceProfileId": "ab0c23d3-b001-45ef-6a01-2bc3de4f5333", "ServiceProfileId": "fe98dc76-cd12-001e-2d34-5550432da100", "OtaaV1_1": { "AppKey": "3f4ca100e2fc675ea123f4eb12c4a012", "JoinEui": "b4c231a359bc2e3d", "NwkKey": "01c3f004a2d6efffe32c4eda14bcd2b4" }, "DevEui": "ac12efc654d23fc2" }, "Arn": "arn:aws:iotwireless:us-east-1:123456789012:WirelessDevice/1ffd32c8-8130-4194-96df-622f072a315f", "Description": "My LoRaWAN wireless device" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-wireless-gateway-certificate.

Amazon CLI

To get the ID of a certificate associated with a wireless gateway

The following get-wireless-gateway-certificate example gets the certificate ID associated with a wireless gateway that has the specified ID.

aws iotwireless get-wireless-gateway-certificate \ --id "6c44ab31-8b4d-407a-bed3-19b6c7cda551"

Output:

{ "IotCertificateId": "8ea4aeae3db34c78cce75d9abd830356869ead6972997e0603e5fd032c804b6f" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-wireless-gateway-firmware-information.

Amazon CLI

To get firmware information about a wireless gateway

The following get-wireless-gateway-firmware-information example gets firmware version and other information about a wireless gateway.

aws iotwireless get-wireless-gateway-firmware-information \ --id "3039b406-5cc9-4307-925b-9948c63da25b"

Output:

{ "LoRaWAN" :{ "CurrentVersion" :{ "PackageVersion" : "1.0.0", "Station" : "2.0.5", "Model" : "linux" } } }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-wireless-gateway-statistics.

Amazon CLI

To get operating information about a wireless gateway

The following get-wireless-gateway-statistics example gets operating information about a wireless gateway.

aws iotwireless get-wireless-gateway-statistics \ --wireless-gateway-id "3039b406-5cc9-4307-925b-9948c63da25b"

Output:

{ "WirelessGatewayId": "3039b406-5cc9-4307-925b-9948c63da25b" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-wireless-gateway-task-definition.

Amazon CLI

To get information about a wireless gateway task definition

The following get-wireless-gateway-task-definition example gets information about the wireless task definition with the specified ID.

aws iotwireless get-wireless-gateway-task-definition \ --id "b7d3baad-25c7-35e7-a4e1-1683a0d61da9"

Output:

{ "AutoCreateTasks": true, "Name": "TestAutoUpdate", "Update":{ "UpdateDataSource" : "s3://cupsalphagafirmwarebin/station", "UpdateDataRole" : "arn:aws:iam::001234567890:role/SDK_Test_Role", "LoRaWAN" :{ "CurrentVersion" :{ "PackageVersion" : "1.0.0", "Station" : "2.0.5", "Model" : "linux" }, "UpdateVersion" :{ "PackageVersion" : "1.0.1", "Station" : "2.0.5", "Model" : "minihub" } } } }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-wireless-gateway-task.

Amazon CLI

To get information about the wireless gateway task

The following get-wireless-gateway-task example gets information about the wireless gateway task with the specified ID.

aws iotwireless get-wireless-gateway-task \ --id "11693a46-6866-47c3-a031-c9a616e7644b"

Output:

{ "WirelessGatewayId": "6c44ab31-8b4d-407a-bed3-19b6c7cda551", "WirelessGatewayTaskDefinitionId": "b7d3baad-25c7-35e7-a4e1-1683a0d61da9", "Status": "Success" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use get-wireless-gateway.

Amazon CLI

To get information about a wireless gateway

The following get-wireless-gateway example gets information about the wireless gateway myFirstLoRaWANGateway.

aws iotwireless get-wireless-gateway \ --identifier "12345678-a1b2-3c45-67d8-e90fa1b2c34d" \ --identifier-type WirelessGatewayId

Output:

{ "Description": "My first LoRaWAN gateway", "ThingArn": "arn:aws:iot:us-east-1:123456789012:thing/a1b2c3d4-5678-90ab-cdef-12ab345c67de", "LoRaWAN": { "RfRegion": "US915", "GatewayEui": "a1b2c3d4567890ab" }, "ThingName": "a1b2c3d4-5678-90ab-cdef-12ab345c67de", "Id": "12345678-a1b2-3c45-67d8-e90fa1b2c34d", "Arn": "arn:aws:iotwireless:us-east-1:123456789012:WirelessGateway/6c44ab31-8b4d-407a-bed3-19b6c7cda551", "Name": "myFirstLoRaWANGateway" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use list-destinations.

Amazon CLI

To list the wireless destinations

The following list-destinations example lists the available destinations registered to your Amazon account.

aws iotwireless list-destinations

Output:

{ "DestinationList": [ { "Arn": "arn:aws:iotwireless:us-east-1:123456789012:Destination/IoTWirelessDestination", "Name": "IoTWirelessDestination", "Expression": "IoTWirelessRule", "Description": "Destination for messages processed using IoTWirelessRule", "RoleArn": "arn:aws:iam::123456789012:role/IoTWirelessDestinationRole" }, { "Arn": "arn:aws:iotwireless:us-east-1:123456789012:Destination/IoTWirelessDestination2", "Name": "IoTWirelessDestination2", "Expression": "IoTWirelessRule2", "RoleArn": "arn:aws:iam::123456789012:role/IoTWirelessDestinationRole" } ] }

For more information, see Add destinations to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use list-device-profiles.

Amazon CLI

To list the device profiles

The following list-device-profiles example lists the available device profiles registered to your Amazon account.

aws iotwireless list-device-profiles

Output:

{ "DeviceProfileList": [ { "Id": "12345678-a1b2-3c45-67d8-e90fa1b2c34d", "Arn": "arn:aws:iotwireless:us-east-1:123456789012:DeviceProfile/12345678-a1b2-3c45-67d8-e90fa1b2c34d" }, { "Id": "a1b2c3d4-5678-90ab-cdef-12ab345c67de", "Arn": "arn:aws:iotwireless:us-east-1:123456789012:DeviceProfile/a1b2c3d4-5678-90ab-cdef-12ab345c67de" } ] }

For more information, see Add profiles to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use list-partner-accounts.

Amazon CLI

To list the partner accounts

The following list-partner-accounts example lists the available partner accounts associated with your Amazon account.

aws iotwireless list-partner-accounts

Output:

{ "Sidewalk": [ { "AmazonId": "78965678771228", "Fingerprint": "bd96d8ef66dbfd2160eb60e156849e82ad7018b8b73c1ba0b4fc65c32498ee35" }, { "AmazonId": "89656787651228", "Fingerprint": "bc5e99e151c07be14be7e6603e4489c53f858b271213a36ebe3370777ba06e9b" } ] }

For more information, see Amazon Sidewalk Integration for Amazon IoT Core in the Amazon IoT Developers Guide.

The following code example shows how to use list-service-profiles.

Amazon CLI

To list the service profiles

The following list-service-profiles example lists the available service profiles registered to your Amazon account.

aws iotwireless list-service-profiles

Output:

{ "ServiceProfileList": [ { "Id": "12345678-a1b2-3c45-67d8-e90fa1b2c34d", "Arn": "arn:aws:iotwireless:us-east-1:123456789012:ServiceProfile/538185bb-d7e7-4b95-96a0-c51aa4a5b9a0" }, { "Id": "a1b2c3d4-5678-90ab-cdef-12ab345c67de", "Arn": "arn:aws:iotwireless:us-east-1:123456789012:ServiceProfile/ea8bc823-5d13-472e-8d26-9550737d8100" } ] }

For more information, see Add profiles to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use list-tags-for-resource.

Amazon CLI

To list the tags assigned to the resource

The following list-tags-for-resource example lists the tags assigned to a wireless destination resource.

aws iotwireless list-tags-for-resource \ --resource-arn "arn:aws:iotwireless:us-east-1:123456789012:Destination/IoTWirelessDestination"

Output:

{ "Tags": [ { "Value": "MyValue", "Key": "MyTag" } ] }

For more information, see Describe your Amazon IoT Core for LoRaWAN resources in the Amazon IoT Developers Guide.

The following code example shows how to use list-wireless-devices.

Amazon CLI

To list the available wireless devices

The following list-wireless-devices example lists the available wireless devices registered to your Amazon account.

aws iotwireless list-wireless-devices

Output:

{ "WirelessDeviceList": [ { "Name": "myLoRaWANDevice", "DestinationName": "IoTWirelessDestination", "Id": "1ffd32c8-8130-4194-96df-622f072a315f", "Type": "LoRaWAN", "LoRaWAN": { "DevEui": "ac12efc654d23fc2" }, "Arn": "arn:aws:iotwireless:us-east-1:123456789012:WirelessDevice/1ffd32c8-8130-4194-96df-622f072a315f" } ] }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use list-wireless-gateway-task-definitions.

Amazon CLI

To list the wireless gateway task definitions

The following list-wireless-gateway-task-definitions example lists the available wireless gateway task definitions registered to your Amazon account.

aws iotwireless list-wireless-gateway-task-definitions

Output:

{ "TaskDefinitions": [ { "Id": "b7d3baad-25c7-35e7-a4e1-1683a0d61da9", "LoRaWAN" : { "CurrentVersion" :{ "PackageVersion" : "1.0.0", "Station" : "2.0.5", "Model" : "linux" }, "UpdateVersion" :{ "PackageVersion" : "1.0.1", "Station" : "2.0.5", "Model" : "minihub" } } } ] }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use list-wireless-gateways.

Amazon CLI

To list the wireless gateways

The following list-wireless-gateways example lists the available wireless gateways in your Amazon account.

aws iotwireless list-wireless-gateways

Output:

{ "WirelessGatewayList": [ { "Description": "My first LoRaWAN gateway", "LoRaWAN": { "RfRegion": "US915", "GatewayEui": "dac632ebc01d23e4" }, "Id": "3039b406-5cc9-4307-925b-9948c63da25b", "Arn": "arn:aws:iotwireless:us-east-1:123456789012:WirelessGateway/3039b406-5cc9-4307-925b-9948c63da25b", "Name": "myFirstLoRaWANGateway" }, { "Description": "My second LoRaWAN gateway", "LoRaWAN": { "RfRegion": "US915", "GatewayEui": "cda123fffe92ecd2" }, "Id": "3285bdc7-5a12-4991-84ed-dadca65e342e", "Arn": "arn:aws:iotwireless:us-east-1:123456789012:WirelessGateway/3285bdc7-5a12-4991-84ed-dadca65e342e", "Name": "mySecondLoRaWANGateway" } ] }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use send-data-to-wireless-device.

Amazon CLI

To send data to the wireless device

The following send-data-to-wireless-device example sends a decrypted application data frame to the wireless device.

aws iotwireless send-data-to-wireless-device \ --id "11aa5eae-2f56-4b8e-a023-b28d98494e49" \ --transmit-mode "1" \ --payload-data "SGVsbG8gVG8gRGV2c2lt" \ --wireless-metadata LoRaWAN={FPort=1}

Output:

{ MessageId: "6011dd36-0043d6eb-0072-0008" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use tag-resource.

Amazon CLI

To specify a tag key and value for a resource

The following tag-resource example tags the wireless destination IoTWirelessDestination with the key MyTag and value MyValue.

aws iotwireless tag-resource \ --resource-arn "arn:aws:iotwireless:us-east-1:651419225604:Destination/IoTWirelessDestination" \ --tags Key="MyTag",Value="MyValue"

This command produces no output.

For more information, see Describe your Amazon IoT Core for LoRaWAN resources in the Amazon IoT Developers Guide.

  • For API details, see TagResource in Amazon CLI Command Reference.

The following code example shows how to use test-wireless-device.

Amazon CLI

To test the wireless device

The following test-wireless-device example sends uplink data of Hello to a device with specified ID.

aws iotwireless test-wireless-device \ --id "11aa5eae-2f56-4b8e-a023-b28d98494e49"

Output:

{ Result: "Test succeeded. one message is sent with payload: hello" }

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use untag-resource.

Amazon CLI

To remove one or more tags from a resource

The following untag-resource example removes the tag MyTag and its value from the wireless destination IoTWirelessDestination.

aws iotwireless untag-resource \ --resource-arn "arn:aws:iotwireless:us-east-1:123456789012:Destination/IoTWirelessDestination" \ --tag-keys "MyTag"

This command produces no output.

For more information, see Describe your Amazon IoT Core for LoRaWAN resources in the Amazon IoT Developers Guide.

  • For API details, see UntagResource in Amazon CLI Command Reference.

The following code example shows how to use update-destination.

Amazon CLI

To update the properties of a destination

The following update-destination example updates the description property of a wireless destination.

aws iotwireless update-destination \ --name "IoTWirelessDestination" \ --description "Destination for messages processed using IoTWirelessRule"

This command produces no output.

For more information, see Add destinations to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use update-partner-account.

Amazon CLI

To update the properties of a partner account

The following update-partner-account updates the AppServerPrivateKey for the account that has the specified ID.

aws iotwireless update-partner-account \ --partner-account-id "78965678771228" \ --partner-type "Sidewalk" \ --sidewalk AppServerPrivateKey="f798ab4899346a88599180fee9e14fa1ada7b6df989425b7c6d2146dd6c815bb"

This command produces no output.

For more information, see Amazon Sidewalk Integration for Amazon IoT Core in the Amazon IoT Developers Guide.

The following code example shows how to use update-wireless-device.

Amazon CLI

To update the properties of a wireless device

The following update-wireless-device example updates the properties of a wireless device registered to your Amazon account.

aws iotwireless update-wireless-device \ --id "1ffd32c8-8130-4194-96df-622f072a315f" \ --destination-name IoTWirelessDestination2 \ --description "Using my first LoRaWAN device"

This command produces no output.

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.

The following code example shows how to use update-wireless-gateway.

Amazon CLI

To update the wireless gateway

The following update-wireless-gateway example updates the description of your wireless gateway.

aws iotwireless update-wireless-gateway \ --id "3285bdc7-5a12-4991-84ed-dadca65e342e" \ --description "Using my LoRaWAN gateway"

This command produces no output.

For more information, see Connecting devices and gateways to Amazon IoT Core for LoRaWAN in the Amazon IoT Developers Guide.