2020/4/22 News

obniz.js 3.5.0 Released

2020.04.22

obniz.js 3.5.0 Released

本日、obniz.js 3.5.0をリリースしました。
新たに20種類のBLEデバイスをサポート。合わせてBLE接続の安定化とタイムアウト機能の追加など、いくつかの改善を加えました。

GitHubへ

New Support Devices

以下のBLEデバイスをサポートしました。

BLE

Improvements

Common

  • async / await 関数は、obnizがオフラインまたはタイムアウト秒数を超えるとエラーを返します。
await obniz.spi0.writeWait([0x00]); // => will throw if obniz gone to offline or timeout occure.
  • i2cエラーが発生したときにエラーを返します。
const arr = await obniz.i2c0.readWait(0x11, 0x03); // => will throw if target is not connected or NAK responded.

BLE

  • ble.scan.start()とble.scan.end()は非推奨になりました。今後はstartWait()および endWait()を使用します。
  • ble.scan.onfinish()は、スキャンが何らかの理由で失敗したときにエラーを受け取ります。
obniz.ble.initWait(); // will throw error if fails. obniz.ble.scan.onfind = (peripheral) => { } obniz.ble.scan.onfinish = (peripherals, error) => { if (error) { // some thing error occured like obniz went to offline. } } await obniz.ble.scan.startWait(); // will throw error if start fails
  • peripheral.ondisconnect now pass reason arugument.
  • key phrase pairing をサポートしました。
await obniz.ble.initWait({}); obniz.ble.scan.onfind = function(peripheral){ if(peripheral.localName == "my peripheral"){ peripheral.onconnect = async function(){ console.log("success"); let passkeyCallback = await ()=>{ //HTML prompt let number = prompt("Please type passkey code."); return number; } // pairing with user input passkey. await peripheral.pairingWait({passkeyCallback}); } await peripheral.connectWait(); } } obniz.ble.scan.start();