Skip to content

Commit

Permalink
fix: Improve debug log in BLE connection (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loodyy authored Dec 3, 2024
1 parent cdf1842 commit 4525694
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/device/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ export abstract class deviceBase {
// Set an event handler
let serviceData = { model: this.device.bleModel, modelName: this.device.bleModelName } as ad['serviceData']
switchbot.onadvertisement = (ad: ad) => {
this.debugLog(`ad: ${JSON.stringify(ad, null, ' ')}`)
if (this.device.bleMac === ad.address && ad.serviceData.model === this.device.bleModel) {
this.debugLog(`${JSON.stringify(ad, null, ' ')}`)
this.debugLog(`address: ${ad.address}, model: ${ad.serviceData.model}`)
Expand Down
2 changes: 1 addition & 1 deletion src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2630,7 +2630,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
async connectBLE(accessory: PlatformAccessory, device: device & devicesConfig): Promise<any> {
try {
queueScheduler.schedule(async () => this.switchBotBLE)
this.debugLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${this.switchBotBLE}`)
this.debugLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${JSON.stringify(this.switchBotBLE, null, ' ')}`)
return this.switchBotBLE
} catch (e: any) {
this.errorLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' not found, Error: ${e.message ?? e}`)
Expand Down

0 comments on commit 4525694

Please sign in to comment.