Skip to content

Revise eddystone scanner (Bugfix)#2260

Open
stanley31huang wants to merge 3 commits intomainfrom
revise_eddystone_scanner
Open

Revise eddystone scanner (Bugfix)#2260
stanley31huang wants to merge 3 commits intomainfrom
revise_eddystone_scanner

Conversation

@stanley31huang
Copy link
Collaborator

@stanley31huang stanley31huang commented Dec 22, 2025

Description

This PR include the fixed in #1967, also compitable with Bluetooth 5.0 controller without LE extneded advertising support.

In currently implementation, it will issue HCI command to retrieve the LE Extended Advertising Capability then issue corresponding Scan Enable command

Resolved issues

Documentation

Tests

Verified on RPi4 with bluetooth 5.0 controller

ubuntu@ubuntu:~$ sudo hciconfig -a hci0
hci0:	Type: Primary  Bus: UART
	BD Address: D8:3A:DD:2A:E8:D5  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING 
	RX bytes:204717 acl:0 sco:0 events:6837 errors:0
	TX bytes:2820 acl:0 sco:0 commands:356 errors:0
	Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH SNIFF 
	Link mode: PERIPHERAL ACCEPT 
	Name: 'ubuntu'
	Class: 0x6c041c
	Service Classes: Rendering, Capturing, Audio, Telephony
	Device Class: Audio/Video, Portable Audio
	HCI Version: 5.0 (0x9)  Revision: 0x172
	LMP Version: 5.0 (0x9)  Subversion: 0x6119
	Manufacturer: Cypress Semiconductor (305)

ubuntu@ubuntu:~$ sudo checkbox-ce-oem.shell 
We are deprecating the classic frontend Checkbox snaps
Consider switching to the strict frontend

checkbox-ce-oem runtime shell, type 'exit' to quit the session
root@ubuntu:/home/ubuntu# PYTHONPATH=checkbox-support/ python3 checkbox-support/checkbox_support/scripts/eddystone_scanner.py

====================================
Attempt 1/3 (function 'beacon_scan')
====================================
# Checking the LE Extended advertising capability
Received response from controller.
Raw 8-byte LE feature mask: 3f 0 0 8 0 0 0 0
# Extended advertising support: False
# Checking the LE Extended advertising length
HCI command failed with status 0x01.
Failed to get the max_advertising_data_length from controller, return '255'
# Max advertising data length: 255
# Issue LE Set Scan Enable to 'False' by hci command
# Issue LE Set Scan Parameters by hci command
# Issue LE Set Scan Enable to 'True' by hci command
Warning: HCI Command failed. Error code: 0xc, Payload: 0x4 0xe 0x4 0x1 0xc 0x20 0xc
  Found an eddystone report
Eddystone beacon detected: [Adv Report Type: LE_ADVERTISING_REPORT(2)] URL: https://www.ubuntu.com.com/ <mac: c2:c7:b7:7f:ca:33> <rssi: -49>
# Issue LE Set Scan Enable to 'False' by hci command
root@ubuntu:/home/ubuntu#

Tested on an IoT product with bluetooth 6.0 and bluetooth 5.4 controller

ubuntu@localhost:~$ sudo checkbox-ce-oem.shell
checkbox-ce-oem runtime shell, type 'exit' to quit the session
root@localhost:/home/ubuntu# PYTHONPATH=checkbox-support/ python3 checkbox-support/checkbox_support/scripts/eddystone_scanner.py -D hci0

====================================
Attempt 1/3 (function 'beacon_scan')
====================================
# Checking the LE Extended advertising capability
Received response from controller.
Raw 8-byte LE feature mask: 2d f9 0 1 0 18 0 0
# Extended advertising support: True
# Checking the LE Extended advertising length
# Max advertising data length: 1650
# Issue LE Set Extended Scan Enable to 'False' by hci command
# Issue LE Set Extended Scan Parameters by hci command
# Issue LE Set Extended Scan Enable to 'True' by hci command
  Found an eddystone report
Eddystone beacon detected: [Adv Report Type: LE_EXT_ADVERTISING_REPORT(13)] URL: https://www.ubuntu.com.com/ <mac: c2:c7:b7:7f:ca:33> <rssi: -54>
  Found an eddystone report
# Issue LE Set Extended Scan Enable to 'False' by hci command

root@localhost:/home/ubuntu# PYTHONPATH=checkbox-support/ python3 checkbox-support/checkbox_support/scripts/eddystone_scanner.py -D hci1

====================================
Attempt 1/3 (function 'beacon_scan')
====================================
# Checking the LE Extended advertising capability
Received response from controller.
Raw 8-byte LE feature mask: fd 79 0 3 10 19 0 0
# Extended advertising support: True
# Checking the LE Extended advertising length
# Max advertising data length: 62
# Issue LE Set Extended Scan Enable to 'False' by hci command
# Issue LE Set Extended Scan Parameters by hci command
# Issue LE Set Extended Scan Enable to 'True' by hci command
  Found an eddystone report
Eddystone beacon detected: [Adv Report Type: LE_EXT_ADVERTISING_REPORT(13)] URL: https://www.ubuntu.com.com/ <mac: c2:c7:b7:7f:ca:33> <rssi: -57>
# Issue LE Set Extended Scan Enable to 'False' by hci command

Tested on Lenovo laptop with Realtek wireless interface: https://pastebin.canonical.com/p/M8dFbXgxmj/

@stanley31huang stanley31huang changed the title Revise eddystone scanner Revise eddystone scanner (Bugfix) Dec 22, 2025
@stanley31huang stanley31huang marked this pull request as draft December 22, 2025 12:01
@stanley31huang stanley31huang force-pushed the revise_eddystone_scanner branch from 9955621 to 81a9101 Compare December 22, 2025 12:05
@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.86%. Comparing base (0092647) to head (1e83b7b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2260      +/-   ##
==========================================
+ Coverage   53.82%   53.86%   +0.03%     
==========================================
  Files         406      406              
  Lines       43289    43286       -3     
  Branches     7997     7998       +1     
==========================================
+ Hits        23301    23314      +13     
+ Misses      19176    19160      -16     
  Partials      812      812              
Flag Coverage Δ
checkbox-support 65.53% <100.00%> (+0.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stanley31huang stanley31huang force-pushed the revise_eddystone_scanner branch 5 times, most recently from 0068178 to 9c94c58 Compare December 23, 2025 10:16
@stanley31huang stanley31huang marked this pull request as ready for review December 24, 2025 01:13
removed older beacontools
revised eddystone scanner scripts for a bluetooth controller without extended advertising support
@stanley31huang stanley31huang force-pushed the revise_eddystone_scanner branch 2 times, most recently from 61998df to 8262bf4 Compare January 6, 2026 02:01
@stanley31huang stanley31huang force-pushed the revise_eddystone_scanner branch from 8262bf4 to 915ec8c Compare January 8, 2026 09:30
update eddystone unit tests
@stanley31huang stanley31huang force-pushed the revise_eddystone_scanner branch from 915ec8c to 1e83b7b Compare January 8, 2026 09:41
@pieqq
Copy link
Collaborator

pieqq commented Jan 16, 2026

@copilot

Copy link

Copilot AI commented Jan 16, 2026

@pieqq I've opened a new pull request, #2293, to work on those changes. Once the pull request is ready, I'll request review from you.

@pieqq pieqq requested a review from Copilot January 23, 2026 08:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the eddystone scanner to properly support both Bluetooth 5.0 controllers without LE Extended Advertising and newer Bluetooth 5.4/6.0 controllers with extended advertising capabilities. The implementation now dynamically detects controller capabilities and issues the appropriate HCI commands.

Changes:

  • Added dynamic detection of LE Extended Advertising support via HCI commands
  • Updated scanner callback signature to include report type information
  • Replaced fallback mechanism with retry decorator and improved error handling

Reviewed changes

Copilot reviewed 3 out of 29 changed files in this pull request and generated 2 comments.

File Description
checkbox-support/checkbox_support/tests/test_vendor_beacontools_scanner.py Added comprehensive unit tests for Monitor class methods including extended advertising detection, scan parameter configuration, and packet processing
checkbox-support/checkbox_support/tests/test_eddystone_scanner.py Updated tests to match new callback signature and replaced timeout/retry logic with mock decorators
checkbox-support/checkbox_support/scripts/eddystone_scanner.py Refactored beacon_scan to use retry decorator, added debug flag, and updated callback to include report type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +68 to +69
while time.time() - start < TIMEOUT:
if beacon_packet:
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The while loop continuously checks conditions without any delay between iterations, potentially consuming excessive CPU resources. Consider adding a small sleep interval (e.g., time.sleep(0.1)) inside the loop to reduce CPU usage while waiting for beacon packets.

Copilot uses AI. Check for mistakes.
Comment on lines +80 to 82
break
scanner.stop()
if beacon_packet:
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition 'if beacon_packet' is checked twice: once inside the loop (line 69) and again after the loop (line 82). This is redundant since breaking from the loop guarantees beacon_packet is truthy. Consider restructuring to eliminate the duplicate check.

Copilot uses AI. Check for mistakes.
@pieqq pieqq self-assigned this Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants