本文整理匯總了TypeScript中thing-if-sdk.ThingIFAPI.onboardWithVendorThingID方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ThingIFAPI.onboardWithVendorThingID方法的具體用法?TypeScript ThingIFAPI.onboardWithVendorThingID怎麽用?TypeScript ThingIFAPI.onboardWithVendorThingID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類thing-if-sdk.ThingIFAPI
的用法示例。
在下文中一共展示了ThingIFAPI.onboardWithVendorThingID方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it ("Shows how to Onboarding", function(done) {
const onboardReq = new ThingIF.OnboardWithVendorThingIDRequest("vendorThingID", "password");
api.onboardWithVendorThingID(onboardReq).then((result:ThingIF.OnboardingResult) => {
console.log(result.accessToken);
console.log(result.mqttEndPoint);
console.log(result.thingID);
const mqttEndPoint = result.mqttEndPoint;
const host:string = mqttEndPoint.host;
const topic:string = mqttEndPoint.mqttTopic;
const username:string = mqttEndPoint.username;
const password:string = mqttEndPoint.password;
const port:number = mqttEndPoint.portTCP;
const clientID:string = mqttEndPoint.mqttTopic;
// Connect to MQTT with mqttEndPoint information.
}).catch((error:Error) => {
if (error instanceof ThingIF.HttpRequestError) {
// REST Api returns error response.
console.log(error.status);
} else if (error.name == ThingIF.Errors.IlllegalStateError) {
// Error caused by illegal state.
} else if (error.name == ThingIF.Errors.ArgumentError) {
// Error caused by invalid argument.
} else {
// Other error. Unexpected error happens.
}
done(error);
});
});