I want to capture some responses data after I send some data via bluetooth but I have a problem at the time of capture, I send "a" Into my bluetooth module and should send me a response to 1 or 0, just after sent, but there is an error on the part of the catch which sent the data and making me answer a previous response. example: Correct
App Bluetooth App Send "a" ===> get "a" must response 1 but NULL Send "b" ===> get "b" must response 0 but 1 Send "a" ===> get "a" must response 1 but 0Capturing taking a previous data!!! Please Help! The code
var ilu1= Ti.UI.createButton({ width : Ti.UI.FILL, height : '80dp', shadowColor: '#000', shadowOffset: {x:0, y:0}, shadowRadius: 2, font:{ fontSize:55, fontFamily: customFont2 }, textAlign : Titanium.UI.TEXT_ALIGNMENT_CENTER, verticalAlign : Titanium.UI.TEXT_VERTICAL_ALIGNMENT_BOTTOM, title : 'L', color : '#fff', backgroundColor:'#005a93', backgroundSelectedColor: '#1f2d46', backgroundFocusedColor: '#1f2d46', touchEnabled: true, zIndex:2 }); ilu1.addEventListener('click', function() { novarumbluetooth.sendData('a'); actualizalabel.text = 'Actualizando'; var responsebtilu = novarumbluetooth.addEventListener('nb_onReceiveData', function(e) { Ti.App.responsebt2 = e.data; }); alert(Ti.App.responsebt2); if (Ti.App.responsebt2=='1') { ilu1.title = 'K'; actualizalabel.text = 'Actualizado'; } else { actualizalabel.text = 'Error'; }; })Thanks!!