Skip to content

Instantly share code, notes, and snippets.

View oflarcade's full-sized avatar

Omar Farouk Lakhdhar oflarcade

View GitHub Profile
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'))
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 => {
...
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);
@oflarcade
oflarcade / list.js
Last active October 30, 2019 10:07
...
renderItem(item) {
const color = item.connected ? 'green' : '#fff';
return (
<TouchableHighlight onPress={() => this.test(item)}>
<View style={[styles.row, {backgroundColor: color}]}>
<Text
style={{
fontSize: 12,
...
startScan() {
if (!this.state.scanning) {
//this.setState({peripherals: new Map()});
BleManager.scan([], 3, true).then(results => {
console.log('Scanning...');
this.setState({scanning: true});
});
}
}
....
import BleManager from 'react-native-ble-manager';
const bleManagerEmitter = new NativeEventEmitter(BleManagerModule);
...
componentDidMount() {
AppState.addEventListener('change', this.handleAppStateChange);
BleManager.start({showAlert: false});
constructor() {
super();
this.state = {
scanning: false,
peripherals: new Map(),
peripheral:null,
appState: '',
connectedTo: 'nothing',
battery: null,
constructor() {
super();
this.state = {
scanning: false,
peripherals: new Map(),
peripheral:null,
appState: '',
connectedTo: 'nothing',
battery: null,
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.
@oflarcade
oflarcade / console.js
Created April 1, 2019 12:58
console Wildfly
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