0.4.0 • Published 3 years ago

viatom-ble-native-library v0.4.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
3 years ago

viatom-ble-native-library

Publishing

npm publish

Installation

yarn add viatom-ble-native-library
npx react-native run-android

Usage

import { startScanning, stopScanning, connect, disconnect } from "viatom-ble-native-library";

... 

startScanning()
stopScanning()

connect(macAdress) // takes in input the macAdress string
disconnect()

Events

The library is sending different type of events which can be observed by react native.

Name of events:

  • BLEScanningEvent
  • BLEConnectionEvent

BLEScanningEvent

In params send a map

{ "name": String // name of BLEDevice found "macAdress": String // mac address of BLEDevice found "status": String // scanning status, can be SCANNING, SCANNING_ALREADY_STARTED, SCANNING_ERROR }

BLEConnectionEvent

In params send a map

{ "connectionState" : String // status of BLEDevice, can be CONNECTING, CONNECTED, DISCONNECTING, DISCONNECTED, CONNECTION_ERROR, READY }

Example

How to intercept Events from React Native

import { NativeEventEmitter, NativeModules} from 'react-native';

...

const eventEmitter = new NativeEventEmitter(NativeModules.ToastExample);
    const eventListener = eventEmitter.addListener('BLEScanningEvent', (event) => {

      console.log("Scanning Status: " + event.status);
      console.log("Scanning Status: " + event.name);
      console.log("Scanning Status: " + event.macAdress);


    });
0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago