0.2.2 • Published 2 years ago

react-native-ble-light v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-ble-light

a package interact BLE of PHX

Installation

npm install react-native-ble-light

Usage

import BleLight from "react-native-ble-light";

`` Start Ble before use methods

    BleLight.start();

`` Scan peripheral, result scanned will show in Ble.onScanPeripheral.
    Ble.startScan();
    Ble.onScanPeripheral = (peripheral) => {
        //do st
    }

`` Stop Scan.
    Ble.stopScan();
    Stop success: Ble.onStopScanPeripheral = (state) => { // }

`` Enable bluetooth
    Ble.enableBluetooth();

`` Check state of bluetooth. State will show in Ble.onDidUpdateState
    Ble.checkState();
    Ble.onDidUpdateState = (state) => {
        // do st
    }

`` Follow change of characteristic.
    Ble.onHandleUpdateValueForCharacteristic = (state) => {

    }
`` Connect and send wifi infomation.
    Ble.configBLEDevice(peripheralUUID, options).
    Where in options:
        - TargetServiceUUID
        - TargetCharacteristicUUID
        - TargetMessageSSID
        - TargetMessagePassword
    Example: Ble.configBLEDevice("1AFB2E", {"TargetServiceUUID":"0F","TargetCharacteristicUUID":"F2", "TargetMessageSSID":"My wifi", "TargetMessagePassword": "12345678" })
`` State while paring Device
    Ble.onPairingPeripheral = (state) => {
        // PERIPHERAL_CONNECTED : state connect.
        // PERIPHERAL_DISCOVER_SERVICE: state discover service.
        // PERIPHERAL_DISCOVER_CHARACTERISTICS: state discover characteristic.
        // PERIPHERAL_START_NOTIFICATION: state of notification.
        // PERIPHERAL_WRITTEN_SSID: state write ssid
        // PERIPHERAL_WRITTEN_PW: state write password
    }

## License

toan.lk173407
0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago