<commit_before>import { Body, ContentType, Get, JsonController, NotFoundError, Param, Post } from 'routing-controllers';

import { HitTrackerDeviceManager, ILedZonesConfig } from '../ble';

import { logger } from '../logging';

import { Inject } from 'typedi';

@JsonController()
export class UnitController {
  private timer!: NodeJS.Timer;
  private deviceManager: HitTrackerDeviceManager;

  constructor(@Inject('device-manager') deviceManager: HitTrackerDeviceManager) {
    this.deviceManager = deviceManager;
  }

  @Post('/unit/:address')
  @ContentType('application/json')
  public async setLedConfiguration(
    @Param('address') address: string,
    @Body({ required: true, validate: true })
    ledZoneConfigs: ILedZonesConfig
  ) {
    if (!this.deviceManager.hasDevice(address)) {
      throw new NotFoundError(`Peripheral ${address} was not found`);
    }
    logger.debug(`Setting unit ${address} LED configuration  to ${JSON.stringify(ledZoneConfigs)}`);
    try {
      await this.deviceManager.stopScanning();

      await this.deviceManager.getDevice(address).setLedConfiguration(ledZoneConfigs);
      await this.deviceManager.startScanning();
    } catch (error) {
      logger.error(error);<commit_msg>pull in LedZonesConfig into UnitController<commit_after>import { Body, ContentType, Get, JsonController, NotFoundError, Param, Post } from 'routing-controllers';

import { HitTrackerDeviceManager } from '../ble';
import { ILedZonesConfig } from '../interfaces';
import { logger } from '../logging';

import { Inject } from 'typedi';

@JsonController()
export class UnitController {
  private timer!: NodeJS.Timer;
  private deviceManager: HitTrackerDeviceManager;

  constructor(@Inject('device-manager') deviceManager: HitTrackerDeviceManager) {
    this.deviceManager = deviceManager;
  }

  @Post('/unit/:address')
  @ContentType('application/json')
  public async setLedConfiguration(
    @Param('address') address: string,
    @Body({ required: true, validate: true })
    ledZoneConfigs: ILedZonesConfig
  ) {
    if (!this.deviceManager.hasDevice(address)) {
      throw new NotFoundError(`Peripheral ${address} was not found`);
    }
    logger.debug(`Setting unit ${address} LED configuration  to ${JSON.stringify(ledZoneConfigs)}`);
    try {
      await this.deviceManager.stopScanning();

      await this.deviceManager.getDevice(address).setLedConfiguration(ledZoneConfigs);
      await this.deviceManager.startScanning();
    } catch (error) {
      logger.error(error);
{'fraction_non_alphanumeric': 0.12480063795853269, 'fraction_numerical': 0.0, 'mean_word_length': 4.728310502283105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3082121', 'n_tokens_mistral': 702, 'n_tokens_neox': 709, 'n_words': 164}