當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ThingIFAPI.onboardWithVendorThingID方法代碼示例

本文整理匯總了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);
     });
 });
開發者ID:satoshikumano,項目名稱:thing-if-js-usage-test,代碼行數:28,代碼來源:thing-if-test.ts


注:本文中的thing-if-sdk.ThingIFAPI.onboardWithVendorThingID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。