Comments (6)
You might be running in to the bug where the event that listens to value change event has a typo in it (I still need to release a new version for that)
Try readValue()
to see if it can read a value at all.
Edit: you can also try and import the package from the git directly. https://flutter.dev/docs/development/packages-and-plugins/using-packages
from flutter_web_bluetooth.
@jeroen1602
Hi, thank you for your response.
I tried readValue()
in my code and it threw the error:
Operation not supported for uuid 0000fff1-0000-1000-8000-00805f9b34fb
which is a valid uuid that I've tested before.
ByteData element = await readCharacteristic
.readValue(timeout: Duration(seconds: 5));
I also removed the package from pubspec.yaml
and tried to get the latest version from the repo directly:
flutter_web_bluetooth:
git:
url: git://github.com/jeroen1602/flutter_web_bluetooth.git
and I got the same result.
Am I missing anything?
from flutter_web_bluetooth.
Some operations are not supported based on how the characteristic is set up. You should be able to check what is supported by reading the properties of the characteristic.
But did you also try startNotifications()
again with the version directly from GitHub? Because that one should work with the GitHub version.
from flutter_web_bluetooth.
@jeroen1602
Hi, Sorry for the delay!
I downloaded the package from the repo again and monitored the characteristic's properties (the ones I thought might be relevant) with the following code:
if (readCharacteristic != null) {
print(
"is notifying: ${readCharacteristic.isNotifying}");
print(
"notify: ${readCharacteristic.properties.notify}");
print(
"reliableWrite: ${readCharacteristic.properties.reliableWrite}");
print("read: ${readCharacteristic.properties.read}");
}
and here are the results:
is notifying: true
notify: true
reliableWrite: false
read: false
Couple of notes:
- I called
startNotifications()
right after declaring the characteristic. Theprint("is notifying: ${readCharacteristic.isNotifying}");
returns true which I thinkg verifies that. - I previously used this exact characteristic via NRF connect application and flutter blue package before reading from my Bluetooth device. So I'm confident about the UUIDs that I chose. (
getCharacteristic()
method also did not throwNotFoundError
and I confirmed the characteristic by printing its UUIDprint(readCharacteristic.uuid);
)
from flutter_web_bluetooth.
- ✅ With the following code, I'm able to
.readValue()
from device on Desktop Chrome. So the uuid is correct and working.
// Setup serviceId
final services = await _device?.discoverServices();
final service = services?.firstWhere(
(service) => service.uuid == serviceId,
);
// Setup charId
final characteristic = await service?.getCharacteristic(characteristicUuid);
// Read from device
final res = characteristic?.readValue();
- 💔 However, on mobile phone Android Chrome, search, connect, write are all working, but read value failed. I got the similar error from the android Chrome. Which is very strange, why it works on Desktop Chrome, but not on MobilePhone Android Chrome...
![image](https://private-user-images.githubusercontent.com/12739843/239270441-ec23d94b-ddd6-46c1-96e3-29c44748259b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTUyOTMyNjgsIm5iZiI6MTcxNTI5Mjk2OCwicGF0aCI6Ii8xMjczOTg0My8yMzkyNzA0NDEtZWMyM2Q5NGItZGRkNi00NmMxLTk2ZTMtMjljNDQ3NDgyNTliLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA1MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNTA5VDIyMTYwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA3Y2Y0Yzg1Mjg2OWVlNDVhNjg4YzE4YjM4MWYyMGYwZDFmNTA0MWEzY2E3MjkwNTI5M2E2ZDU3ZGJhZWNhMDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.WHBwQ1xXIHpRZJVrVMl_rNW3qUsJZDE7gqFk7mAZh5U)
from flutter_web_bluetooth.
@JooYoo This seems to be a bug with the chrome version that is running on Android. You can avoid this error by checking it the characteristic supports reading with characteristic.properties.read
. Though this doesn't explain why it would work on desktop chrome and not on the mobile version of chrome.
You could try enabling the enable-experimental-web-platform-features
flag in chrome://flags
, and see if that solves the problem.
You could also try using a BLE app on your phone to see if that is able to read from the characteristic, it may just be the Bluetooth implementation on the phone.
from flutter_web_bluetooth.
Related Issues (20)
- Struggling with BluetoothCharacteristic.value HOT 2
- Error with brand new Flutter project HOT 2
- Misleading description on pub.dev HOT 4
- Support for getting list of characteristics from a service
- Can't find any service HOT 6
- MTU HOT 6
- Can We Get Manufacturer Data or FilterOption by Manufacturer data HOT 5
- How to determine the current connected device ? HOT 1
- Signal strength HOT 3
- Getting meta dependency issue HOT 1
- Thermal Printers compatibility?
- Interaction between Flutter web app and Flutter mobile app HOT 2
- Browser supports HOT 6
- Unable to getting Services of Bluetooth Device HOT 3
- Add exclusion filters
- Manufacturer Data Map is empty in advertisements HOT 6
- Support Notifications
- Cannot listen for changes on characteristic.startNotifications() HOT 5
- Couldn't find all of the services! HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_web_bluetooth.