<commit_before>import { Injectable } from '@angular/core';

/**
 * Class for the devices, this makes it possible to specify the
 * device type in typescript to avoid getting invalid device-objects
 */
export class Device {
  id: string;
  name: string;
  connected: boolean;
  ledOn: boolean;
  buttonPressed?: boolean;
}

@Injectable()
export class DevicesService {
	devices: Device[];

  constructor() {
    this.devices = [];
  };

  /**
   * Returns mock devices for testing purposes
   */
  getMockDevices = (): Device[] => ([
  	{id: '01:23:45:67:89:AB', name: 'TI SensorTag1', connected: false, ledOn: false, buttonPressed: true},
  	{id: '01:23:45:67:89:AC', name: 'TI SensorTag2', connected: true, ledOn: true, buttonPressed: true},
  	{id: '01:23:45:67:89:AD', name: 'TI SensorTag3', connected: false, ledOn: false, buttonPressed: true},
  ]);

  /**
   * Returns the list of devices currently stored
   */
  getDevices = (): Device[] => {
    //alert('providing devices from devicesService: ' + this.devices.toString())
  	return this.devices;
  };

  /**
   * Adds a new device to the list of devices
   * @param {Device} device - the device to add
   */
  newDevice = (device: Device) => {
    if (this.isNewDevice(device)){
      this.devices.push(device);
      //alert('device added: ' + JSON.stringify(device));
    }
  };

  /**
   * Converts the device discovered by ble into a device on the tiles format
   * @param {any} bleDevice - the returned device from the ble scan
   */
  convertBleDeviceToDevice = (bleDevice: any): Device  => {
    /*const device: Device = {
      id: '01:23:45:67:89:AB',
      name: 'TI SensorTag1',
      connected: false,
      ledOn: false
    };*/
    const device: Device = {
      id: bleDevice.id,
      name: (bleDevice.name ? bleDevice.name : 'NoName'),
      connected: false, 
      ledOn: false,
      buttonPressed: false
    };

    return device;
  };<commit_msg>Added bleDevice json strucure example<commit_after>import { Injectable } from '@angular/core';

/**
 * Class for the devices, this makes it possible to specify the
 * device type in typescript to avoid getting invalid device-objects
 */
export class Device {
  id: string;
  name: string;
  connected: boolean;
  ledOn: boolean;
  buttonPressed?: boolean;
}

@Injectable()
export class DevicesService {
	devices: Device[];

  constructor() {
    this.devices = [];
  };

  /**
   * Returns mock devices for testing purposes
   */
  getMockDevices = (): Device[] => ([
  	{id: '01:23:45:67:89:AB', name: 'TI SensorTag1', connected: false, ledOn: false, buttonPressed: true},
  	{id: '01:23:45:67:89:AC', name: 'TI SensorTag2', connected: true, ledOn: true, buttonPressed: true},
  	{id: '01:23:45:67:89:AD', name: 'TI SensorTag3', connected: false, ledOn: false, buttonPressed: true},
  ]);

  /**
   * Returns the list of devices currently stored
   */
  getDevices = (): Device[] => {
    //alert('providing devices from devicesService: ' + this.devices.toString())
  	return this.devices;
  };

  /**
   * Adds a new device to the list of devices
   * @param {Device} device - the device to add
   */
  newDevice = (device: Device) => {
    if (this.isNewDevice(device)){
      this.devices.push(device);
      //alert('device added: ' + JSON.stringify(device));
    }
  };

  /**
   * Converts the device discovered by ble into a device on the tiles format
   * @param {any} bleDevice - the returned device from the ble scan
   */
  convertBleDeviceToDevice = (bleDevice: any): Device  => {
    /*
    bleDevice = {
      "id" : "01:23:45:67:89:AB",
      "advertising" : {},
      "rssi" : -99
    }
    */
    /*const device: Device = {
      id: '01:23:45:67:89:AB',
      name: '<NAME>',
      connected: false,
      ledOn: false
    };*/
    const device: Device = {
      id: bleDevice.id,
      name: (bleDevice.name ? bleDevice.name : 'NoName'),
      connected: false, 
      ledOn: false,
      buttonPressed: false
    };

    return device;
  };
{'fraction_non_alphanumeric': 0.1464393179538616, 'fraction_numerical': 0.02482447342026078, 'mean_word_length': 3.01307847082495, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 12, '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': '3386193', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1287, 'n_words': 375}