在AWS IoT服务中的活动配置模板中,应该要包含执行命令或配置设备的操作指令,否则就会出现无法完成设备自动配置的情况。可以在AWS控制台中创建一个新的活动配置模板,并在模板中添加执行操作的指令,以确保设备自动配置成功。
参考代码示例:
aws iot create-provisioning-template --template-name MyProvisioningTemplate \
--template-body file://./provisioning-template-body.json
{
"Parameters": {
"ThingName": {
"Type": "String"
},
"ThingType": {
"Type": "String"
}
},
"Resources": {
"MyThing": {
"Type": "AWS::IoT::Thing",
"Properties": {
"ThingName": { "Ref": "ThingName" },
"ThingTypeName": { "Ref": "ThingType" }
}
},
"MyPolicy": {
"Type": "AWS::IoT::Policy",
"Properties": {
"PolicyDocument": {
" Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:*",
"Resource": "*"
}
]
},
"PolicyName": "MyPolicy"
}
},
"MyRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"iot.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Path": "/",
"Policies": [
{
"PolicyName": "MyPolicy",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iot:*"
],
"Resource": "*"
}
]
}
}
]
}
}
},
"Outputs": {
"ThingName": { "Value": { "Ref": "MyThing"} },
"PolicyARN": { "Value": { "Fn::GetAtt": [ "MyPolicy", "Arn" ]} },
"RoleId": { "Value": { "Fn::GetAtt": [ "MyRole", "Arn" ]} }
}
}
上一篇:AWSIoT-Core规则查询从MQTT消息(JSON)的双重嵌套对象中选择数据失败
下一篇:AWSIoTAndroidmqttLastWillAndTestament:MqttException(0)-java.io.IOException:Alreadyconnected