• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16export class ScanData {
17  private deviceId: string = '';
18  private deviceName: string = '';
19  private rssi: number = 0;
20  private connectable: boolean = false;
21  private data: Uint8Array = new Uint8Array([0xFF, 0xFF, 0xFF, 0xFF]);
22
23  constructor(deviceId: string = '', deviceName: string = 'null', rssi: number = 0, connectable: boolean = false,
24    data: Uint8Array = new Uint8Array([0xFF, 0xFF, 0xFF, 0xFF])) {
25    this.deviceId = deviceId;
26    this.deviceName = deviceName;
27    this.rssi = rssi;
28    this.connectable = connectable;
29    this.data = data;
30  }
31
32  public setDeviceId(deviceId: string) {
33    this.deviceId = deviceId;
34  }
35
36  public setData(data: Uint8Array) {
37    this.data = data;
38  }
39
40  public getDeviceId(): string {
41    return this.deviceId;
42  }
43
44  public getData(): Uint8Array {
45    return this.data;
46  }
47
48  public setDeviceName(deviceName: string) {
49    this.deviceName = deviceName;
50  }
51
52  public getDeviceName(): string {
53    return this.deviceName;
54  }
55
56  public setRssi(rssi: number) {
57    this.rssi = rssi;
58  }
59
60  public getRssi(): number {
61    return this.rssi;
62  }
63
64  public setConnectable(connectable: boolean) {
65    this.connectable = connectable;
66  }
67
68  public getConnectable(): boolean {
69    return this.connectable;
70  }
71}
72
73let scanData = new ScanData();
74
75export default scanData as ScanData;
76
77