From df9a9ef6f935b1621de8d1073bba892bc64db9bd Mon Sep 17 00:00:00 2001 From: Naoki Umeyama Date: Sun, 22 Oct 2017 08:04:09 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Since=20it=20was=20sometimes=20n?= =?UTF-8?q?ot=20started=20despite=20being=20connected,=20it=20was=20solved?= =?UTF-8?q?=20by=20delaying=20the=20execution=20time.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/index.js b/index.js index 5670a26..ea0dc2f 100755 --- a/index.js +++ b/index.js @@ -7,6 +7,8 @@ let Characteristic; // dorita980をrequire const dorita980 = require('dorita980'); +// connect後、start()までの遅延時間を設定 +const delayStartTime = 1000; // 遅延時間を設定 const delayTime = 5000; @@ -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 { // 掃除をやめて