thingy52_web_bluetooth
Advanced tools
Comparing version 1.5.1 to 1.5.2-transpiled
@@ -1,3 +0,3 @@ | ||
import Thingy from "./js/Thingy.js"; | ||
import Thingy from "./es5/Thingy.js"; | ||
export default Thingy; |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TMS_ORIENTATION_UUID, | ||
decoder: this.decodeOrientationData.bind(this), | ||
decoder: this.decodeOrientationData, | ||
}; | ||
} | ||
decodeOrientationData(data) { | ||
decodeOrientationData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const orientation = data.getUint8(0); |
@@ -45,8 +45,8 @@ /* | ||
uuid: this.device.TCS_ADV_PARAMS_UUID, | ||
decoder: this.decodeAdvertisingParam.bind(this), | ||
encoder: this.encodeAdvertisingParam.bind(this), | ||
decoder: this.decodeAdvertisingParam, | ||
encoder: this.encodeAdvertisingParam, | ||
}; | ||
} | ||
decodeAdvertisingParam(data) { | ||
decodeAdvertisingParam = (data) => { | ||
try { | ||
@@ -67,5 +67,4 @@ // Interval is given in units of 0.625 milliseconds | ||
async encodeAdvertisingParam(params) { | ||
encodeAdvertisingParam = async (params) => { | ||
try { | ||
if (typeof params !== "object") { | ||
@@ -72,0 +71,0 @@ const error = new Error("The argument has to be an object."); |
@@ -45,7 +45,7 @@ /* | ||
uuid: "battery_level", | ||
decoder: this.decodeBatteryStatus.bind(this), | ||
decoder: this.decodeBatteryStatus, | ||
}; | ||
} | ||
decodeBatteryStatus(data) { | ||
decodeBatteryStatus = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const batteryStatus = data.getInt8(0); |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TUIS_BTN_UUID, | ||
decoder: this.decodeButtonData.bind(this), | ||
decoder: this.decodeButtonData, | ||
}; | ||
} | ||
decodeButtonData(data) { | ||
decodeButtonData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const state = data.getUint8(0); |
@@ -45,8 +45,8 @@ /* | ||
uuid: this.device.TCS_CLOUD_TOKEN_UUID, | ||
decoder: this.decodeCloudToken.bind(this), | ||
encoder: this.encodeCloudToken.bind(this), | ||
decoder: this.decodeCloudToken, | ||
encoder: this.encodeCloudToken, | ||
}; | ||
} | ||
decodeCloudToken(data) { | ||
decodeCloudToken = (data) => { | ||
try { | ||
@@ -65,3 +65,3 @@ const decoder = new TextDecoder(); | ||
encodeCloudToken(token) { | ||
encodeCloudToken = (token) => { | ||
try { | ||
@@ -68,0 +68,0 @@ if (token.length > 250) { |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TES_COLOR_UUID, | ||
decoder: this.decodeColorData.bind(this), | ||
decoder: this.decodeColorData, | ||
}; | ||
} | ||
decodeColorData(data) { | ||
decodeColorData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const littleEndian = true; |
@@ -45,8 +45,8 @@ /* | ||
uuid: this.device.TCS_CONN_PARAMS_UUID, | ||
decoder: this.decodeConnectionParam.bind(this), | ||
encoder: this.encodeConnectionParam.bind(this), | ||
decoder: this.decodeConnectionParam, | ||
encoder: this.encodeConnectionParam, | ||
}; | ||
} | ||
decodeConnectionParam(data) { | ||
decodeConnectionParam = (data) => { | ||
try { | ||
@@ -73,3 +73,3 @@ // Connection intervals are given in units of 1.25 ms | ||
async encodeConnectionParam(params) { | ||
encodeConnectionParam = async (params) => { | ||
try { | ||
@@ -76,0 +76,0 @@ if (typeof params !== "object") { |
@@ -45,8 +45,8 @@ /* | ||
uuid: this.device.TCS_EDDYSTONE_UUID, | ||
decoder: this.decodeEddystoneData.bind(this), | ||
encoder: this.encodeEddystoneData.bind(this), | ||
decoder: this.decodeEddystoneData, | ||
encoder: this.encodeEddystoneData, | ||
}; | ||
} | ||
decodeEddystoneData(data) { | ||
decodeEddystoneData = (data) => { | ||
try { | ||
@@ -88,3 +88,3 @@ // According to Eddystone URL encoding specification, certain elements can be expanded: https://github.com/google/eddystone/tree/master/eddystone-url | ||
encodeEddystoneData(data) { | ||
encodeEddystoneData = (data) => { | ||
try { | ||
@@ -91,0 +91,0 @@ // Uses URL API to check for valid URL |
@@ -45,8 +45,8 @@ /* | ||
uuid: this.device.TES_CONFIG_UUID, | ||
decoder: this.decodeConfigData.bind(this), | ||
encoder: this.encodeConfigData.bind(this), | ||
decoder: this.decodeConfigData, | ||
encoder: this.encodeConfigData, | ||
}; | ||
} | ||
decodeConfigData(data) { | ||
decodeConfigData = (data) => { | ||
try { | ||
@@ -90,3 +90,3 @@ const littleEndian = true; | ||
async encodeConfigData(params) { | ||
encodeConfigData = async (params) => { | ||
try { | ||
@@ -93,0 +93,0 @@ if (typeof params !== "object") { |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TMS_EULER_UUID, | ||
decoder: this.decodeEulerData.bind(this), | ||
decoder: this.decodeEulerData, | ||
}; | ||
} | ||
decodeEulerData(data) { | ||
decodeEulerData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const littleEndian = true; |
@@ -32,3 +32,2 @@ /* | ||
import EventTarget from "./EventTarget.js"; | ||
import ThingyController from "./ThingyController.js"; | ||
@@ -45,3 +44,3 @@ import Utilities from "./Utilities.js"; | ||
async _connect() { | ||
_connect = async () => { | ||
if (!("thingyController" in this)) { | ||
@@ -100,3 +99,3 @@ // has to be put here rather than in the constructor as we need access to the id of the device | ||
this.thingyController.setGattStatus(true); | ||
this.thingyController.enqueue(this.type, "connect", this._connect.bind(this)); | ||
this.thingyController.enqueue(this.type, "connect", () => this._connect()); | ||
} | ||
@@ -113,3 +112,3 @@ | ||
} else { | ||
this.thingyController.enqueue(this.type, "connect", this._connect.bind(this)); | ||
this.thingyController.enqueue(this.type, "connect", () => this._connect()); | ||
return false; | ||
@@ -119,3 +118,3 @@ } | ||
async _read(returnRaw = false) { | ||
_read = async (returnRaw = false) => { | ||
try { | ||
@@ -190,3 +189,3 @@ let connectIteration = 0; | ||
async _write(prop) { | ||
_write = async (prop) => { | ||
try { | ||
@@ -267,3 +266,3 @@ if (prop === undefined) { | ||
async _notify(enable, verify = false) { | ||
_notify = async (enable, verify = false) => { | ||
if (!(enable === true || enable === false)) { | ||
@@ -279,3 +278,3 @@ const error = new Error("You have to specify the enable parameter (true/false)"); | ||
if (!connected) { | ||
this.thingyController.enqueue(this.type, (enable ? "start" : "stop"), this._notify.bind(this, enable, verify)); | ||
this.thingyController.enqueue(this.type, (enable ? "start" : "stop"), () => this._notify(enable, verify)); | ||
return false; | ||
@@ -287,3 +286,3 @@ } | ||
if (!this.hasProperty("notify") && !this.hasProperty("indicate")) { | ||
if (!this.hasProperty("notify") && (!this.hasProperty("indicate"))) { | ||
const error = new Error(`The ${this.type} feature does not support the start/stop methods`); | ||
@@ -334,3 +333,3 @@ this.utilities.processEvent("error", this.type, error); | ||
if (!this.characteristic.hasEventListener) { | ||
csn.addEventListener("characteristicvaluechanged", onReading.bind(this)); | ||
csn.addEventListener("characteristicvaluechanged", (e) => onReading(e)); | ||
this.characteristic.hasEventListener = true; | ||
@@ -348,3 +347,3 @@ } | ||
this.thingyController.setGattStatus(true); | ||
this.thingyController.enqueue(this.type, (enable ? "start" : "stop"), this._notify.bind(this, enable, verify)); | ||
this.thingyController.enqueue(this.type, (enable ? "start" : "stop"), () => this._notify(enable, verify)); | ||
this.characteristic.notifying = false; | ||
@@ -375,3 +374,3 @@ this.utilities.processEvent("error", this.type, error); | ||
this.thingyController.setGattStatus(true); | ||
this.thingyController.enqueue(this.type, (enable ? "start" : "stop"), this._notify.bind(this, enable, verify)); | ||
this.thingyController.enqueue(this.type, (enable ? "start" : "stop"), () => this._notify(enable, verify)); | ||
this.characteristic.notifying = true; | ||
@@ -383,3 +382,3 @@ this.utilities.processEvent("error", this.type, error); | ||
} else { | ||
this.thingyController.enqueue(this.type, (enable ? "start" : "stop"), this._notify.bind(this, enable, verify)); | ||
this.thingyController.enqueue(this.type, (enable ? "start" : "stop"), () => this._notify(enable, verify)); | ||
return false; | ||
@@ -389,19 +388,19 @@ } | ||
hasProperty(property) { | ||
hasProperty = (property) => { | ||
return (this.characteristic.characteristic.properties[property] === true ? true : false); | ||
} | ||
async start() { | ||
start = async () => { | ||
return await this._notify(true); | ||
} | ||
async stop() { | ||
stop = async () => { | ||
return await this._notify(false); | ||
} | ||
async read() { | ||
read = async () => { | ||
return await this._read(); | ||
} | ||
async write(data) { | ||
write = async (data) => { | ||
return await this._write(data); | ||
@@ -408,0 +407,0 @@ } |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TCS_FW_VER_UUID, | ||
decoder: this.decodeFirmwareVersion.bind(this), | ||
decoder: this.decodeFirmwareVersion, | ||
}; | ||
} | ||
decodeFirmwareVersion(data) { | ||
decodeFirmwareVersion = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const major = data.getUint8(0); |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TES_GAS_UUID, | ||
decoder: this.decodeGasData.bind(this), | ||
decoder: this.decodeGasData, | ||
}; | ||
} | ||
decodeGasData(data) { | ||
decodeGasData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const littleEndian = true; |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TMS_GRAVITY_UUID, | ||
decoder: this.decodeGravityVectorData.bind(this), | ||
decoder: this.decodeGravityVectorData, | ||
}; | ||
} | ||
decodeGravityVectorData(data) { | ||
decodeGravityVectorData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const x = data.getFloat32(0, true); |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TMS_HEADING_UUID, | ||
decoder: this.decodeHeadingData.bind(this), | ||
decoder: this.decodeHeadingData, | ||
}; | ||
} | ||
decodeHeadingData(data) { | ||
decodeHeadingData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const littleEndian = true; |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TES_HUMIDITY_UUID, | ||
decoder: this.decodeHumidityData.bind(this), | ||
decoder: this.decodeHumidityData, | ||
}; | ||
} | ||
decodeHumidityData(data) { | ||
decodeHumidityData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const humidity = data.getUint8(0); |
@@ -45,8 +45,8 @@ /* | ||
uuid: this.device.TUIS_LED_UUID, | ||
decoder: this.decodeLedData.bind(this), | ||
encoder: this.encodeLedData.bind(this), | ||
decoder: this.decodeLedData, | ||
encoder: this.encodeLedData, | ||
}; | ||
} | ||
decodeLedData(data) { | ||
decodeLedData = (data) => { | ||
try { | ||
@@ -53,0 +53,0 @@ const mode = data.getUint8(0); |
@@ -45,5 +45,3 @@ /* | ||
uuid: this.device.TSS_MIC_UUID, | ||
decoder: this.decodeMicrophoneData.bind(this), | ||
// verifyAction: this.verifyMicrophoneAction.bind(this), | ||
// verifyReaction: this.verifyMicrophoneReaction.bind(this), | ||
decoder: this.decodeMicrophoneData, | ||
}; | ||
@@ -59,10 +57,9 @@ | ||
5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767]; | ||
this.suspendAudioContext = this.suspendAudioContext.bind(this); | ||
} | ||
async suspendAudioContext() { | ||
suspendAudioContext = async () => { | ||
await this.audioCtx.suspend(); | ||
} | ||
decodeMicrophoneData(event) { | ||
decodeMicrophoneData = (event) => { | ||
const audioPacket = event.buffer; | ||
@@ -78,3 +75,3 @@ const adpcm = { | ||
async verifyMicrophoneAction() { | ||
verifyMicrophoneAction = async () => { | ||
try { | ||
@@ -108,3 +105,3 @@ await this.device.mtu._write(140); | ||
_decodeAudio(adpcm) { | ||
_decodeAudio = (adpcm) => { | ||
try { | ||
@@ -188,3 +185,3 @@ // Allocate output buffer | ||
play(audio) { | ||
play = (audio) => { | ||
if (this._audioStack === undefined) { | ||
@@ -198,3 +195,3 @@ this._audioStack = []; | ||
} | ||
_scheduleAudioBuffers() { | ||
_scheduleAudioBuffers = () => { | ||
while (this._audioStack.length > 0) { | ||
@@ -201,0 +198,0 @@ const bufferTime = 0.01; // Buffer time in seconds before initial audio chunk is played |
@@ -45,8 +45,8 @@ /* | ||
uuid: this.device.TMS_CONFIG_UUID, | ||
decoder: this.decodeConfigData.bind(this), | ||
encoder: this.encodeConfigData.bind(this), | ||
decoder: this.decodeConfigData, | ||
encoder: this.encodeConfigData, | ||
}; | ||
} | ||
decodeConfigData(data) { | ||
decodeConfigData = (data) => { | ||
try { | ||
@@ -74,3 +74,3 @@ const littleEndian = true; | ||
async encodeConfigData(params) { | ||
encodeConfigData = async (params) => { | ||
try { | ||
@@ -77,0 +77,0 @@ if (typeof params !== "object") { |
@@ -45,8 +45,8 @@ /* | ||
uuid: this.device.TCS_MTU_REQUEST_UUID, | ||
decoder: this.decodeMtu.bind(this), | ||
encoder: this.encodeMtu.bind(this), | ||
decoder: this.decodeMtu, | ||
encoder: this.encodeMtu, | ||
}; | ||
} | ||
decodeMtu(mtuSize) { | ||
decodeMtu = (mtuSize) => { | ||
try { | ||
@@ -62,3 +62,3 @@ const littleEndian = true; | ||
encodeMtu(mtuSize, peripheralRequest = true) { | ||
encodeMtu = (mtuSize, peripheralRequest = true) => { | ||
try { | ||
@@ -65,0 +65,0 @@ if (mtuSize < 23 || mtuSize > 276) { |
@@ -45,8 +45,8 @@ /* | ||
uuid: this.device.TCS_NAME_UUID, | ||
decoder: this.decodeName.bind(this), | ||
encoder: this.encodeName.bind(this), | ||
decoder: this.decodeName, | ||
encoder: this.encodeName, | ||
}; | ||
} | ||
decodeName(data) { | ||
decodeName = (data) => { | ||
try { | ||
@@ -64,3 +64,3 @@ const decoder = new TextDecoder(); | ||
encodeName(data) { | ||
encodeName = (data) => { | ||
try { | ||
@@ -67,0 +67,0 @@ if (data.length > 10) { |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TES_PRESSURE_UUID, | ||
decoder: this.decodePressureData.bind(this), | ||
decoder: this.decodePressureData, | ||
}; | ||
} | ||
decodePressureData(data) { | ||
decodePressureData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const littleEndian = true; |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TMS_QUATERNION_UUID, | ||
decoder: this.decodeQuaternionData.bind(this), | ||
decoder: this.decodeQuaternionData, | ||
}; | ||
} | ||
decodeQuaternionData(data) { | ||
decodeQuaternionData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const littleEndian = true; |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TMS_RAW_UUID, | ||
decoder: this.decodeRawDataData.bind(this), | ||
decoder: this.decodeRawDataData, | ||
}; | ||
} | ||
decodeRawDataData(data) { | ||
decodeRawDataData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const littleEndian = true; |
@@ -49,3 +49,3 @@ /* | ||
decodeRotationData(data) { | ||
decodeRotationData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ // Divide by 2^2 = 4 to get correct values |
@@ -45,8 +45,8 @@ /* | ||
uuid: this.device.TSS_CONFIG_UUID, | ||
decoder: this.decodeSoundConfigurationData.bind(this), | ||
encoder: this.encodeSoundConfigurationData.bind(this), | ||
decoder: this.decodeSoundConfigurationData, | ||
encoder: this.encodeSoundConfigurationData, | ||
}; | ||
} | ||
decodeSoundConfigurationData(data) { | ||
decodeSoundConfigurationData = (data) => { | ||
try { | ||
@@ -65,3 +65,3 @@ const speakerMode = data.getUint8(0); | ||
async encodeSoundConfigurationData(data) { | ||
encodeSoundConfigurationData = async (data) =>{ | ||
try { | ||
@@ -68,0 +68,0 @@ if (typeof data !== "object") { |
@@ -46,3 +46,3 @@ /* | ||
uuid: this.device.TSS_SPEAKER_DATA_UUID, | ||
encoder: this.encodeSpeakerData.bind(this), | ||
encoder: this.encodeSpeakerData, | ||
}; | ||
@@ -53,3 +53,3 @@ | ||
async encodeSpeakerData(data) { | ||
encodeSpeakerData = (data) => { | ||
try { | ||
@@ -56,0 +56,0 @@ if (data.mode === 1) { |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TSS_SPEAKER_STAT_UUID, | ||
decoder: this.decodeSpeakerStatus.bind(this), | ||
decoder: this.decodeSpeakerStatus, | ||
}; | ||
} | ||
decodeSpeakerStatus(data) { | ||
decodeSpeakerStatus = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const speakerStatus = data.getInt8(0); |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TMS_STEP_UUID, | ||
decoder: this.decodeStepData.bind(this), | ||
decoder: this.decodeStepData, | ||
}; | ||
} | ||
decodeStepData(data) { | ||
decodeStepData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const littleEndian = true; |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TMS_TAP_UUID, | ||
decoder: this.decodeTapData.bind(this), | ||
decoder: this.decodeTapData, | ||
}; | ||
} | ||
decodeTapData(data) { | ||
decodeTapData = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const direction = data.getUint8(0); |
@@ -45,7 +45,7 @@ /* | ||
uuid: this.device.TES_TEMP_UUID, | ||
decoder: this.decodeTemperature.bind(this), | ||
decoder: this.decodeTemperature, | ||
}; | ||
} | ||
decodeTemperature(data) { | ||
decodeTemperature = (data) => { | ||
try { | ||
@@ -52,0 +52,0 @@ const integer = data.getInt8(0); |
@@ -65,3 +65,4 @@ /* | ||
import EventTarget from "./EventTarget.js"; | ||
import DFUControlPointService from "./DFUControlPointService.js"; | ||
import DFUControlPointServiceFirmwarev1 from "./DFUControlPointServiceFirmwarev1.js"; | ||
import DFUControlPointServiceFirmwarev2 from "./DFUControlPointServiceFirmwarev2.js"; | ||
@@ -71,3 +72,2 @@ class Thingy extends EventTarget { | ||
super(); | ||
this.logEnabled = options.logEnabled; | ||
@@ -125,5 +125,6 @@ this.connected = false; | ||
// DFU = Device Firmware Update | ||
// DFU Service | ||
this.DFU_UUID = "0000fe59-0000-1000-8000-00805f9b34fb"; | ||
this.DFU_CTRL_POINT_UUID = "8ec90003-f315-4f60-9fb8-838830daea50"; | ||
this.DFU_CTRL_POINT_UUID_VERSION_1 = "8ec90001-f315-4f60-9fb8-838830daea50"; | ||
this.DFU_CTRL_POINT_UUID_VERSION_2 = "8ec90003-f315-4f60-9fb8-838830daea50"; | ||
@@ -140,4 +141,4 @@ this.serviceUUIDs = [ | ||
this.addEventListener("gattavailable", this.executeQueuedOperations.bind(this)); | ||
this.addEventListener("operationqueued", this.executeQueuedOperations.bind(this)); | ||
this.addEventListener("gattavailable", () => this.executeQueuedOperations()); | ||
this.addEventListener("operationqueued", () => this.executeQueuedOperations()); | ||
@@ -174,6 +175,7 @@ this.advertisingparameters = new AdvertisingParametersService(this); | ||
this.battery = new BatteryService(this); | ||
this.dfucontrolpoint = new DFUControlPointService(this); | ||
this.dfucontrolpoint_v1 = new DFUControlPointServiceFirmwarev1(this); | ||
this.dfucontrolpoint_v2 = new DFUControlPointServiceFirmwarev2(this); | ||
} | ||
async connect() { | ||
connect = async () => { | ||
try { | ||
@@ -192,3 +194,3 @@ // Scan for Thingys | ||
this.device.addEventListener('gattserverdisconnected', this.onDisconnected.bind(this)); | ||
this.device.addEventListener('gattserverdisconnected', (e) => this.onDisconnected(e)); | ||
@@ -207,7 +209,7 @@ this.setConnected(true); | ||
return true; | ||
if (this.logEnabled) { | ||
console.log(`Connected to "${this.device.name}"`); | ||
} | ||
return true; | ||
} catch (error) { | ||
@@ -227,3 +229,3 @@ this.setConnected(false); | ||
// if an operation fails three times and seemingly no other operations are executed at the same time, the operation is discarded. | ||
async executeQueuedOperations() { | ||
executeQueuedOperations = async () => { | ||
try { | ||
@@ -299,11 +301,11 @@ if (!this.thingyController.getExecutingQueuedOperations()) { | ||
getConnected() { | ||
getConnected = () => { | ||
return this.connected; | ||
} | ||
setConnected(bool) { | ||
setConnected = (bool) => { | ||
this.connected = bool; | ||
} | ||
resetDeviceProperties() { | ||
resetDeviceProperties = () => { | ||
this.setConnected(false); | ||
@@ -313,3 +315,3 @@ this.thingyController.terminate(); | ||
onDisconnected({target}) { | ||
onDisconnected = ({target}) => { | ||
if (!this.getConnected()) { | ||
@@ -323,5 +325,6 @@ if (this.logEnabled) { | ||
} | ||
} | ||
async disconnect() { | ||
disconnect = async () => { | ||
try { | ||
@@ -328,0 +331,0 @@ this.resetDeviceProperties(); |
@@ -43,3 +43,3 @@ /* | ||
_initialize() { | ||
_initialize = () => { | ||
if (window.thingyController === undefined) { | ||
@@ -70,3 +70,3 @@ window.thingyController = {}; | ||
addExecutedOperation(feature, method) { | ||
addExecutedOperation = (feature, method) => { | ||
if (this.device.getConnected()) { | ||
@@ -77,7 +77,7 @@ window.thingyController[this.tid].executedOperations.push({feature, method}); | ||
clearExecutedOperations() { | ||
clearExecutedOperations = () => { | ||
window.thingyController[this.tid].executedOperations = []; | ||
} | ||
setGattStatus(bool) { | ||
setGattStatus = (bool) => { | ||
if (this.device.getConnected()) { | ||
@@ -92,3 +92,3 @@ window.thingyController[this.tid].gattStatus = bool; | ||
getGattStatus() { | ||
getGattStatus = () => { | ||
if (this.device.getConnected()) { | ||
@@ -99,3 +99,3 @@ return window.thingyController[this.tid].gattStatus; | ||
getNumQueuedOperations() { | ||
getNumQueuedOperations = () => { | ||
if (this.device.getConnected()) { | ||
@@ -106,3 +106,3 @@ return window.thingyController[this.tid].queuedOperations.length; | ||
getQueuedOperation(index) { | ||
getQueuedOperation = (index) => { | ||
if (this.device.getConnected()) { | ||
@@ -116,3 +116,3 @@ if (window.thingyController[this.tid].queuedOperations.length >= index) { | ||
// removes either by index or by operation specifics (feature and method) | ||
removeQueuedOperation(x) { | ||
removeQueuedOperation = (x) => { | ||
if (this.device.getConnected()) { | ||
@@ -134,3 +134,3 @@ if (Number.isInteger(x)) { | ||
enqueue(feature, method, f) { | ||
enqueue = (feature, method, f) => { | ||
if (this.device.getConnected()) { | ||
@@ -142,3 +142,3 @@ window.thingyController[this.tid].queuedOperations.push({feature, method, f}); | ||
dequeue() { | ||
dequeue = () => { | ||
if (this.device.getConnected()) { | ||
@@ -149,3 +149,3 @@ return window.thingyController[this.tid].queuedOperations.shift(); | ||
setExecutingQueuedOperations(bool) { | ||
setExecutingQueuedOperations = (bool) => { | ||
if (this.device.getConnected()) { | ||
@@ -160,3 +160,3 @@ window.thingyController[this.tid].executingQueuedOperations = bool; | ||
getExecutingQueuedOperations() { | ||
getExecutingQueuedOperations = () => { | ||
if (this.device.getConnected()) { | ||
@@ -167,7 +167,7 @@ return window.thingyController[this.tid].executingQueuedOperations; | ||
getDevice() { | ||
getDevice = () => { | ||
return this.device; | ||
} | ||
setDevice(device) { | ||
setDevice = (device) => { | ||
this.device = device; | ||
@@ -177,3 +177,3 @@ this.tid = device.device.id; | ||
getExecutedOperation(index) { | ||
getExecutedOperation = (index) => { | ||
if (this.device.getConnected()) { | ||
@@ -184,3 +184,3 @@ return window.thingyController[this.tid].executedOperations[index]; | ||
getNumExecutedOperations() { | ||
getNumExecutedOperations = () => { | ||
if (this.device.getConnected()) { | ||
@@ -191,3 +191,3 @@ return window.thingyController[this.tid].executedOperations.length; | ||
terminate() { | ||
terminate = () => { | ||
window.thingyController[this.tid] = undefined; | ||
@@ -194,0 +194,0 @@ } |
@@ -11,7 +11,7 @@ import EventTarget from "./EventTarget.js"; | ||
async wait(ms) { | ||
wait = (ms) => { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
processEvent(type, feature, body, target = this.device) { | ||
processEvent = (type, feature, body, target = this.device) => { | ||
let eventObject; | ||
@@ -18,0 +18,0 @@ |
{ | ||
"name": "thingy52_web_bluetooth", | ||
"version": "1.5.1", | ||
"version": "1.5.2-transpiled", | ||
"description": "API for connecting to and interacting with Nordic Semiconductor's Thingy:52 in the browser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
119
README.md
@@ -10,3 +10,3 @@ # Nordic Thingy:52 for Web Bluetooth | ||
This is work in progress, and for now this repository will help you connect to a Thingy:52 and access all services and characteristics except for MTU (Maximum Transmission Unit): | ||
This is work in progress, and for now this repository will help you connect to a Thingy:52 and access all services and characteristics except for speaker, microphone, MTU (Maximum Transmission Unit): | ||
@@ -16,8 +16,8 @@ ### Get started | ||
- Clone or download this repository. | ||
- If you've used this repository, you can serve `index.html` using any http server. You can then navigate to the server address in a supported browser and open the console (ctrl + shift + J or cmd + alt + J). | ||
- If you've used this repository, you can open `index.html` in a supported browser and open the console (ctrl + shift + J or cmd + alt + J). | ||
- Turn on your Thingy:52. | ||
- Click the "Connect" button found on the page. | ||
- Click the "Connect" button found in `index.html`. | ||
- You can now choose your Thingy:52 and connect to it. | ||
- In the console, you can see the browser connect to the device and discover its services. | ||
- When connected, the Thingy:52 will use the LED breathe feature and the LED will pulsate with a RED light. | ||
- When connected, the Thingy:52 will use the LED breathe feature and the LED will pulsate with RED light. | ||
- In the browser, it will also show the current temperature measured by the device in the HTML element below the connect button. | ||
@@ -205,4 +205,4 @@ | ||
- `start` - Starts sending absolute orientation data from the connected device. | ||
- `stop` - Terminates sending absolute orientation data from the connected device. | ||
- `start` - Starts sending absolute orientation data from the connected device | ||
- `stop` - Terminates sending absolute orientation data from the connected device | ||
@@ -216,3 +216,3 @@ ### Advertising Parameters | ||
- `read` - Reads the connected device's advertising parameters. | ||
- `read` - Reads the connected device's advertising parameters | ||
- `write` - Writes the advertising parameters of the connected device. | ||
@@ -233,5 +233,5 @@ - **Parameters**: | ||
- `start` - Starts sending battery level data from the connected device. | ||
- `stop` - Terminates sending battery level data from the connected device. | ||
- `read` - Reads the connected device's battery level. | ||
- `start` - Starts sending battery level data from the connected device | ||
- `stop` - Terminates sending battery level data from the connected device | ||
- `read` - Reads the connected device's battery level | ||
@@ -247,4 +247,4 @@ ### Button | ||
- `start` - Starts sending button data from the connected device. | ||
- `stop` - Terminates sending button data from the connected device. | ||
- `start` - Starts sending button data from the connected device | ||
- `stop` - Terminates sending button data from the connected device | ||
@@ -258,3 +258,3 @@ ### Cloud Token | ||
- `read` - Reads the cloud token currently written to the connected device. | ||
- `read` - Reads the cloud token currently written to the connected device | ||
- `write` - Writes the cloud token of the connected device. | ||
@@ -273,4 +273,4 @@ - **Parameters**: | ||
- `start` - Starts sending color data from the connected device. | ||
- `stop` - Terminates sending color data from the connected device. | ||
- `start` - Starts sending color data from the connected device | ||
- `stop` - Terminates sending color data from the connected device | ||
@@ -284,3 +284,3 @@ ### Connection Parameters | ||
- `read` - Reads the connected device's connection parameters. | ||
- `read` - Reads the connected device's connection parameters | ||
- `write` - Writes the connection parameters of the connected device. | ||
@@ -295,5 +295,6 @@ - **Parameters**: | ||
### DFU | ||
`thingy.dfucontrolpoint` | ||
`thingy.dfucontrolpoint_v1` | ||
`thingy.dfucontrolpoint_v2` | ||
Allows interaction with the connected device's DFU service (Device Firmware Upgrade) | ||
Allows interaction with the connected device's DFU service (Device Firmware Upgrade). Note that depending on which firmware version the Thingy has, the characteristic is different. If the firmware is version 1.x, use the 'thingy.dfucontrolpoint_v1' characteristic. If it is 2.x, use the 'thingy.dfucontrolpoint_v2' characteristic. This is due to a change in the UUID of the service from firmware version 1.1.0 to 2.0.0. | ||
@@ -315,3 +316,3 @@ **Supported operations** | ||
- `read` - Reads the connected device's eddystone url. | ||
- `read` - Reads the connected device's eddystone url | ||
- `write` - Writes the eddystone url of the connected device. | ||
@@ -328,4 +329,4 @@ - **Parameters**: | ||
- `read` - Reads the connected device's current environment configuration. | ||
- `write` - Writes the environment configuration of the connected device. | ||
- `read` - Reads the connected device's current environment configuration | ||
- `write` - Writes the environment configuration of the connected device | ||
- **Parameters**: | ||
@@ -352,4 +353,4 @@ - Object: | ||
- `start` - Starts sending euler orientation data from the connected device. | ||
- `stop` - Terminates sending euler orientation data from the connected device. | ||
- `start` - Starts sending euler orientation data from the connected device | ||
- `stop` - Terminates sending euler orientation data from the connected device | ||
@@ -363,3 +364,3 @@ ### Firmware | ||
- `read` - Reads the current firmware version deployed on the device. | ||
- `read` - Reads the current firmware version deployed on the device | ||
@@ -376,4 +377,4 @@ | ||
- `start` - Starts sending gas data from the connected device. | ||
- `stop` - Terminates sending gas data from the connected device. | ||
- `start` - Starts sending gas data from the connected device | ||
- `stop` - Terminates sending gas data from the connected device | ||
@@ -389,4 +390,4 @@ ### Gravity vector | ||
- `start` - Starts sending gravity vector data from the connected device. | ||
- `stop` - Terminates sending gravity vector data from the connected device. | ||
- `start` - Starts sending gravity vector data from the connected device | ||
- `stop` - Terminates sending gravity vector data from the connected device | ||
@@ -402,4 +403,4 @@ ### Heading | ||
- `start` - Starts sending heading data from the connected device. | ||
- `stop` - Terminates sending heading data from the connected device. | ||
- `start` - Starts sending heading data from the connected device | ||
- `stop` - Terminates sending heading data from the connected device | ||
@@ -415,4 +416,4 @@ ### Humidity | ||
- `start` - Starts sending humidity data from the connected device. | ||
- `stop` - Terminates sending humidity data from the connected device. | ||
- `start` - Starts sending humidity data from the connected device | ||
- `stop` - Terminates sending humidity data from the connected device | ||
@@ -426,4 +427,4 @@ ### LED | ||
- `read` - reads the connected device's current LED configuration. | ||
- `write` - Writes the LED configuration of the connected device. | ||
- `read` - reads the connected device's current LED configuration | ||
- `write` - Writes the LED configuration of the connected device | ||
- **Parameters**: | ||
@@ -453,4 +454,4 @@ - Object: | ||
- `start` - Starts sending microphone data from the connected device. | ||
- `stop` - Terminates sending microphone data from the connected device. | ||
- `start` - Starts sending microphone data from the connected device | ||
- `stop` - Terminates sending microphone data from the connected device | ||
@@ -464,4 +465,4 @@ ### Motion Configuration | ||
- `read` - Reads the connected device's current motion configuration. | ||
- `write` - Writes the motion configuration of the connected device. | ||
- `read` - Reads the connected device's current motion configuration | ||
- `write` - Writes the motion configuration of the connected device | ||
- **Parameters**: | ||
@@ -482,3 +483,3 @@ - Object: | ||
- `read` - Reads the MTU of the connected device. | ||
- `read` - Reads the MTU of the connected device | ||
- `write` - Writes the MTU of the connected device. | ||
@@ -496,3 +497,3 @@ - **Parameters**: | ||
- `read` - Reads the name of the connected device. | ||
- `read` - Reads the name of the connected device | ||
- `write` - Writes the name of the connected device. | ||
@@ -511,4 +512,4 @@ - **Parameters**: | ||
- `start` - Starts sending pressure data from the connected device. | ||
- `stop` - Terminates sending pressure data from the connected device. | ||
- `start` - Starts sending pressure data from the connected device | ||
- `stop` - Terminates sending pressure data from the connected device | ||
@@ -524,4 +525,4 @@ ### Quaternion orientation | ||
- `start` - Starts sending quaternion orientation data from the connected device. | ||
- `stop` - Terminates sending quaternion orientation data from the connected device. | ||
- `start` - Starts sending quaternion orientation data from the connected device | ||
- `stop` - Terminates sending quaternion orientation data from the connected device | ||
@@ -537,4 +538,4 @@ ### Raw data | ||
- `start` - Starts sending raw data from the connected device. | ||
- `stop` - Terminates sending raw data from the connected device. | ||
- `start` - Starts sending raw data from the connected device | ||
- `stop` - Terminates sending raw data from the connected device | ||
@@ -550,4 +551,4 @@ ### Rotation matrix orientation | ||
- `start` - Starts sending rotation matrix orientation data from the connected device. | ||
- `stop` - Terminates sending rotation matrix orientation data from the connected device. | ||
- `start` - Starts sending rotation matrix orientation data from the connected device | ||
- `stop` - Terminates sending rotation matrix orientation data from the connected device | ||
@@ -561,4 +562,4 @@ ### Sound Configuration | ||
- `read` - Reads the connected device's current sound configuration. | ||
- `write` - Writes the sound configuration of the connected device. | ||
- `read` - Reads the connected device's current sound configuration | ||
- `write` - Writes the sound configuration of the connected device | ||
- **Parameters**: | ||
@@ -582,3 +583,3 @@ - Object: | ||
- `write` - Writes to the speaker of the connected device. | ||
- `write` - Writes to the speaker of the connected device | ||
- **Parameters**: | ||
@@ -605,4 +606,4 @@ - Object: | ||
- `start` - Starts sending the speaker status from the connected device. | ||
- `stop` - Terminates sending the speaker status from the connected device. | ||
- `start` - Starts sending the speaker status from the connected device | ||
- `stop` - Terminates sending the speaker status from the connected device | ||
@@ -618,4 +619,4 @@ ### Step counter | ||
- `start` - Starts sending step counter data from the connected device. | ||
- `stop` - Terminates sending step counter data from the connected device. | ||
- `start` - Starts sending step counter data from the connected device | ||
- `stop` - Terminates sending step counter data from the connected device | ||
@@ -631,4 +632,4 @@ ### Tap | ||
- `start` - Starts sending tap data from the connected device. | ||
- `stop` - Terminates sending tap data from the connected device. | ||
- `start` - Starts sending tap data from the connected device | ||
- `stop` - Terminates sending tap data from the connected device | ||
@@ -644,3 +645,3 @@ ### Temperature | ||
- `start` - Starts sending temperature data from the connected device. | ||
- `stop` - Terminates sending temperature data from the connected device. | ||
- `start` - Starts sending temperature data from the connected device | ||
- `stop` - Terminates sending temperature data from the connected device |
@@ -6,4 +6,4 @@ { | ||
"target": "es5", | ||
"outDir": "build", | ||
"checkJs": true, | ||
"outDir": "es5", | ||
"checkJs": false, | ||
"lib": [ | ||
@@ -15,7 +15,9 @@ "es6", | ||
"exclude": [ | ||
"index.js", | ||
"node_modules", | ||
"docs", | ||
"build", | ||
"ts" | ||
"ts", | ||
"es5" | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
452982
85
8206
615
2