Skip to content

Commit

Permalink
🐛 Since it was sometimes not started despite being connected, it was …
Browse files Browse the repository at this point in the history
…solved by delaying the execution time.
  • Loading branch information
Naoki Umeyama committed Oct 21, 2017
1 parent 94c092b commit df9a9ef
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ let Characteristic;

// dorita980をrequire
const dorita980 = require('dorita980');
// connect後、start()までの遅延時間を設定
const delayStartTime = 1000;
// 遅延時間を設定
const delayTime = 5000;

Expand Down Expand Up @@ -67,20 +69,21 @@ roombaAccessory.prototype = {
// Roombaに接続する
roombaViaLocal.on('connect', () => {
that.log('Roomba Connect!');

// Roombaに掃除を開始させる
roombaViaLocal.start().then(() => {
that.log('Roomba is Ruuuuuuuuuunning!');

// 実行後、公式アプリのチャンネルを解放するためにローカル接続を切断する
roombaViaLocal.end();
callback();
}).catch((error) => {
// エラー
that.log('Roomba Failed: %s', error.message);
that.log(error);
callback(error);
});
setTimeout(() => {
// Roombaに掃除を開始させる
roombaViaLocal.start().then(() => {
that.log('Roomba is Ruuuuuuuuuunning!');

// 実行後、公式アプリのチャンネルを解放するためにローカル接続を切断する
roombaViaLocal.end();
callback();
}).catch((error) => {
// エラー
that.log('Roomba Failed: %s', error.message);
that.log(error);
callback(error);
});
},delayStartTime);
});
} else {
// 掃除をやめて
Expand Down

0 comments on commit df9a9ef

Please sign in to comment.