From 411ad70b4b7e79b5846d367461c7cd3e8777c78d 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 --- 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 818e2176..bcd410a4 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;