diff --git a/server.js b/server.js index b9f6959f8a5eb3db5382c8ad5db500023328aac4..e33e06422a599e5dff2a556233b3ea2914759c46 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;