Skip to content

Commit

Permalink
Porting to Buffer.from()/Buffer.alloc()
Browse files Browse the repository at this point in the history
  • Loading branch information
leahjessie authored and rzr committed Feb 20, 2021
1 parent dbcad4e commit bfb33fe
Show file tree
Hide file tree
Showing 21 changed files with 1,657 additions and 120 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ bleno.startAdvertisingIBeacon(uuid, major, minor, measuredPower[, callback(error
##### Start advertising with EIR data (__Linux only__)

```javascript
var scanData = new Buffer(...); // maximum 31 bytes
var advertisementData = new Buffer(...); // maximum 31 bytes
var scanData = Buffer.alloc(...); // maximum 31 bytes
var advertisementData = Buffer.alloc(...); // maximum 31 bytes

bleno.startAdvertisingWithEIRData(advertisementData[, scanData, callback(error)]);
```
Expand Down Expand Up @@ -227,7 +227,7 @@ Parameters to handler are

```javascript
var result = Characteristic.RESULT_SUCCESS;
var data = new Buffer( ... );
var data = Buffer.alloc( ... );

callback(result, data);
```
Expand Down
6 changes: 3 additions & 3 deletions examples/battery-service/battery-level-characteristic.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var BatteryLevelCharacteristic = function() {
}),
new Descriptor({
uuid: '2904',
value: new Buffer([0x04, 0x01, 0x27, 0xAD, 0x01, 0x00, 0x00 ]) // maybe 12 0xC unsigned 8 bit
value: Buffer.from([0x04, 0x01, 0x27, 0xAD, 0x01, 0x00, 0x00 ]) // maybe 12 0xC unsigned 8 bit
})
]
});
Expand All @@ -34,11 +34,11 @@ BatteryLevelCharacteristic.prototype.onReadRequest = function(offset, callback)
var percent = data.split('\t')[1].split(';')[0];
console.log(percent);
percent = parseInt(percent, 10);
callback(this.RESULT_SUCCESS, new Buffer([percent]));
callback(this.RESULT_SUCCESS, Buffer.from([percent]));
});
} else {
// return hardcoded value
callback(this.RESULT_SUCCESS, new Buffer([98]));
callback(this.RESULT_SUCCESS, Buffer.from([98]));
}
};

Expand Down
Loading

0 comments on commit bfb33fe

Please sign in to comment.