BLE on React Native

E86b46be0f4e61db6b28becc5493bbab?s=47 januswel
February 08, 2018

BLE on React Native

some tips to use BLE on React Native

E86b46be0f4e61db6b28becc5493bbab?s=128

januswel

February 08, 2018
Tweet

Transcript

  1. 21.

    1 class BleManager extends EventEmitter2 { 2 startScanning() { /*

    snip */ } 3 connectToPeripheral() { /* snip */ } 4 async readCharacteristic() { /* snip */ } 5 async startMeasuring() { 6 const value = await this.readCharacteristic() 7 this.emit('READ', value) 8 } 9 } 1 class SomeComponent extends React.Component { 2 handleRead(value) { 3 this.props.actions.storeValues(value) 4 } 5 componentDidMount() { 6 this.props.bleManager.on( 7 'READ', 8 this.handleRead.bind(this) 9 ) 10 } 11 render() { 12 /* render buttons to 13 * - startScanning 14 * - connectToPeripheral, 15 * - startMeasuring */ 16 } 17 }