Code Monkey home page Code Monkey logo

ble_sdk's Introduction

ble_sdk

  • ble_sdk version ble_sdk size ble_sdk issues ble_sdk issues
  • Bluetooth Low Energy (BLE) plugin that can communicate with single device

Futures

  • BLE device discovery
  • Connection BLE
  • BLE status
  • Connection BLE state
  • Discover services
  • Enable notification a characteristic
  • Enable indication a characteristic
  • Read a characteristic
  • Write a characteristic

Getting Started

android

Android ProGuard rules

-keep class com.hodoan.ble_sdk.** { *; }

ios

<key>NSBluetoothAlwaysUsageDescription</key>
<string>using BLE</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>using BLE</string>

Usage

Scan Device

BleSdk.instance.startScan(services: ['1808'])

Stop Scan Device

BleSdk.instance.stopScan()

Connect Device

BleSdk.instance.connect(deviceId: '...')

Connect Device

BleSdk.instance.connect(deviceId: '...')

Device discovery

BleSdk.instance.discoverServices()

set notification a characteristic

BleSdk.instance.setNotification(Characteristic(
    characteristicId: '...',
    serviceId: '...',
    properties: [],
))

set indication a characteristic

BleSdk.instance.setIndication(Characteristic(
    characteristicId: '...',
    serviceId: '...',
    properties: [],
))

Read a characteristic

BleSdk.instance.readCharacteristic(Characteristic(
    characteristicId: '...',
    serviceId: '...',
    properties: [],
))

Write a characteristic

BleSdk.instance.readCharacteristic(CharacteristicValue(
    characteristic: ...,
    data: [],
))

Disconnect device

BleSdk.instance.disconnect()

Log Characteristic

BleSdk.instance.logResult.listen((_){})

Listen Read/Write All Characteristic

BleSdk.instance.characteristicResult.listen((_){})

Listen BLE ON/OFF

BleSdk.instance.stateBluetoothResult.listen((_){})

State Connect

BleSdk.instance.stateConnectResult.listen((_){})

ble_sdk's People

Contributors

ho-doan avatar doan-phi-ho avatar doanhobranch avatar

Stargazers

 avatar

Watchers

 avatar

ble_sdk's Issues

Clean code

ble_sdk_custom.dart

Future _setNotifications(List listNotifications) async {
bool result = false;
for (final notification in listNotifications) {
await Future.delayed(const Duration(milliseconds: 500));
if (notification.properties.contains(CharacteristicProperties.NOTIFY)) {
// log('Set notification to ${notification.characteristicId} - ${DateTime.now()}');
result = await setNotification(notification);
}
if (notification.properties.contains(CharacteristicProperties.INDICATE)) {
// log('Set indication to ${notification.characteristicId} - ${DateTime.now()}');
result = await setIndication(notification);
}
if (!result) return false;
}

return true;

}

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.