Showing 1 of 5 files from the diff.

@@ -51,7 +51,7 @@
Loading
51 51
    adapterId: number,
52 52
    address: string
53 53
  ): Promise<number> {
54 -
    this.lockAdapter(adapterId);
54 +
    await this.lockAdapter(adapterId);
55 55
56 56
    this.logger.debug(`Querying for RSSI of ${address} using hcitool`);
57 57
    try {
@@ -105,7 +105,7 @@
Loading
105 105
    adapterId: number,
106 106
    address: string
107 107
  ): Promise<Device> {
108 -
    this.lockAdapter(adapterId);
108 +
    await this.lockAdapter(adapterId);
109 109
110 110
    try {
111 111
      const output = await execPromise(
@@ -149,9 +149,14 @@
Loading
149 149
   *
150 150
   * @param adapterId - HCI Device ID of the adapter to lock
151 151
   */
152 -
  protected lockAdapter(adapterId: number): void {
153 -
    if (this.adapterStates.get(adapterId) == 'scan') {
154 -
      noble.stopScanning();
152 +
  async lockAdapter(adapterId: number): Promise<void> {
153 +
    switch (this.adapterStates.get(adapterId)) {
154 +
      case 'inquiry':
155 +
        throw new Error(
156 +
          `Trying to lock adapter ${adapterId} even though it is already locked`
157 +
        );
158 +
      case 'scan':
159 +
        noble.stopScanning();
155 160
    }
156 161
157 162
    this.adapterStates.set(adapterId, 'inquiry');
@@ -162,11 +167,11 @@
Loading
162 167
   *
163 168
   * @param adapterId - HCI Device ID of the adapter to unlock
164 169
   */
165 -
  protected unlockAdapter(adapterId: number): void {
170 +
  async unlockAdapter(adapterId: number): Promise<void> {
166 171
    this.adapterStates.set(adapterId, 'inactive');
167 172
168 173
    if (adapterId == this.lowEnergyAdapterId) {
169 -
      this.handleAdapterStateChange(noble.state);
174 +
      await this.handleAdapterStateChange(noble.state);
170 175
    }
171 176
  }
172 177
@@ -191,13 +196,13 @@
Loading
191 196
   *
192 197
   * @param state - State of the HCI adapter
193 198
   */
194 -
  private handleAdapterStateChange(state: string): void {
199 +
  private async handleAdapterStateChange(state: string): Promise<void> {
195 200
    if (this.adapterStates.get(this.lowEnergyAdapterId) != 'inquiry') {
196 201
      if (state === 'poweredOn') {
197 -
        noble.startScanning([], true);
202 +
        await noble.startScanningAsync([], true);
198 203
        this.adapterStates.set(this.lowEnergyAdapterId, 'scan');
199 204
      } else {
200 -
        noble.stopScanning();
205 +
        await noble.stopScanning();
201 206
        this.adapterStates.set(this.lowEnergyAdapterId, 'inactive');
202 207
      }
203 208
    }
Files Coverage
src 91.65%
Project Totals (86 files) 91.65%
Node.js 12.x
Build #330057063 -
unittests
1
coverage:
2
  status:
3
    project:
4
      default:
5
        threshold: 1
6
    patch:
7
      default:
8
        threshold: 5
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading