Open mvenditto opened 8 years ago
@mvenditto
So i'm wondering if are negative values causing the problem (missing conversion?)
Yes, I think the following change is needed:
this.writeUInt8Characteristic(ESTIMOTE_SERVICE_UUID, POWER_LEVEL_UUID, rawLevel, callback);
should be:
this.writeInt8Characteristic(ESTIMOTE_SERVICE_UUID, POWER_LEVEL_UUID, rawLevel, callback);
It would be great if you could try this out and maybe submit a pull request.
Hi,
I have experienced the same problem but i think another solution could be to leave the 'write' method unchanged
this.writeUInt8Characteristic(ESTIMOTE_SERVICE_UUID, POWER_LEVEL_UUID, rawLevel, callback);
and add a conversion in writePowerLevel function:
Estimote.prototype.writePowerLevel = function(powerLevel, callback) {
if (powerLevel < 1) {
powerLevel = 1;
} else if (powerLevel > 8) {
powerLevel = 8;
}
var POWER_LEVEL_MAPPER = {
1: -30,
2: -20,
3: -16,
4: -12,
5: -8,
6: -4,
7: 0,
8: 4
};
var rawLevel = POWER_LEVEL_MAPPER[powerLevel];
var rawLevel = var rawLevel & 0xFF // ex. -12 --> 244
this.writeUInt8Characteristic(ESTIMOTE_SERVICE_UUID, POWER_LEVEL_UUID, rawLevel, callback);
};
@dross94 that could also work.
I'd prefer to add/use writeInt8Characteristic
to/from noble-device.
Hello,
When i try to use Estimote.writePowerLevel passing a value other than 7 or 8 i get the following error:
I noticed that power levels 7 and 8 are the only one mapped with >= 0 values and the error is thrown when triyng to write the value to buffer in writeUInt8Characteristic.
So i'm wondering if are negative values causing the problem (missing conversion?) or there is something wrong with my code ?
Thank you in advance.