To using Flutter you need to prepare the environment. Here you can find the tutorial showing how to do this, step by step.
xSetting log level
xListening bluetooth state
xListening connection state changes
xListening characteristic notifications
Firstly you need create client. It is very important to create only one single instance. You can do this via method
Set up log level
After creating the client, you can set up log level. There are a few defined log levels:
- NONE (default value)
You can set log level via
and, you will get set log level as the response. You can also check current level log via:
Bluetooth state checking
Library allows to check bluetooth state. You can register listener that informs about state changes. It is possible via:
This method returns stream that emits all bluetooth state changes. It is not the only one way to get information about bluetooth state. If you want to get current bluetooth state you can just call method
to get current state.
There is a few defined current state:
- UNKNOWN (default state)
The connection with the device
After creating client, you can establish connection with device. There is possibility to scan all devices via:
FlutterBleLib.instance.startDeviceScan(scanMode, calbackType, uuidsArray)
method. This method returns stream that emits scanned devices. The information about the device contains device id that is used to create connection. All you need to do is calling:
method, as a response you will get information about connected device. You can check any time that device is connected via
at any time. It’s good to set up the monitor that allows to get the information about breaking connection. Library provides this functionality via the following method
If some of the device's brake, this stream will emit information about this device.
When you are connected with your device you can discover services, write, read or listen notification from characteristic via relevant method.
Full library functionality is shown in example app.
Konrad Krakowiak (firstname.lastname@example.org)<br/> Michał Mizera (email@example.com)<br/> Michał Zieliński (firstname.lastname@example.org)<br/> Paweł Janeczek (email@example.com)
Copyright 2018 Polidea Sp. z o.o Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.