Skip to content

Commit

Permalink
fix(bluetooth-classic): fix device rotation logic
Browse files Browse the repository at this point in the history
This may address #288, requires testing by someone that can reproduce
the issue though.
  • Loading branch information
mKeRix committed Oct 17, 2020
1 parent 607975f commit 15f5f89
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class BluetoothClassicService
distributeInquiries(): void {
if (this.clusterService.isMajorityLeader()) {
const nodes = this.getParticipatingNodes();
const addresses = this.config.addresses;
const addresses = [...this.config.addresses];
if (this.rotationOffset >= Math.max(nodes.length, addresses.length)) {
this.rotationOffset = 0;
}
Expand All @@ -190,7 +190,7 @@ export class BluetoothClassicService
nodeSubset.forEach((node, index) => {
if (addressSubset[index] == null) {
this.logger.error(
`Trying to request inquiry without MAC! Current index: ${index}. Addresses in this round: ${addressSubset}. Nodes in this round: ${nodeSubset}.`
`Trying to request inquiry without MAC! Current index: ${this.rotationOffset}. Addresses in this round: ${addressSubset}. Addresses overall: ${addresses}.`
);
}

Expand Down Expand Up @@ -405,9 +405,7 @@ export class BluetoothClassicService
const [small, large] = a1.length > a2.length ? [a2, a1] : [a1, a2];
const largeSubset = large.slice(offset, offset + small.length);
if (offset + small.length > large.length) {
largeSubset.push(
...large.slice(0, small.length - this.rotationOffset + 1)
);
largeSubset.push(...large.slice(0, small.length - largeSubset.length));
}

return a1.length > a2.length ? [largeSubset, a2] : [a1, largeSubset];
Expand Down

0 comments on commit 15f5f89

Please sign in to comment.