GithubHelp home page GithubHelp logo

pineappleooilprince / flutter_blue_elves Goto Github PK

View Code? Open in Web Editor NEW
37.0 4.0 14.0 4.18 MB

A flutter plugin for bluebooth ble device connect and control.

License: MIT License

Java 34.06% Objective-C 18.18% Dart 47.30% Ruby 0.46%
flutter plugin bluetooth bluetooth-low-energy bluetooth-le null-safety

flutter_blue_elves's Introduction


Flutter Bluetooth


flutter_blue_elves

A flutter plugin witch includes platform-specific implementation code for Android 18+ and/or iOS 10+ to connect and control bluetooth ble device.

Table of Contents

Install

This project is a flutter plugin,so you use it by add dependencies in your pubspec.yaml.

dependencies:
  flutter:
    sdk: flutter
  flutter_blue_elves: ^0.1.9
$ flutter pub get

Example

The example include all api usages.In ios,you have to add bluetooth permission tag in info file. img

Usage

Import plugin module where you need use.

import 'package:flutter_blue_elves/flutter_blue_elves.dart';

Check bluetooth function is Ok.

Effect Need version
Bluetooth permission 1. Scan for Bluetooth devices;
2. Connect with Bluetooth devices;
3. Communicate with Bluetooth devices
Android 31+
Location permission 1. Scan for Bluetooth devices;
2. Scan bluetooth device with physical location of the device;
ALL
location function Same as Location permission ALL
Bluetooth function Use Bluetooth ALL
///Android:
FlutterBlueElves.instance.androidCheckBlueLackWhat().then((values) {
if(values.contains(AndroidBluetoothLack.bluetoothPermission)){
///no bluetooth permission,if your target is android 12
}
if(values.contains(AndroidBluetoothLack.locationPermission)){
///no location permission
}
if(values.contains(AndroidBluetoothLack.locationFunction)){
///location powerOff
}
if(values.contains(AndroidBluetoothLack.bluetoothFunction)){
///bluetooth powerOff
}
});

///Ios:
FlutterBlueElves.instance.iosCheckBluetoothState().then((value) {
if(value==IosBluetoothState.unKnown){
///Bluetooth is not initialized
}else if(value==IosBluetoothState.resetting){
///Bluetooth is resetting
}else if(value==IosBluetoothState.unSupport){
///Bluetooth not support
}else if(value==IosBluetoothState.unAuthorized){
///No give bluetooth permission
}else if(value==IosBluetoothState.poweredOff){
///bluetooth powerOff
}else{
///bluetooth is ok
}
}

Turn on bluetooth function what bluetooth need.Just for android.

///apply location permission
FlutterBlueElves.instance.androidApplyLocationPermission((isOk) {
print(isOk ? "User agrees to grant location permission" : "User does not agree to grant location permission");
});
///turn on location function
FlutterBlueElves.instance.androidOpenLocationService((isOk) {
print(isOk ? "The user agrees to turn on the positioning function" : "The user does not agree to enable the positioning function");
});
///turn on bluetooth permission
FlutterBlueElves.instance.androidApplyBluetoothPermission((isOk) {
print(isOk ? "The user agrees to turn on the Bluetooth permission" : "The user does not agrees to turn on the Bluetooth permission");
});
///turn on bluetooth function
FlutterBlueElves.instance.androidOpenBluetoothService((isOk) {
print(isOk ? "The user agrees to turn on the Bluetooth function" : "The user does not agrees to turn on the Bluetooth function");
});

Scan bluetooth device not connected.

///start scan,you can set scan timeout
FlutterBlueElves.instance.startScan(5000).listen((scanItem) {
///Use the information in the scanned object to filter the devices you want
///if want to connect someone,call scanItem.connect,it will return Device object
Device device = scanItem.connect(connectTimeout: 5000);
///you can use this device to listen bluetooth device's state
device.stateStream.listen((newState){
///newState is DeviceState type,include disconnected,disConnecting, connecting,connected, connectTimeout,initiativeDisConnected,destroyed
}).onDone(() {
///if scan timeout or you stop scan,will into this
});
});

///stop scan
FlutterBlueElves.instance.stopScan();

Obtain devices that cannot be scanned because they are connected by other apps on the phone.

///Get Hide device.
///Because it is not scanned, some device information will be missing compared with the scanned results
FlutterBlueElves.instance.getHideConnectedDevices().then((values) {
  
});

Discovery device's bluetooth service,witch work in connected.

///use this stream to listen discovery result
device.serviceDiscoveryStream.listen((serviceItem) {
///serviceItem type is BleService,is readonly.It include BleCharacteristic and BleDescriptor
});
///to discovery service,witch work in connected
device.discoveryService();

Communicate with the device,witch work in connected.

///use this stream to listen data result
device.deviceSignalResultStream.listen((result) {
///result type is DeviceSignalResult,is readonly.It have DeviceSignalType attributes,witch include characteristicsRead,characteristicsWrite,characteristicsNotify,descriptorRead,descriptorWrite,unKnown.
///In ios you will accept unKnown,because characteristicsRead is as same as characteristicsNotify for ios.So characteristicsRead or characteristicsNotify will return unKnown.
});

///Read data from device by Characteristic.
///to read,witch work in connected
device.readData(serviceUuid,characteristicUuid);

///Write data to device by Characteristic.
///to write,witch work in connected.After my test,i find this isNoResponse is work in ios but not in android.
///In ios if you set isNoResponse,you will not receive data after write,but android will.
device.writeData(serviceUuid,characteristicUuid,isNoResponse,data);

///Read data from device by Descriptor.
device.devicereadDescriptorData(serviceUuid,characteristicUuid);

///Write data to device by Descriptor.
device.writeDescriptorData(serviceUuid,characteristicUuid,data);

Negotiate mtu with the device,witch work in connected and just for android

Ios automatically negotiates mtu with the device, so we don’t need to worry about it. After my test, the maximum value of mtu negotiated by ios is 185, but as long as the device allows it, ios can also write more than 185 bytes of data at one time

///Mtu range is in [23,517]
device.androidRequestMtu(512, (isSuccess, newMtu){
///get the result in this callback
///if isSuccess is true,the newMtu is new
///if isSuccess is false,this newMtu is current
});

Connect&Disconnect Device

///work in disConnected
///This connection method is direct connection, because it has been connected before, so I saved the direct connection object, and I can use this object to connect again
device.connect(5000);
///work in connected
///disconnect device
device.disConnect();

Destroy Device object

///if you never use this Device Object,call destroy(),witch can save space
device.destroy();

Watch Device rssi change

///use this stream to listen rssi change
device.deviceSignalResultStream.listen((newRssi) {
  
});
///start watch rssi
device.startWatchRssi().then((ok){
  if(ok){
    ///start ok
  }else{
    ///start error
  } 
})
///stop watch rssi
device.stopWatchRssi().then((ok){
  if(ok){
    ///stop ok
  }else{
    ///stop error
  }
})

License

MIT © PineappleOilPrince

flutter_blue_elves's People

Contributors

pineappleooilprince avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flutter_blue_elves's Issues

How to decrease data period and how can I fix the default value?

We have ble tags and these ble tags give us x, y, z acceleration. While receiving this acceleration, a default value is returned with certain periods. The hardware company confirmed that the reason for this default value is software related. During the calculation (x,y,z), some values in x,y,z overlap with deviceInfo, that is, the hex form of the device.name value in the library. To be more precise, the 13,16th digits of the returned row value give us information about the device name, while 16,17 gives us a value about the x period and causes a confusion. Can you support us to solve this situation?

readData 读取数据多了之后无法读取到最新的数据

你好,我在使用flutter_blue_elves的时候遇到一个问题
使用 readData 读取数据时,不能获取到最新的数据

我的蓝牙设备是连接在电子秤上的 会一直发送显示的重量数据 “weight:73kg”这种结构的数据

电子秤这边如果发送了100条数据

APP这边每次读取的不是最新的那一条 而是当次连接收到的所有数据
比如电子秤发送了weight:100kg,weight:200kg,weight:300kg,weight:400kg,weight:500kg,这样的5条数据

APP这边读取到的就是

  • 第一次:weight:100kg
  • 第二次:weight:100kgweight:200kg
  • 第三次:weight:100kgweight:200kgweight:300kg
  • 第四次:weight:100kgweight:200kgweight:300kgweight:400kg
  • 第五次:weight:100kgweight:200kgweight:300kgweight:400kgweight:500kg
    每次获取到会一直累计

大概获取到 20条左右 就会开始截断
电子秤发送100条数据 APP这边智能读取到前20条左右的数据

不知道是哪里的问题

Value is not updating when characteristics value is changed

  • When I tried to read data from ble service's characteristics using uuid, it always giving same initial value

1 st time readvalue - 0x01 - actual value - 0x01
2nd time readvalue - 0x01 - actual value - 0x02
3rd time readvalue - 0x01 - actual value - 0x03
etc

Scan duplicate device in Ios side

Why do I always return to the duplicate device when I turn on the Bluetooth again and start scanning the device on the iOS side, even if I pass in a parameter that does not allow duplicates.
My blue_elves version is 0.1.4

Device is not sending any data with buffers > 23 bytes

Hi, im currently stuck with this problem, it seems that my device (s20 5g, but also many others) could not send any data if the buffer is greater than 23 bytes. I already implemented the negotiation of MTU, which in my case is 132, but when I use writeData(serviceUuid, characteristicUuid, isNoResponse, data) the function is called but no message is sent out. With smaller packages its ok, but I need to send more data in only one message. Thanks in advance for any help!

蓝牙扫描过程中,操作关掉蓝牙,后面出现崩溃

日志如下:
W/BluetoothAdapter(18861): getBluetoothLeScanner() ble not available
D/AndroidRuntime(18861): Shutting down VM
E/AndroidRuntime(18861): FATAL EXCEPTION: main
E/AndroidRuntime(18861): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.bluetooth.le.BluetoothLeScanner.stopScan(android.bluetooth.le.ScanCallback)' on a null object reference
E/AndroidRuntime(18861): at gao.xiaolei.flutter_blue_elves.FlutterBlueElvesPlugin.lambda$getScanTimeoutCallback21$6$FlutterBlueElvesPlugin(FlutterBlueElvesPlugin.java:490)
E/AndroidRuntime(18861): at gao.xiaolei.flutter_blue_elves.-$$Lambda$FlutterBlueElvesPlugin$2V9C3iupvr1z0-5_MvV3wO8BJaw.run(Unknown Source:2)
E/AndroidRuntime(18861): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(18861): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(18861): at android.os.Looper.loop(Looper.java:246)
E/AndroidRuntime(18861): at android.app.ActivityThread.main(ActivityThread.java:8653)
E/AndroidRuntime(18861): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18861): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/AndroidRuntime(18861): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
I/Process (18861): Sending signal. PID: 18861 SIG: 9

如果获取指令执行后数据

获取设备返回数据的结果广播流:这个方法获取到的data 一直写入指令数据,不是指令执行后的数据

蓝牙2.0扫描不出来

有一个打印机设备同时有蓝牙2.0和蓝牙4.0
蓝牙1: FP62.k + 00:15:83:FF:70:0E 【2.0】
蓝牙2: FP62.k + C0:15:83:FF:70:0E 【4.0】
4.0的可以扫描到,2.0的扫描不到

IOS isNoResponse 没生效

IOS中isNoResponse没生效,这里改成isNoResponse? CBCharacteristicWriteWithoutResponse:CBCharacteristicWriteWithResponse
就可以了。
[self.peripheral writeValue:data forCharacteristic:characteristic type:isNoResponse? CBCharacteristicWriteWithResponse:CBCharacteristicWriteWithResponse];

感谢提供插件。刚从其他插件转过来

Scan can't find the device

After checking the Bluetooth open state, call the flutterblueelves.instance.startscan (5000) scanning device, but there is no result, the terminal outputs the log

I/flutter (27789): ble status:true,  start scaning
D/BluetoothAdapter(27789): isLeEnabled(): ON
D/BluetoothLeScanner(27789): could not find callback wrapper
D/BluetoothAdapter(27789): isLeEnabled(): ON
D/BluetoothLeScanner(27789): onScannerRegistered() - status=0 scannerId=7 mScannerId=0
2
D/BluetoothAdapter(27789): isLeEnabled(): ON
D/BluetoothLeScanner(27789): could not find callback wrapper

I don't know what the reason is caused, permissions or configuration files❓

How to use flutter_blue_elves to show widgets as needed?

I need to connect to a ble sensor and show the data in a phone app, I tried the flutter_blue_elves example, it works well.

But it don't work after I did some changes in device_control.dart to show some different widgets, why? I only changed the build part.

So, how to use flutter_blue_elves to show widgets as needed?

Or, is it possible to use flutter_blue_elves as a backgrougnd service?

Do you need to rescan after destroy to connect?

蓝牙连接destroy 之后是不是需要重新扫描才可以连接

我在项目中销毁之后重连不了
我改了一下 example的演示 也是这样的

ElevatedButton(
  child: Text(
      currentState == DeviceState.connected
          ? "Disconnect"
          : "Connect"),
  onPressed: () {
    if (currentState == DeviceState.connected) {
      // currentConnected._device.disConnect();
      currentConnected._device.destroy();
      print('修改为销毁方法');
    } else {
      currentConnected._device
          .connect(connectTimeout: 10000);
    }
  },
),

How I can set auto connect flag true?

Log :
connect() - device: CD:6C:1C:F6:FD:3F, auto: false

when auto is true you can listen to state if BLE device, then how I can set auto true in such condition.
Connect function does not provide any param for auto true/false.
See Here:

Device device = scanedDevice.connect(connectTimeout: 18000);

deviceSignalResultStream 只能在页面初始化的生命周期initState里注册吗

我的需求是要用户点击后,进行搜索指定设备,然后注册deviceSignalResultStream 来监听写入和notify的响应,可是我发现deviceSignalResultStream 没有监听到任何响应。我在您的示例应用里,也尝试deviceSignalResultStream不直接在initState初始化,而是在设备建立连接后,同样也是监听不到写入成功的响应。是我写的不对吗还是的确存在该问题,请指教下。以下贴上我的代码,用户点击后触发connectNetwork,然后开始搜索设备,建立连接
`
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_blue_elves/flutter_blue_elves.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:gsy_github_app_flutter/common/net/address.dart';
import 'package:gsy_github_app_flutter/common/net/api.dart';
import 'package:gsy_github_app_flutter/common/utils/navigator_utils.dart';
import 'package:gsy_github_app_flutter/model/NetworkingWifi.dart';
import 'package:gsy_github_app_flutter/page/deviceConfigure/device_configure_page.dart';
import 'package:gsy_github_app_flutter/page/equipmentConfiguration/equipment_configuration_page.dart';
import 'package:gsy_github_app_flutter/redux/gsy_state.dart';
import 'dart:async';
import 'dart:typed_data';

mixin BleController on State<DeviceConfigurePage> {
  bool isConnect = false;
  var store;

  //联网的信息
  late NetworkingWifi wifiInfo;

  //搜索到的设备
  ScanResult? discoveredDevice;

  //连接的设备
  Device? connectDevice;

  //连接状态流
  StreamSubscription<DeviceState>? _stateStream;

  //信号流
  StreamSubscription<DeviceSignalResult>? _deviceSignalResultStream;

  //连接状态
  DeviceState? _deviceState;

  //服务id
  String _serviceUuid = '0000a002-0000-1000-8000-00805f9b34fb';

  //特征id
  String _characteristicUuid = '0000c302-0000-1000-8000-00805f9b34fb';

  // 订阅id
  String _responsecharacteristicUuid = '0000c305-0000-1000-8000-00805f9b34fb';
  Timer? timer;
  var loadPercent = 0;
  var second = 0;

  //当前配置步骤
  int curConnectStep = 0;

  //是否正在页面注销
  bool isDispose = true;

  @override
  void dispose() {
    isDispose = true;
    if (_stateStream != null) {
      _stateStream?.cancel();
      _deviceSignalResultStream?.cancel();
      connectDevice?.destroy();
    }
    print('dispose');
    super.dispose();
  }

  /**  进入到蓝牙对接
   * step1 搜索到指定名称的蓝牙,获取其设备id
   * step2 通过设备id 和蓝牙建立连接
   * step3 向设备下的指定服务下的指定特征发送wifi信息
   * step4 发送后,等待同步数据
   */
  connectNetwork() async {
    store = StoreProvider.of<GSYState>(context);
    //获取store里的wifi名称、密码、sn、设备类型
    wifiInfo = store.state.networkingWifi;
    setState(() {
      isConnect = true;
    });
    await discoverServices('AiThinker'); //AiThinker //MiKettle
    // runProgress();
  }

  /**
   * 搜索附近设备,并建立连接,发送蓝牙信息
   * deviceName:  要连接的蓝牙名称
   */
  Future discoverServices(String deviceName) async {
    FlutterBlueElves.instance.startScan(300000).listen((event) {
      print('event.name ${event.name}');

      if (event.name == deviceName) {
        discoveredDevice = event;
        if (mounted) {
          curConnectStep = 1;
          loadPercent = 10;
        }
        toConnectDevice(event);
        FlutterBlueElves.instance.stopScan();
      }
    }).onDone(() {
      if (discoveredDevice == null) {
        goConfigureResultPage(
            wifiInfo.deviceType, ConfigurationResult.findFail);
      }
    });
  }

  //连接设备
  toConnectDevice(ScanResult curScan) {
    connectDevice = curScan.connect(connectTimeout: 10000);
    if (connectDevice != null) {
      getStateStream();
      getSinagalResultStream();
    }
  }

  //写入
  void toWrite(serviceId, characteristicId, data) {
    connectDevice?.writeData(serviceId, characteristicId, true, data);
  }

  //给蓝牙发送wifi的信息
  sendWifnfo(String serviceId, String characteristicId) async {
    var wifiToJson = '{n:${wifiInfo.ssid!}}';
    var passwordToJson = '{p:${wifiInfo.bssid!}}';

    // 转成UTF-16数组
    List<int> wifiCodeList = toUint8List(wifiToJson);
    List<int> passwordCodeList = toUint8List(passwordToJson);

    try {
      toWrite(serviceId, characteristicId, wifiCodeList);
      toWrite(serviceId, characteristicId, passwordCodeList);
    } catch (e) {
      goConfigureResultPage(wifiInfo.deviceType, ConfigurationResult.sendFail);
    }
  }

  //获取状态流
  void getStateStream() {
    _stateStream = connectDevice!.stateStream.listen((event) {
      if (event == DeviceState.connected) {
        if (mounted) {
          curConnectStep = 2;
          loadPercent = 20;
        }
        // 连接成功后,写入指令,并设置监听
        sendWifnfo(_serviceUuid, _characteristicUuid);
        setNotify(_serviceUuid, _characteristicUuid);
      } else if (event == DeviceState.disconnected && !isDispose) {
        goConfigureResultPage(
            wifiInfo.deviceType, ConfigurationResult.connectFail);
      }
      setState(() {
        _deviceState = event;
      });
    });
  }
  //设置监听
  setNotify(serviceUuid, characteristicUuid) {
    connectDevice!
        .setNotify(serviceUuid, characteristicUuid, true)
        .then((value) {
      if (value) {}
    });
  }
  
  getSinagalResultStream() {
    _deviceSignalResultStream =
        connectDevice!.deviceSignalResultStream.listen((event) {
      print('coming data ${event.data} ');
      

      if (event.type == DeviceSignalType.characteristicsRead ||
          event.type == DeviceSignalType.unKnown) {
        
      } else if (event.type == DeviceSignalType.characteristicsWrite) {
      } else if (event.type == DeviceSignalType.characteristicsNotify) {
       
        
        var str = uint8ToHex(event.data!);

        //监听到连接成功,则开始同步数据
        if (str.contains('{wifi connected}')) {
          runProgress();
        } else if (str.contains('{wifi timeout}')) {
          // wifi 响应超时
          //跳去配置失败页面
          goConfigureResultPage(
              wifiInfo.deviceType, ConfigurationResult.configurationFail);
        } 
      } else if (event.type == DeviceSignalType.descriptorRead) {}
    });
  }

  String uint8ToHex(Uint8List byteArr) {
    if (byteArr == null || byteArr.length == 0) {
      return "";
    }
    Uint8List result = Uint8List(byteArr.length << 1);
    var hexTable = [
      '0',
      '1',
      '2',
      '3',
      '4',
      '5',
      '6',
      '7',
      '8',
      '9',
      'A',
      'B',
      'C',
      'D',
      'E',
      'F'
    ]; //16进制字符表
    for (var i = 0; i < byteArr.length; i++) {
      var bit = byteArr[i]; //取传入的byteArr的每一位
      var index = bit >> 4 & 15; //右移4位,取剩下四位
      var i2 = i << 1; //byteArr的每一位对应结果的两位,所以对于结果的操作位数要乘2
      result[i2] = hexTable[index].codeUnitAt(0); //左边的值取字符表,转为Unicode放进resut数组
      index = bit & 15; //取右边四位
      result[i2 + 1] =
          hexTable[index].codeUnitAt(0); //右边的值取字符表,转为Unicode放进resut数组
    }
    return String.fromCharCodes(result); //Unicode转回为对应字符,生成字符串返回
  }

  /**
   * 跳转到配置结果页
   * devicetype: 设备类型
   * status: 配置结果
   */
  void goConfigureResultPage(devicetype, ConfigurationResult status) async {
    // if (discoveredDevice != null) {
    //   await bleconnector.disconnect(discoveredDevice?.id ?? '');
    //   await bleconnector.dispose();
    // }
    // print('connectedstate  ${connectedstate.toString()}');

    NavigatorUtils.PushReplaceRouter(
        context,
        EquipmentConfigurationPage(
          status: status,
          deviceType: devicetype,
        ));
  }

  /**
   * 获取数据同步状态,跳转到配置结果页
   * 同步成功  ConfigurationResult.succes  同步失败: ConfigurationResult.configurationFail
   */
  void runProgress() {
    const oneSec = const Duration(seconds: 3);
    var connetctStatusCallback = isDeviceConnect();
    setState(() {
      curConnectStep = 3;
      loadPercent = 30;
    });
    var callback = (timers) async {
      var isConnected = await connetctStatusCallback();
      print('isConnect$isConnected');
      if (isConnected) {
        setState(() {
          loadPercent = 100;
          timer?.cancel();
          goConfigureResultPage(
              wifiInfo.deviceType, ConfigurationResult.succes);
        });
      } else {
        if (loadPercent + 10 >= 100) {
          setState(() {
            loadPercent = 99;
            timer?.cancel();
            goConfigureResultPage(
                wifiInfo.deviceType, ConfigurationResult.configurationFail);
          });
        } else {
          setState(() {
            loadPercent = loadPercent + 10;
          });
        }
      }
    };
    timer = Timer.periodic(oneSec, callback);
  }

  /// 设备是否联网
  isDeviceConnect() {
    var times = 1;
    return () async {
      Map<String, dynamic> params = {'sn': wifiInfo.sn, 'times': times};
      print(params);
      var value = await httpManager.netFetch(
          Address.getDeviceConnectStatus(), params, null, null);
      if (value!.result) {
        if (value.data['data']['net'] == 1) {
          return true;
        }
      }
      times++;
      return false;
    };
  }

  // ascii 转为 字符串
  String toAsciiString(chars) => String.fromCharCodes(chars);

  //字符串转化为Uint8List
  Uint8List toUint8List(dataStr) {
    var ascii = dataStr.codeUnits;
    var data = Uint8List.fromList(ascii);
    return data;
  }
}

`

Connect to start background cillecting

I/BluetoothSocket( 9163): BT connect calling pid/uid = 9163/10740, pkgName=io.github.edufolly.flutterbluetoothserialexample
I/flutter ( 9163): PlatformException(connect_error, read failed, socket might closed or timeout, read ret: -1, java.io.IOException: read failed, socket might closed or timeout, read ret: -1
I/flutter ( 9163): at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:838)
I/flutter ( 9163): at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:852)
I/flutter ( 9163): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:443)
I/flutter ( 9163): at io.github.edufolly.flutterbluetoothserial.BluetoothConnection.connect(BluetoothConnection.java:57)
I/flutter ( 9163): at io.github.edufolly.flutterbluetoothserial.BluetoothConnection.connect(BluetoothConnection.java:64)
I/flutter ( 9163): at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin$FlutterBluetoothSerialMethodCallHandler.lambda$onMethodCall$4$FlutterBluetoothSerialPlugin$FlutterBluetoothSerialMethodCallHandler(FlutterBluetoothSerialPlugin.java:1007)
I/flutter ( 9163): at io.github.edufolly.flutterbluetoothserial.-$$Lambda$FlutterBluetoothSerialPlugin$FlutterBluetoothSerialMethodCallHandler$DZLg1SWj2Aas0tcY7uTlx8xsy4Y.run(Unknown Source:10)
I/flutter ( 9163): at andr

iOS values not receiving

In Android, where I was using this library for my ble, it worked flawlessly, however in iOS, even if the bluetooth was turned on, the value wasn't being received. Can someone please fix this problem. I appreciate you.

往蓝牙写入长串特征值,收不到蓝牙对应的通知

你好,往蓝牙写入长串特征值
比如下面指令:
EAAA07535486ACA6A7A8A9BB8AEBADAEAFB04E4D4C4B4A494847464544434241403F3E3D3C3B3A393837363534333231302F2E2D2C2B2A292827262524201F1E1D1C1B1A191817161514131211100F0E0D0C0B0A09080706050403020100FFFEFDFCFBFAF9F8F7F6F5F4F3F2F1F0EFEEEDECEBEAE9E8E7E6E5E4E3E2E1E0DFDEDDDCDBDAD9D8D77F929559
通过writeData(mUuid_service!, mUuid_charact!, false,Hex.createUint8ListFromHexString(指令码)) 方式 收不到对应蓝牙返回来的通知,在原生上就能接收到通知。这是什么原因造成的,请大神赐教。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.