<NME> webpageCharacteristic.js
<BEF> var util = require('util');
var bleno = require('bleno');
var CHARACTERISTIC_UUID = 'd1a517f0-2499-46ca-9ccc-809bc1c966fa';

var WebpageCharacteristic = function() {
  WebpageCharacteristic.super_.call(this, {
    uuid: CHARACTERISTIC_UUID,
    properties: ['read'],
    value: null
  });

  this._value = Buffer.alloc(0);
  this._updateValueCallback = null;
};

util.inherits(WebpageCharacteristic, bleno.Characteristic);

WebpageCharacteristic.prototype.onReadRequest = function(offset, callback) {
  console.log(`Reading - ${this._value}`);
  callback(this.RESULT_SUCCESS, this._value);
};

WebpageCharacteristic.prototype.onWriteRequest = function(data, offset, withoutResponse, callback) {
  this._value = data;

  console.log(`Writing ${this._value.length} bytes`);

  if (this._updateValueCallback) {
    console.log('WebpageCharacteristic - onWriteRequest: notifying');

    this._updateValueCallback(this._value);
  }

  if(callback) {
    callback(this.RESULT_SUCCESS);
  }
};

WebpageCharacteristic.prototype.onSubscribe = function(maxValueSize, updateValueCallback) {
  console.log('WebpageCharacteristic - onSubscribe');
  this._updateValueCallback = updateValueCallback;
};

WebpageCharacteristic.prototype.onUnsubscribe = function() {
  console.log('WebpageCharacteristic - onUnsubscribe');
  this._updateValueCallback = null;
};

module.exports = WebpageCharacteristic;

<MSG> Merge pull request #887 from iankchristie/fileServing

File serving
<DFF> @@ -11,13 +11,24 @@ var WebpageCharacteristic = function() {
 
   this._value = Buffer.alloc(0);
   this._updateValueCallback = null;
+
+  this._mtuSize = 251;  // 5 less than the specified mtu
+  this._start = 0;
+  this._end = this._mtuSize;
 };
 
 util.inherits(WebpageCharacteristic, bleno.Characteristic);
 
 WebpageCharacteristic.prototype.onReadRequest = function(offset, callback) {
-  console.log(`Reading - ${this._value}`);
-  callback(this.RESULT_SUCCESS, this._value);
+  var tempBuffer = this._value.slice(this._start, this._end);
+  callback(this.RESULT_SUCCESS, tempBuffer);
+
+  this._start = this._end;
+  this._end = this._end + this._mtuSize;
+  if(this._start >= this._value.length) {
+    this._start = 0;
+    this._end = this._mtuSize;
+ }
 };
 
 WebpageCharacteristic.prototype.onWriteRequest = function(data, offset, withoutResponse, callback) {

{'addition_count': 13, 'commit_subject': 'Merge pull request #887 from iankchristie/fileServing', 'deletion_count': 2, 'file_extension': '.js', 'lang': 'js', 'license': 'apache-2.0', 'repo_name': 'google/physical-web'}