Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. import SOMEBluetoothManager, { SOMEBluetoothEventEmitter } from '../nativeComponents/SOMEBluetooth/SOMEBluetooth';
  2. import { connect } from 'react-redux';
  3.  
  4. const MAX_PAYLOAD_LENGTH = 14;
  5.  
  6. class SOMEDataTransfer {
  7. constructor(gainParamList) {
  8. this.gainParamList = gainParamList;
  9. this.transferTimeoutDuration = 10000;
  10. // console.log('lets llook again at the gainparamlist that is being sent over inside the constructor ', gainParamList);
  11. }
  12. start(onFinishCallback) {
  13. this.onFinishCallback = onFinishCallback;
  14. this.setupBluetoothEventListeners();
  15.  
  16. let initialChannel = 0;
  17. let initialGains = this.getChannelGains(initialChannel);
  18.  
  19. let transferChannelGainsCompleteCallback = (success, channel) => {
  20. if (success) {
  21. let newChannel = channel + 1;
  22. if (newChannel >= this.gainParamList.length) {
  23. // console.log('Finished! and now lets look at success and channell, onFinishcallback', success, channel, onFinishCallback);
  24. this.removeBluetoothEventListeners();
  25. if (onFinishCallback) {
  26. this.onFinishCallback(true);
  27. }
  28. }
  29. else {
  30. console.log('Channel ' + channel + ' transfer complete');
  31. let gains = this.getChannelGains(newChannel);
  32. this.transferChannelGains(gains, newChannel, 0, transferChannelGainsCompleteCallback);
  33. }
  34. }
  35. else {
  36. console.log('Channel ' + channel + ' transfer failed');
  37. this.removeBluetoothEventListeners();
  38. if (onFinishCallback) {
  39. this.onFinishCallback(false);
  40. }
  41. }
  42. }
  43. this.transferChannelGains(initialGains, initialChannel, 0, transferChannelGainsCompleteCallback);
  44. }
  45. }
  46. const mapStateToProps = (state) => {
  47. return {
  48.  
  49. }
  50. }
  51. const mapDispatchToProps = (dispatch) => {
  52. return {
  53.  
  54. }
  55. }
  56. export default connect(mapStateToProps, mapDispatchToProps)(SOMEDataTransfer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement