本文整理汇总了TypeScript中thing-if-sdk.ThingIFAPI类的典型用法代码示例。如果您正苦于以下问题:TypeScript ThingIFAPI类的具体用法?TypeScript ThingIFAPI怎么用?TypeScript ThingIFAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ThingIFAPI类的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);
});
});