Flutter_blue: Help! connect to device

Created on 7 Aug 2019  路  5Comments  路  Source: pauldemarco/flutter_blue

How can I connect to device if I only have mac address value? Thanks a lot!

Most helpful comment

On iOS you cannot connect to a device via mac address - they are not exposed to the users (https://stackoverflow.com/a/2971250/4312184). As I know, the only way to do it is to store device mac address inside an advertisement manufacturer data. At least we do it with our devices and everything working good.

All 5 comments

If you know the information of the device beforehand then you can create a BluetoothDevice object yourself and use that to connect.
Simple example:

BluetoothDevice myDevice = BluetoothDevice(
   id: DeviceIdentifier("MAC address"),
   type: BluetoothDeviceType.le,
   name: "Device Name",
),
await myDevice.connect();

Pre Flutter Blue 0.6.0:

BluetoothDevice myDevice = BluetoothDevice(
   id: DeviceIdentifier("MAC address"),
   type: BluetoothDeviceType.le,
   name: "Device Name",
),
FlutterBlue.instance.connect(mydevice);

Thanks for your support <3

On iOS you cannot connect to a device via mac address - they are not exposed to the users (https://stackoverflow.com/a/2971250/4312184). As I know, the only way to do it is to store device mac address inside an advertisement manufacturer data. At least we do it with our devices and everything working good.

I am using ^0.7.2 version and when I run on apple device my app, the logs don't show me the mac address, but I know the device mac address to connect to, the code above doesn't work for me. How can in create device in connect to it?
Problem: BluetoothDevice doesn't have a default constructor.
Thank you.

I am using ^0.7.2 version and when I run on apple device my app, the logs don't show me the mac address, but I know the device mac address to connect to, the code above doesn't work for me. How can in create device in connect to it?
Problem: BluetoothDevice doesn't have a default constructor.
Thank you.

I'm also in trouble

Was this page helpful?
0 / 5 - 0 ratings

Related issues

saulopef picture saulopef  路  4Comments

brianegan picture brianegan  路  5Comments

janekm picture janekm  路  3Comments

ssaylanc picture ssaylanc  路  4Comments

FWeissenb picture FWeissenb  路  5Comments