How can I connect to device if I only have mac address value? Thanks a lot!
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
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.