Navigation

    obniz Developer's Community Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. chie
    C
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    chie

    @chie

    0
    Reputation
    4
    Posts
    1
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    chie Follow

    Best posts made by chie

    This user hasn't posted anything yet.

    Latest posts made by chie

    • RE: obniz BLE/wifiゲートウェイ BLEのローミングについて

      kido 様

      ご返信いただきありがとうございます。

      教えていただいた方法にて、やり方を模索してみます。

      posted in Technical Support
      C
      chie
    • RE: ObnizOfflineErrorのエラー処理について

      @kido 様

      ご返信頂きありがとうございます。

      obniz.closeする前に、下記のようにnoble.stopScanning();をして実行してみましたが、実行後しばらく待つと同じエラーが発生しています。

      ーーーコードーーー
      await _sleep(5*1000)
      noble.stopScanning();

      await _sleep(10*1000)
      noble.obniz.close();
      noble.obniz.on('close', () => {
      console.log("a close event occurred!", noble.obniz.id);
      });

      obnizの管理コンソールより、対象のobnizはオンラインであることを確認しています。

      また、nodeのバージョンはv12.18.3です

      ーーー実行ログーーー
      a close event occurred! xxxx-xxxx
      /Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz/dist/src/obniz/ObnizConnection.js:277
      throw new ObnizError_1.ObnizOfflineError();
      ^

      ObnizOfflineError: obniz is not online.
      at Obniz.send (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz/dist/src/obniz/ObnizConnection.js:277:19)
      at ObnizBLEHci.write (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz/dist/src/obniz/libs/embeds/bleHci/hci.js:53:20)
      at Object.write (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz-noble/lib/obniz-hci-socket/hci.js:112:21)
      at Hci.setScanEnabled (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz-noble/lib/obniz-hci-socket/hci.js:282:16)
      at Gap.stopScanning (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz-noble/lib/obniz-hci-socket/gap.js:55:13)
      at NobleBindings.stopScanning (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz-noble/lib/obniz-hci-socket/bindings.js:43:13)
      at NobleBindings.onExit (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz-noble/lib/obniz-hci-socket/bindings.js:103:8)
      at process.emit (events.js:315:20) {
      code: 1
      }

      よろしくお願いいたします。

      posted in Technical Support
      C
      chie
    • ObnizOfflineErrorのエラー処理について

      obniz wifi/ble gateway(OS 3.5.0)を使って開発しております。
      次のフローでコードを実行しました。

      obnizNoble(obniz_id)を呼び出した後、nobleのstateChangeイベントでpower onを確認した後、スキャンを開始。
      スキャンして見つかったペリフェラルと接続した後、noble.obniz.close();を呼び出す

      しばらく待つと下記のエラーが発生しプログラムが終了します。

      /Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz/dist/src/obniz/ObnizConnection.js:277
      throw new ObnizError_1.ObnizOfflineError();
      ^

      ObnizOfflineError: obniz is not online.
      at Obniz.send (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz/dist/src/obniz/ObnizConnection.js:277:19)
      at ObnizBLEHci.write (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz/dist/src/obniz/libs/embeds/bleHci/hci.js:53:20)
      at Object.write (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz-noble/lib/obniz-hci-socket/hci.js:112:21)
      at Hci.setScanEnabled (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz-noble/lib/obniz-hci-socket/hci.js:282:16)
      at Gap.stopScanning (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz-noble/lib/obniz-hci-socket/gap.js:55:13)
      at NobleBindings.stopScanning (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz-noble/lib/obniz-hci-socket/bindings.js:43:13)
      at NobleBindings.onExit (/Users/xxx/Documents/GitHub/obniz/custom/node_modules/obniz-noble/lib/obniz-hci-socket/bindings.js:103:8)
      at process.emit (node:events:378:20) {
      code: 1
      }

      質問:エラーをキャッチする方法はありますか?

      下記のいずれもエラーをキャッチできませんでした。
      ・test()をtry catchで括る
      ・noble.obniz.close();をtry catchで括る
      ・peripheral.onerror
      ・noble.obniz.onerror

      バージョン情報
      obniz-noble@2.2.0
      obniz@3.16.0

      コード
      ーーーーーーーーー
      const Obniz = require("obniz")
      const obnizNoble = require("obniz-noble");

      const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

      test()

      async function test(){
      let o_id = “xxxxxx”//obniz-id
      let noble = obnizNoble(o_id);

      noble.on('stateChange', async function (state) {
      if (state === 'poweredOn'){
      noble.obniz.onerror = async (ob, err)=>{
      console.log("obniz onerror:",err)
      }
      noble.startScanning();
      }
      })

      noble.on('discover', function (peripheral) {
      let localName = peripheral.advertisement.localName
      if(localName == "xxxxx"){
      peripheral.connect()
      peripheral.onerror = function(err){
      console.log("peripheral error : " + err);
      }
      peripheral.once('connect', function () { console.log('connect: ' + localName);})
      }
      })

      await _sleep(10*1000)

      noble.obniz.close();
      noble.obniz.on('close', () => {
      console.log("a close event occurred!", noble.obniz.id);
      });

      }

      posted in Technical Support
      C
      chie
    • obniz BLE/wifiゲートウェイ BLEのローミングについて

      obniz BLE/wifiゲートウェイでBLEのローミング機能の実装をしたいと思っており、いくつかご質問があります。

      ・obniz BLE/wifiゲートウェイには BLEのローミング機能はありますでしょうか?
      (ない場合はobnizのプログラミングで制御することになると思いますが、参考資料・サンプルコード等はありますでしょうか?)

      ・obniz BLE/wifiゲートウェイ同士が近くにあるかどうか判定する方法はありますでしょうか?

      よろしくお願いいたします。

      posted in Technical Support
      C
      chie