Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2102 +/- ##
==========================================
+ Coverage 84.31% 84.53% +0.22%
==========================================
Files 201 202 +1
Lines 20656 20950 +294
Branches 1121 1150 +29
==========================================
+ Hits 17417 17711 +294
Misses 3047 3047
Partials 192 192 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Newer Xiaomi Wi-Fi devices built on combo modules (Wi-Fi + BLE, e.g. Bouffalo BL602 advertised as
MIBLE_BL602) no longer open a*_miap*access point after a Wi-Fi reset, soDevice.configure_wifi()cannot reach them. The vendor app provisions them over Bluetooth instead. This PR adds that path.
What's added
miio/ble_provisioning.py: Xiaomi "standard auth" key exchange (ECDH P-256, HKDFmible-setup-info),the framing used on the FE95 service (characteristics 0x0010 / 0x0019), and the encrypted Wi-Fi
configuration package (TLV: uid, ssid, password, gmt offset, country domain, time zone, config type,
country code, optional bind key); MiBeacon parsing to find devices in setup mode.
miiocli ble scanandmiiocli ble provision --ssid ... --uid ... --region ....ble = ["bleak>=0.22"]; bleak is imported lazily, the protocol helpers and the CLIimport work without it.
discovery.rst.Tested on hardware
xiaomi.derh.lite(Xiaomi Smart Dehumidifier Lite), BL602, BLE firmware3.6.5_0581, device firmware1.0.1, from macOS (CoreBluetooth). Findings, also noted in the docs:uidis mandatory: without it the device accepts the package and reports success,but never joins the network (a random bind_key does not help);
miiocli cloud listis neededafterwards; blocking the device's internet access after that keeps local control working;
country_domain(e.g.zz) is accepted, the device joins Wi-Fi but never reaches thecloud.
Sources
The Wi-Fi step was reconstructed from the device side of the protocol in the
com.mijiasdk.bleserverpackage of a decompiled Xiaomi speaker launcher (OpenMico/MicoLauncher), cross-checked with dnandha/miauth,
pvvx's TelinkMiFlasher and dentra's
miot_cwbs01PoC, then confirmed on the device above. No code iscopied from these projects. A standalone script with a longer protocol write-up:
https://github.com/A4E/xiaomi-ble-provision
pytest miio/tests/test_ble_provisioning.py: 7 passed; ruff and mypy are clean for the new module.The 5 failures in
chunmi/cooker_multitests happen on master too (Python 3.14 here).