Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/4.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Daisuke Baba committed Jun 19, 2017
2 parents beec90d + 3e69354 commit 922fa67
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ $ npm run build
will generate ES5 js files.

# Revision History
* 4.0.1
- Fix an issue where BLE termination cannot be performed while 'close' event
- Fix an issue where localName cannot be resumed

* 4.0.0
- Remove Node.js v0.12 support
- Remove [BLECAST_TM](http://www.robotsfx.com/robot/BLECAST_TM.html) node and [BLECAST_BL](http://www.robotsfx.com/robot/BLECAST_BL.html) node
Expand Down
3 changes: 1 addition & 2 deletions lib/asakusa_giken.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,13 @@
localNames.splice(localNames.indexOf(c.localName), 1);
}
});
$('#node-config-input-localName').append(option);
$('#node-config-input-localName').val(this.localName);
for (i = 0; i < localNames.length; i++) {
var localName = localNames[i];
var option = $('<option></option>').attr('value', localName)
.text(localName);
$('#node-config-input-localName').append(option);
}
$('#node-config-input-localName').val(this.localName);
$('#node-config-input-address').blur(function() {
var text = $(this).val();
if (text && typeof(text) === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-asakusa_giken",
"version": "4.0.0",
"version": "4.0.1",
"description": "Node-RED nodes for Asakusa Giken Devices",
"license": "MIT",
"repository": {
Expand Down
12 changes: 6 additions & 6 deletions src/asakusa_giken.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export default function(RED) {
}
this.name = n.name;

this.on('close', () => {
this.on('close', (done) => {
if (this.bleenvNode) {
bleenv.remove(this, RED);
bleenv.remove(this, done, RED);
}
});
bleenv.clear(RED);
Expand Down Expand Up @@ -77,9 +77,9 @@ export default function(RED) {
}
this.name = n.name;

this.on('close', () => {
this.on('close', (done) => {
if (this.bleioNode) {
bleio.remove(this, RED);
bleio.remove(this, done, RED);
}
});
bleio.clear(RED);
Expand All @@ -103,9 +103,9 @@ export default function(RED) {
}
this.name = n.name;

this.on('close', () => {
this.on('close', (done) => {
if (this.bleioNode) {
bleio.remove(this, RED);
bleio.remove(this, done, RED);
}
});
bleio.clear(RED);
Expand Down
20 changes: 15 additions & 5 deletions src/bleio.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,20 +491,30 @@ function setupPeripheral(peripheral, RED) {
peripheral.connect();
}
};
if (peripheral.removeHandler) {
peripheral.removeHandler();
}
peripheral.on('connect', connectHandler);
peripheral.on('disconnect', disconnectHandler);
peripheral.terminate = () => {
peripheral.removeHandler = () => {
peripheral.removeListener('connect', connectHandler);
peripheral.removeListener('disconnect', disconnectHandler);
};
peripheral.terminate = (done) => {
if (CONN_DEBUG) { RED.log.info(`${TAG}[CONN_DEBUG] (terminate) start terminate!!`); }
peripheral.instrumented = false;
peripheral.terminated = true;
peripheral.removeListener('connect', connectHandler);
peripheral.removeListener('disconnect', disconnectHandler);
peripheral.removeHandler();
if (peripheral.state !== 'disconnected') {
if (CONN_DEBUG) { RED.log.info(`${TAG}[CONN_DEBUG] (terminate) disconnect()`); }
peripheral.disconnect((err) => {
disconnectHandler(err);
ble.stop(RED);
if (CONN_DEBUG) { RED.log.info(`${TAG}[CONN_DEBUG] (terminate) disconnect() done!`); }
ble.start(RED);
if (done) {
done();
}
});
}
};
Expand Down Expand Up @@ -617,7 +627,7 @@ export function register(node, RED) {
if (CONN_DEBUG) { RED.log.info(`${TAG}[CONN_DEBUG] (register) end`); }
}

export function remove(node, RED) {
export function remove(node, done, RED) {
if (!node || !node.bleioNode) {
throw new Error('invalid node');
}
Expand All @@ -644,7 +654,7 @@ export function remove(node, RED) {
delete periphNodes[address][node.id];
if (Object.keys(periphNodes[address]).length === 0) {
if (CONN_DEBUG) { RED.log.info(`${TAG}[CONN_DEBUG] (remove) terminate()`); }
peripheral.terminate();
peripheral.terminate(done);
} else {
if (CONN_DEBUG) { RED.log.info(`${TAG}[CONN_DEBUG] (remove) disconnect()`); }
peripheral.disconnect(); // will re-connect
Expand Down

0 comments on commit 922fa67

Please sign in to comment.