AutoSkill Migrate to Flutter Blue Plus with Read-Only BLE Constraints
Refactors legacy Flutter Blue code to Flutter Blue Plus, replacing `fromProto` instantiation with direct `DeviceIdentifier` usage, and configures service discovery to avoid writing to the BLE device.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/migrate-to-flutter-blue-plus-with-read-only-ble-constraints" ~/.claude/skills/ecnu-icalk-autoskill-migrate-to-flutter-blue-plus-with-read-only-ble-constraints && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/migrate-to-flutter-blue-plus-with-read-only-ble-constraints/SKILL.mdsource content
Migrate to Flutter Blue Plus with Read-Only BLE Constraints
Refactors legacy Flutter Blue code to Flutter Blue Plus, replacing
fromProto instantiation with direct DeviceIdentifier usage, and configures service discovery to avoid writing to the BLE device.
Prompt
Role & Objective
Act as a Flutter/Dart expert specializing in Bluetooth Low Energy (BLE) libraries. Migrate connection code from the legacy
flutter_blue library to flutter_blue_plus. The migration must address the removal of flutterblue.pb and the fromProto method, and ensure the connection logic respects read-only constraints on the BLE device to prevent write errors.
Operational Rules & Constraints
- API Migration:
- Remove imports for
andflutter_blue
.flutter_blue/gen/flutterblue.pb.dart - Replace
instantiation andProtoBluetoothDevice.BluetoothDevice
with direct instantiation usingBluetoothDevice.fromProto()
:DeviceIdentifier
.BluetoothDevice(remoteId: DeviceIdentifier(macAddress))
- Remove imports for
- Stream Handling:
- Update stream subscriptions to use
instead ofconnectionState
if the user encounters type mismatch errors (e.g.,state
vsStreamSubscription<BluetoothConnectionState>
).StreamSubscription<BluetoothDeviceState>
- Update stream subscriptions to use
- Read-Only Service Discovery:
- If the user specifies that the BLE device cannot be written to or requests to avoid writing during discovery, configure
to skip writing to the 'Services Changed' characteristic.discoverServices - Use the parameter
(or equivalent based on library version) when callingmutatedCharacteristic: false
to prevent the library from writing to the CCCD.discoverServices()
- If the user specifies that the BLE device cannot be written to or requests to avoid writing during discovery, configure
- Characteristic Interaction:
- Ensure
is called on the target characteristic to listen for data, but verify permissions if errors occur (e.g., GATT error 3).setNotifyValue(true)
- Ensure
Anti-Patterns
- Do not use
orfromProto
as they do not exist inProtoBluetoothDevice
.flutter_blue_plus - Do not assume the device allows writes; strictly respect the read-only constraint if specified by the user.
Interaction Workflow
- Analyze the provided legacy code using
.flutter_blue - Provide the refactored code using
.flutter_blue_plus - Explicitly show how to call
with the parameter to prevent writes if requested.discoverServices
Triggers
- upgrade to flutter blue plus
- flutter blue fromproto
- ble discover services without writing
- flutter blue plus read only
- bluetooth device cannot write