Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SOMEBluetoothManager, { SOMEBluetoothEventEmitter } from '../nativeComponents/SOMEBluetooth/SOMEBluetooth';
- import { connect } from 'react-redux';
- const MAX_PAYLOAD_LENGTH = 14;
- class SOMEDataTransfer {
- constructor(gainParamList) {
- this.gainParamList = gainParamList;
- this.transferTimeoutDuration = 10000;
- // console.log('lets llook again at the gainparamlist that is being sent over inside the constructor ', gainParamList);
- }
- start(onFinishCallback) {
- this.onFinishCallback = onFinishCallback;
- this.setupBluetoothEventListeners();
- let initialChannel = 0;
- let initialGains = this.getChannelGains(initialChannel);
- let transferChannelGainsCompleteCallback = (success, channel) => {
- if (success) {
- let newChannel = channel + 1;
- if (newChannel >= this.gainParamList.length) {
- // console.log('Finished! and now lets look at success and channell, onFinishcallback', success, channel, onFinishCallback);
- this.removeBluetoothEventListeners();
- if (onFinishCallback) {
- this.onFinishCallback(true);
- }
- }
- else {
- console.log('Channel ' + channel + ' transfer complete');
- let gains = this.getChannelGains(newChannel);
- this.transferChannelGains(gains, newChannel, 0, transferChannelGainsCompleteCallback);
- }
- }
- else {
- console.log('Channel ' + channel + ' transfer failed');
- this.removeBluetoothEventListeners();
- if (onFinishCallback) {
- this.onFinishCallback(false);
- }
- }
- }
- this.transferChannelGains(initialGains, initialChannel, 0, transferChannelGainsCompleteCallback);
- }
- }
- const mapStateToProps = (state) => {
- return {
- }
- }
- const mapDispatchToProps = (dispatch) => {
- return {
- }
- }
- export default connect(mapStateToProps, mapDispatchToProps)(SOMEDataTransfer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement