Advertisement
Guest User

Untitled

a guest
Sep 5th, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var app = {
  2.     initialize: function() {
  3.         this.bindEvents();
  4.     },
  5.     bindEvents: function() {
  6.         document.addEventListener('deviceready', this.onDeviceReady, false);
  7.     },
  8.     onDeviceReady: function() {
  9.         app.receivedEvent('deviceready');
  10.         alert("Before connect");
  11.         //bluetoothSerial.enable(connectSuccess, connectFailure);
  12.         bluetoothSerial.connect("98:D3:31:40:06:5C", connectSuccess, connectFailure);
  13.         alert("After connect");
  14.     },
  15.     receivedEvent: function(id) {
  16.         var parentElement = document.getElementById(id);
  17.         var listeningElement = parentElement.querySelector('.listening');
  18.         var receivedElement = parentElement.querySelector('.received');
  19.  
  20.         listeningElement.setAttribute('style', 'display:none;');
  21.         receivedElement.setAttribute('style', 'display:block;');
  22.  
  23.         console.log('Received Event: ' + id);
  24.     }
  25. };
  26. function connectSuccess(){
  27.         alert("Success!");
  28.     };
  29.  
  30. function connectFailure(){
  31.     alert("Failed");
  32. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement