From e3b21dfe249f5d5a46802e0811ff6d05330ea362 Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Mon, 12 Mar 2018 01:41:40 +0000 Subject: [PATCH] Check if attribute handle supports emit before calling Origin: https://github.com/noble/bleno/pull/369 Change-Id: Icdc68c129ab7b165f5b30e15812e9d7316346146 --- lib/hci-socket/gatt.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/hci-socket/gatt.js b/lib/hci-socket/gatt.js index 18dc52b..c5b2fe8 100644 --- a/lib/hci-socket/gatt.js +++ b/lib/hci-socket/gatt.js @@ -911,7 +911,9 @@ Gatt.prototype.handleWriteRequestOrCommand = function(request) { handleAttribute.emit('subscribe', this._mtu - 3, updateValueCallback); } } else { - handleAttribute.emit('unsubscribe'); + if (handleAttribute.emit) { + handleAttribute.emit('unsubscribe'); + } } result = ATT_ECODE_SUCCESS;