Coder Social home page Coder Social logo

flutter_ble_mannager's Introduction

flutter_ble_mannager

Flutter 插件 flutter_blue 的二次封装,以便简洁调用

添加flutter_blue库

//文件名:pubspec.yaml
    flutter_blue: ^0.7.2

添加蓝牙权限

Android 端权限添加:

//文件名:AndroidManifest.xml
        <uses-permission android:name="android.permission.BLUETOOTH"/>
        <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

iOS 端权限添加:

//文件名:Info.plist
    <key>NSBluetoothAlwaysUsageDescription</key>
    <string>App需要您的同意,才能访问蓝牙,进行设备连接,数据通讯服务</string>
    <key>NSBluetoothPeripheralUsageDescription</key>
    <string>App需要您的同意,才能访问蓝牙,进行设备连接,数据通讯服务</string>

使用方法

1.初始化

initBle();

2.开始搜索蓝牙设备

startBle();

3.得到搜索到所有蓝牙设备名字数组(含名称过滤)

getBleScanNameAry

4.从名字数组里面选择对应的蓝牙设备进行连接,传入需要连接的设备名在数组的位置

(其实是假连接,停止扫描,准备好需要连接的蓝牙设备参数) connectionBle(int chooseBle)

5.正式连接蓝牙,并且开始检索特征描述符,并匹配需要用到的特征描述符等

discoverServicesBle()

6.断开蓝牙连接

endBle()

*写入数据 例子:dataCallsendBle([0x00, 0x00, 0x00, 0x00])

dataCallsendBle(List value)

*收到数据

dataCallbackBle()

flutter_ble_mannager's People

Contributors

qq2223996838 avatar

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.