GladysProject/Gladys

View on GitHub
server/services/bluetooth/lib/events/bluetooth.scanStop.js

Summary

Maintainability
A
0 mins
Test Coverage
const logger = require('../../../../utils/logger');

/**
 * @description When the Bluetooth stops scanning.
 * @example
 * bluetooth.on('startStop', this.scanStop);
 */
async function scanStop() {
  if (this.scanTimer) {
    clearTimeout(this.scanTimer);
    this.scanTimer = undefined;
  }
  this.scanCounter = 0;

  logger.debug(`Bluetooth: stop scanning`);

  this.scanning = false;
  this.broadcastStatus();
}

module.exports = {
  scanStop,
};