react-native-ble-light
v0.2.2
Published
a package interact BLE of PHX
Downloads
1
Readme
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