aws 的 registerThing 操作来自:
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Iot.html#registerThing-property
var params = {
templateBody: 'STRING_VALUE', /* required */
parameters: {
'<Parameter>': 'STRING_VALUE',
/* '<Parameter>': ... */
}
};
iot.registerThing(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
以上是一个 nodejs 代码片段,其功能与 azure 的配置服务相同:
var serviceClient = provisioningServiceClient.fromConnectionString(this.connectionString);
var enrollment = {
registrationId: id,
deviceId: id,
attestation: {
type: 'x509',
x509: {
clientCertificates: {
primary: {
certificate: certificate
}
}
}
}
};
serviceClient.createOrUpdateIndividualEnrollment(enrollment as IndividualEnrollment, function (err, enrollmentResponse) {
if (err) {
console.error('error creating the individual enrollment: ' + err);
reject(err);
} else {
console.log("enrollment record returned: " + JSON.stringify(enrollmentResponse, null, 2));
resolve(enrollmentResponse);
}
});