Skip to content
This repository was archived by the owner on Mar 17, 2020. It is now read-only.

Commit 4b569aa

Browse files
committed
Use Uint8 for temperature
Signed-off-by: Sakari Poussa <sakari.poussa@intel.com>
1 parent b53611e commit 4b569aa

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

server/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ util.inherits(TemperatureCharacteristic, bleno.Characteristic);
3030

3131
TemperatureCharacteristic.prototype.onReadRequest = function(offset, callback) {
3232
var data = new Buffer(8);
33-
data.writeDoubleLE(this._lastValue, 0);
33+
data.writeUInt8(this._lastValue);
3434
callback(this.RESULT_SUCCESS, data);
3535
};
3636

@@ -68,7 +68,7 @@ TemperatureCharacteristic.prototype.valueChange = function(value) {
6868
console.log("Temperature change " + newValue);
6969

7070
var data = new Buffer(8);
71-
data.writeDoubleLE(newValue, 0);
71+
data.writeUInt8(newValue);
7272

7373
if (this._onChange) {
7474
this._onChange(data);

static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
let data = event.target.value;
292292
// In Chrome 50+, a DataView is returned instead of an ArrayBuffer.
293293
data = data.buffer ? data : new DataView(data);
294-
let temperature = data.getFloat64(0, /*littleEndian=*/ true);
294+
let temperature = data.getUint8(0);
295295
document.querySelector('#temp').innerHTML = temperature.toFixed(0);
296296

297297
let date = (new Date()).toString().replace(/^.* (\d+:\d+:\d+).*$/, (match, p) => p);

0 commit comments

Comments
 (0)