From 6b58e90eb7b6c0908d69b78476c8b3b36ac0aa70 Mon Sep 17 00:00:00 2001 From: Erick Hitter <services@ethitter.com> Date: Sat, 27 Aug 2016 20:33:29 -0700 Subject: [PATCH] Disconnect endpoint --- server.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server.js b/server.js index b9f6959..e33e064 100755 --- a/server.js +++ b/server.js @@ -110,6 +110,21 @@ app.get( '/api/:lock_action(lock|unlock)/:lock_name', cache( '5 seconds' ), func } ); } ); +// Endpoint to disconnect a lock's BLE connections +app.get( '/api/disconnect/:lock_name', function( req, res ) { + // Parse allowed request arguments + var lock = app.get( 'lock' + req.params.lock_name ); + if ( ! lock ) { + clear_caches( req.params.lock_name ); + res.sendStatus( 400 ); + return; + } + + lock.disconnect(); + clear_caches( req.params.lock_name ); + res.sendStatus( 204 ); +} ); + // Convert named status to integer representation function statusStringtoInt( status ) { var statusInt = -1; -- GitLab