Develop bluetooth with Weex, with only one line of code.
JavaScript Objective-C Ruby HTML Other
Switch branches/tags
Nothing to show
Permalink
Failed to load latest commit information.
Classes/iOS remove duplicate javascript file. May 23, 2017
Examples/iOSExample Add support for Cocoapods May 18, 2017
testWeex Add comment of function in javascript. May 23, 2017
.gitignore Initial commit May 12, 2017
.swift-version Add support for Cocoapods May 18, 2017
LICENSE
README.md update example code May 23, 2017
qqgroup_qrcode.png
wechat_qrcode.jpg
weex-bluetooth.podspec Add support for Cocoapods May 18, 2017

README.md

weex-bluetooth

An extremely easy-use bluetooth library for weex developers. with only a few lines of code, you will be able to connect to a bluetooth device and read from/write to it!

Both iOS and Android are supported.(Android version will be coming soon)

For Chinese version of README click HERE.

Quick Example

  //open bluetooth
  openBluetoothAdapter()
  .then(data => {//scan for BLE devices
    var services = [];
    return discoverDevice(services,function(device){//scan filter
      var deviceName = device['name'];
      var index = deviceName.indexOf("you-ble-name");
      return (index != -1);
    });
  })
  .then(device => {//connect to BLE device
    return connectToDevice(device);
  }).then(device => {//discover service of BLE device
    return discoverServices(device);
  }).then(data => {//discover characteristic of a service
    var deviceID = data['deviceID'];
    var services = data['services'];
    for (var index in services){
      var serviceID = services[index]['UUID'];
      if (serviceID=="FFF0") {
        return discoverCharacteristics(deviceID, serviceID);
      }
    }
  }).then(data => {
    var deviceID = data[0];
    var serviceID = data[1];
    var characteristics = data[2];
    for (var i = 0; i < characteristics.length; i++) {
      var characteristicID = characteristics[i]['UUID'];
      if (characteristicID=="your-characteristic-UUID") {//listen to value change of characteristic
        listenToValueChangeOfCharacteristic(deviceID, serviceID, characteristicID,function(data){
          console.log(data);
        });
      }
    }
  });

Features

Easy-understadable APIs to use.

Full Documents and comments;

Fast response to issues. If you have any questions, feel free to post it!

Friendly to Javascript Promise.

Installation

1\ Install Weex environment.

2\ For iOS version, install Xcode at Mac OS X. For Android version Android programming environment should be installed.

3\

How to Use

Future Plan

1\ Support for Android.

About Author

xing li, an iOS developer from Nanjing, China. You can access me by shangwangwanwan[@]gmail.com. And here is my tech blog. Here is the QR code of QQ group chat(For Chinese developers):

Here is my wechat QR code:

Licence

This project is licenced under the terms of Apache licence.