This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handleUpdateValueForCharacteristic(data) { | |
//let dataBuffer = Buffer.Buffer.from(data); | |
console.log( | |
'Received data from ' + | |
data.peripheral + | |
' characteristic ' + | |
data.characteristic, | |
data.value[1], | |
); | |
console.log(data.characteristic,UUID_BASE_2('2a37')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handleBattery(peripheral) { | |
setTimeout(() => { | |
BleManager.retrieveServices(peripheral.id).then(services => { | |
BleManager.read(peripheral.id, 'fee0', UUID_BASE('0006')) | |
.then(readData => { | |
let data = Buffer.Buffer.from(readData); | |
console.log('read battery level', data.readUInt8(1, true)); | |
this.setState({battery: data.readUInt8(1, true)}); | |
}) | |
.catch(error => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
test(peripheral) { | |
if (peripheral) { | |
if (peripheral.connected) { | |
BleManager.disconnect(peripheral.id); | |
} else { | |
BleManager.connect(peripheral.id) | |
.then(() => { | |
let peripherals = this.state.peripherals; | |
let p = peripherals.get(peripheral.id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
renderItem(item) { | |
const color = item.connected ? 'green' : '#fff'; | |
return ( | |
<TouchableHighlight onPress={() => this.test(item)}> | |
<View style={[styles.row, {backgroundColor: color}]}> | |
<Text | |
style={{ | |
fontSize: 12, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
startScan() { | |
if (!this.state.scanning) { | |
//this.setState({peripherals: new Map()}); | |
BleManager.scan([], 3, true).then(results => { | |
console.log('Scanning...'); | |
this.setState({scanning: true}); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
import BleManager from 'react-native-ble-manager'; | |
const bleManagerEmitter = new NativeEventEmitter(BleManagerModule); | |
... | |
componentDidMount() { | |
AppState.addEventListener('change', this.handleAppStateChange); | |
BleManager.start({showAlert: false}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor() { | |
super(); | |
this.state = { | |
scanning: false, | |
peripherals: new Map(), | |
peripheral:null, | |
appState: '', | |
connectedTo: 'nothing', | |
battery: null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor() { | |
super(); | |
this.state = { | |
scanning: false, | |
peripherals: new Map(), | |
peripheral:null, | |
appState: '', | |
connectedTo: 'nothing', | |
battery: null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yarn install | |
yarn install v1.15.2 | |
warning ../../../package.json: No license field | |
[1/4] 🔍 Resolving packages... | |
[2/4] 🚚 Fetching packages... | |
info @expo/traveling-fastlane-linux@1.9.3: The platform "darwin" is incompatible with this module. | |
info "@expo/traveling-fastlane-linux@1.9.3" is an optional dependency and failed compatibility check. Excluding it from installation. | |
info @expo/ngrok-bin-darwin-ia32@2.2.8: The CPU architecture "x64" is incompatible with this module. | |
info "@expo/ngrok-bin-darwin-ia32@2.2.8" is an optional dependency and failed compatibility check. Excluding it from installation. | |
info @expo/ngrok-bin-freebsd-ia32@2.2.8: The platform "darwin" is incompatible with this module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 | |
13:35:51,725 INFO [org.jboss.modules] (main) JBoss Modules version 1.4.3.Final | |
13:35:52,079 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final | |
13:35:52,183 INFO [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 9.0.1.Final (WildFly Core 1.0.1.Final) starting | |
13:35:53,444 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 3) WFLYCTL0028: Attribute 'job-repository-type' in the resource at address '/subsystem=batch' is deprecated, and may be removed in future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation. | |
13:35:53,447 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 14) WFLYCTL0028: Attribute 'enabled' in the resource at address '/subsystem=datasources/data-source=ExampleDS' is deprecated, and may be removed in future version. See th |
NewerOlder