Skip to content

Revise eddystone scanner (Bugfix)#2260

Merged
pieqq merged 5 commits intomainfrom
revise_eddystone_scanner
Mar 20, 2026
Merged

Revise eddystone scanner (Bugfix)#2260
pieqq merged 5 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 55.11%. Comparing base (0092647) to head (11df8fa).
⚠️ Report is 111 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2260      +/-   ##
==========================================
+ Coverage   53.82%   55.11%   +1.28%     
==========================================
  Files         406      410       +4     
  Lines       43289    44791    +1502     
  Branches     7997     8369     +372     
==========================================
+ Hits        23301    24687    +1386     
- Misses      19176    19239      +63     
- Partials      812      865      +53     
Flag Coverage Δ
checkbox-ng 71.57% <ø> (ø)
checkbox-support 70.56% <100.00%> (+5.27%) ⬆️
provider-base 30.91% <ø> (ø)
provider-certification-client 57.14% <ø> (ø)
provider-certification-server 57.14% <ø> (ø)
provider-genio 96.90% <ø> (ø)
provider-gpgpu 93.14% <ø> (ø)
provider-iiotg 100.00% <ø> (ø)
provider-resource 39.57% <ø> (ø)
provider-sru 97.97% <ø> (ø)

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.

@pieqq pieqq self-assigned this Jan 30, 2026
fix eddystone_scanner
fix coding style issue
Copy link
Collaborator

@pieqq pieqq left a comment

Choose a reason for hiding this comment

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

Sorry for the long delay, and thanks for submitting this!

I finally got the time to test it locally.

I setup an Beacon broadcast simulator on my phone (one called Virtual Beacon that allows to create URL shares), set up a virtual beacon with a URL, and ran the test in my Checkbox venv:

(checkbox) root@pieq-X870:/home/pieq/dev/work/checkbox/checkbox-support/checkbox_support/scripts# python3 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: bd 7f ff ff 9e 1 0 0
# Extended advertising support: True
# Checking the LE Extended advertising length
# Max advertising data length: 932
# 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
# Issue LE Set Extended Scan Enable to 'False' by hci command
Eddystone beacon detected: [Adv Report Type: LE_EXT_ADVERTISING_REPORT(13)] URL: https://pouet.net/ <mac: 7e:d5:71:24:c3:8f> <rssi: -88>

All good. Let's land this!

@pieqq pieqq merged commit a948598 into main Mar 20, 2026
91 checks passed
@pieqq pieqq deleted the revise_eddystone_scanner branch March 20, 2026 08:21
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.

4 participants