package b4a.HC05DataLogger;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.pc.*;

public class bluetoothasynchstream_subs_0 {


public static RemoteObject  _admin_devicefound(RemoteObject __ref,RemoteObject _name,RemoteObject _macaddress) throws Exception{
try {
		Debug.PushSubsStack("Admin_DeviceFound (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,69);
if (RapidSub.canDelegate("admin_devicefound")) { return __ref.runUserSub(false, "bluetoothasynchstream","admin_devicefound", __ref, _name, _macaddress);}
Debug.locals.put("Name", _name);
Debug.locals.put("MacAddress", _macaddress);
 BA.debugLineNum = 69;BA.debugLine="Private Sub Admin_DeviceFound (Name As String, Mac";
Debug.ShouldStop(16);
 BA.debugLineNum = 70;BA.debugLine="Log(Name & \":\" & MacAddress)";
Debug.ShouldStop(32);
bluetoothasynchstream.__c.runVoidMethod ("LogImpl","31376257",RemoteObject.concat(_name,RemoteObject.createImmutable(":"),_macaddress),0);
 BA.debugLineNum = 71;BA.debugLine="If Name.Contains(GenericDeviceName) Then";
Debug.ShouldStop(64);
if (_name.runMethod(true,"contains",(Object)(__ref.getField(true,"_genericdevicename" /*RemoteObject*/ ))).<Boolean>get().booleanValue()) { 
 BA.debugLineNum = 72;BA.debugLine="Log(GenericDeviceName & \" found\")";
Debug.ShouldStop(128);
bluetoothasynchstream.__c.runVoidMethod ("LogImpl","31376259",RemoteObject.concat(__ref.getField(true,"_genericdevicename" /*RemoteObject*/ ),RemoteObject.createImmutable(" found")),0);
 BA.debugLineNum = 73;BA.debugLine="DeviceName = Name";
Debug.ShouldStop(256);
__ref.setField ("_devicename" /*RemoteObject*/ ,_name);
 BA.debugLineNum = 74;BA.debugLine="DeviceMacAdress = MacAddress";
Debug.ShouldStop(512);
__ref.setField ("_devicemacadress" /*RemoteObject*/ ,_macaddress);
 BA.debugLineNum = 78;BA.debugLine="If PH.SdkVersion <= 24 Then";
Debug.ShouldStop(8192);
if (RemoteObject.solveBoolean("k",__ref.getField(false,"_ph" /*RemoteObject*/ ).runMethod(true,"getSdkVersion"),BA.numberCast(double.class, 24))) { 
 BA.debugLineNum = 79;BA.debugLine="Admin.CancelDiscovery";
Debug.ShouldStop(16384);
__ref.getField(false,"_admin" /*RemoteObject*/ ).runVoidMethod ("CancelDiscovery");
 BA.debugLineNum = 80;BA.debugLine="lblStatus.Text = GenericDeviceName & \" found\"";
Debug.ShouldStop(32768);
__ref.getField(false,"_lblstatus" /*RemoteObject*/ ).runMethod(true,"setText",BA.ObjectToCharSequence(RemoteObject.concat(__ref.getField(true,"_genericdevicename" /*RemoteObject*/ ),RemoteObject.createImmutable(" found"))));
 }else {
 BA.debugLineNum = 82;BA.debugLine="lblStatus.Text = GenericDeviceName & \" found, p";
Debug.ShouldStop(131072);
__ref.getField(false,"_lblstatus" /*RemoteObject*/ ).runMethod(true,"setText",BA.ObjectToCharSequence(RemoteObject.concat(__ref.getField(true,"_genericdevicename" /*RemoteObject*/ ),RemoteObject.createImmutable(" found, please wait."))));
 };
 };
 BA.debugLineNum = 85;BA.debugLine="End Sub";
Debug.ShouldStop(1048576);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _admin_discoveryfinished(RemoteObject __ref) throws Exception{
try {
		Debug.PushSubsStack("Admin_DiscoveryFinished (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,90);
if (RapidSub.canDelegate("admin_discoveryfinished")) { return __ref.runUserSub(false, "bluetoothasynchstream","admin_discoveryfinished", __ref);}
 BA.debugLineNum = 90;BA.debugLine="Private Sub Admin_DiscoveryFinished";
Debug.ShouldStop(33554432);
 BA.debugLineNum = 91;BA.debugLine="If DeviceName = \"\" Then";
Debug.ShouldStop(67108864);
if (RemoteObject.solveBoolean("=",__ref.getField(true,"_devicename" /*RemoteObject*/ ),BA.ObjectToString(""))) { 
 BA.debugLineNum = 92;BA.debugLine="lblStatus.Text = \"Device \" & GenericDeviceName &";
Debug.ShouldStop(134217728);
__ref.getField(false,"_lblstatus" /*RemoteObject*/ ).runMethod(true,"setText",BA.ObjectToCharSequence(RemoteObject.concat(RemoteObject.createImmutable("Device "),__ref.getField(true,"_genericdevicename" /*RemoteObject*/ ),RemoteObject.createImmutable(" Not found"))));
 }else {
 BA.debugLineNum = 94;BA.debugLine="lblStatus.Text = \"Connecting to: \" & GenericDevi";
Debug.ShouldStop(536870912);
__ref.getField(false,"_lblstatus" /*RemoteObject*/ ).runMethod(true,"setText",BA.ObjectToCharSequence(RemoteObject.concat(RemoteObject.createImmutable("Connecting to: "),__ref.getField(true,"_genericdevicename" /*RemoteObject*/ ))));
 BA.debugLineNum = 95;BA.debugLine="Serial.Connect(DeviceMacAdress)";
Debug.ShouldStop(1073741824);
__ref.getField(false,"_serial" /*RemoteObject*/ ).runVoidMethod ("Connect",__ref.getField(false, "ba"),(Object)(__ref.getField(true,"_devicemacadress" /*RemoteObject*/ )));
 };
 BA.debugLineNum = 97;BA.debugLine="End Sub";
Debug.ShouldStop(1);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _admin_statechanged(RemoteObject __ref,RemoteObject _newstate,RemoteObject _oldstate) throws Exception{
try {
		Debug.PushSubsStack("Admin_StateChanged (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,99);
if (RapidSub.canDelegate("admin_statechanged")) { return __ref.runUserSub(false, "bluetoothasynchstream","admin_statechanged", __ref, _newstate, _oldstate);}
Debug.locals.put("NewState", _newstate);
Debug.locals.put("OldState", _oldstate);
 BA.debugLineNum = 99;BA.debugLine="Private Sub Admin_StateChanged (NewState As Int, O";
Debug.ShouldStop(4);
 BA.debugLineNum = 100;BA.debugLine="Log(\"State changed: \" & NewState)";
Debug.ShouldStop(8);
bluetoothasynchstream.__c.runVoidMethod ("LogImpl","31507329",RemoteObject.concat(RemoteObject.createImmutable("State changed: "),_newstate),0);
 BA.debugLineNum = 101;BA.debugLine="lblStatus.Text = \"State changed: \" & NewState";
Debug.ShouldStop(16);
__ref.getField(false,"_lblstatus" /*RemoteObject*/ ).runMethod(true,"setText",BA.ObjectToCharSequence(RemoteObject.concat(RemoteObject.createImmutable("State changed: "),_newstate)));
 BA.debugLineNum = 102;BA.debugLine="BluetoothState = NewState = Admin.STATE_ON";
Debug.ShouldStop(32);
__ref.setField ("_bluetoothstate" /*RemoteObject*/ ,BA.ObjectToBoolean(RemoteObject.solveBoolean("=",_newstate,BA.numberCast(double.class, __ref.getField(false,"_admin" /*RemoteObject*/ ).getField(true,"STATE_ON")))));
 BA.debugLineNum = 103;BA.debugLine="End Sub";
Debug.ShouldStop(64);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _ast_newtext(RemoteObject __ref,RemoteObject _text) throws Exception{
try {
		Debug.PushSubsStack("Ast_NewText (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,133);
if (RapidSub.canDelegate("ast_newtext")) { return __ref.runUserSub(false, "bluetoothasynchstream","ast_newtext", __ref, _text);}
Debug.locals.put("Text", _text);
 BA.debugLineNum = 133;BA.debugLine="Public Sub Ast_NewText(Text As String)";
Debug.ShouldStop(16);
 BA.debugLineNum = 134;BA.debugLine="CallSubDelayed2(mParent, mEventName & \"_NewText\",";
Debug.ShouldStop(32);
bluetoothasynchstream.__c.runVoidMethod ("CallSubDelayed2",__ref.getField(false, "ba"),(Object)(__ref.getField(false,"_mparent" /*RemoteObject*/ )),(Object)(RemoteObject.concat(__ref.getField(true,"_meventname" /*RemoteObject*/ ),RemoteObject.createImmutable("_NewText"))),(Object)((_text)));
 BA.debugLineNum = 135;BA.debugLine="Log(Text)";
Debug.ShouldStop(64);
bluetoothasynchstream.__c.runVoidMethod ("LogImpl","31769474",_text,0);
 BA.debugLineNum = 136;BA.debugLine="End Sub";
Debug.ShouldStop(128);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _astreams_error(RemoteObject __ref) throws Exception{
try {
		Debug.PushSubsStack("Astreams_Error (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,177);
if (RapidSub.canDelegate("astreams_error")) { return __ref.runUserSub(false, "bluetoothasynchstream","astreams_error", __ref);}
 BA.debugLineNum = 177;BA.debugLine="Private Sub Astreams_Error";
Debug.ShouldStop(65536);
 BA.debugLineNum = 178;BA.debugLine="Log(\"error: \" & LastException)";
Debug.ShouldStop(131072);
bluetoothasynchstream.__c.runVoidMethod ("LogImpl","32097153",RemoteObject.concat(RemoteObject.createImmutable("error: "),bluetoothasynchstream.__c.runMethod(false,"LastException",__ref.getField(false, "ba"))),0);
 BA.debugLineNum = 179;BA.debugLine="Astreams.Close";
Debug.ShouldStop(262144);
__ref.getField(false,"_astreams" /*RemoteObject*/ ).runVoidMethod ("Close");
 BA.debugLineNum = 180;BA.debugLine="CallSubDelayed(mParent, mEventName & \"_Terminated";
Debug.ShouldStop(524288);
bluetoothasynchstream.__c.runVoidMethod ("CallSubDelayed",__ref.getField(false, "ba"),(Object)(__ref.getField(false,"_mparent" /*RemoteObject*/ )),(Object)(RemoteObject.concat(__ref.getField(true,"_meventname" /*RemoteObject*/ ),RemoteObject.createImmutable("_Terminated"))));
 BA.debugLineNum = 181;BA.debugLine="End Sub";
Debug.ShouldStop(1048576);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _astreams_newdata(RemoteObject __ref,RemoteObject _buffer) throws Exception{
try {
		Debug.PushSubsStack("Astreams_NewData (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,148);
if (RapidSub.canDelegate("astreams_newdata")) { return __ref.runUserSub(false, "bluetoothasynchstream","astreams_newdata", __ref, _buffer);}
RemoteObject _newdatastart = RemoteObject.createImmutable(0);
RemoteObject _s = RemoteObject.createImmutable("");
RemoteObject _start = RemoteObject.createImmutable(0);
int _i = 0;
RemoteObject _c = RemoteObject.createImmutable('\0');
Debug.locals.put("Buffer", _buffer);
 BA.debugLineNum = 148;BA.debugLine="Private Sub Astreams_NewData (Buffer() As Byte)";
Debug.ShouldStop(524288);
 BA.debugLineNum = 149;BA.debugLine="Dim newDataStart As Int = sb.Length";
Debug.ShouldStop(1048576);
_newdatastart = __ref.getField(false,"_sb" /*RemoteObject*/ ).runMethod(true,"getLength");Debug.locals.put("newDataStart", _newdatastart);Debug.locals.put("newDataStart", _newdatastart);
 BA.debugLineNum = 150;BA.debugLine="sb.Append(BytesToString(Buffer, 0, Buffer.Length,";
Debug.ShouldStop(2097152);
__ref.getField(false,"_sb" /*RemoteObject*/ ).runVoidMethod ("Append",(Object)(bluetoothasynchstream.__c.runMethod(true,"BytesToString",(Object)(_buffer),(Object)(BA.numberCast(int.class, 0)),(Object)(_buffer.getField(true,"length")),(Object)(__ref.getField(true,"_charset" /*RemoteObject*/ )))));
 BA.debugLineNum = 151;BA.debugLine="Dim s As String = sb.ToString";
Debug.ShouldStop(4194304);
_s = __ref.getField(false,"_sb" /*RemoteObject*/ ).runMethod(true,"ToString");Debug.locals.put("s", _s);Debug.locals.put("s", _s);
 BA.debugLineNum = 152;BA.debugLine="Dim start As Int = 0";
Debug.ShouldStop(8388608);
_start = BA.numberCast(int.class, 0);Debug.locals.put("start", _start);Debug.locals.put("start", _start);
 BA.debugLineNum = 153;BA.debugLine="For i = newDataStart To s.Length - 1";
Debug.ShouldStop(16777216);
{
final int step5 = 1;
final int limit5 = RemoteObject.solve(new RemoteObject[] {_s.runMethod(true,"length"),RemoteObject.createImmutable(1)}, "-",1, 1).<Integer>get().intValue();
_i = _newdatastart.<Integer>get().intValue() ;
for (;(step5 > 0 && _i <= limit5) || (step5 < 0 && _i >= limit5) ;_i = ((int)(0 + _i + step5))  ) {
Debug.locals.put("i", _i);
 BA.debugLineNum = 154;BA.debugLine="Dim c As Char = s.CharAt(i)";
Debug.ShouldStop(33554432);
_c = _s.runMethod(true,"charAt",(Object)(BA.numberCast(int.class, _i)));Debug.locals.put("c", _c);Debug.locals.put("c", _c);
 BA.debugLineNum = 155;BA.debugLine="If i = 0 And c = Chr(10) Then '\\n...";
Debug.ShouldStop(67108864);
if (RemoteObject.solveBoolean("=",RemoteObject.createImmutable(_i),BA.numberCast(double.class, 0)) && RemoteObject.solveBoolean("=",_c,bluetoothasynchstream.__c.runMethod(true,"Chr",(Object)(BA.numberCast(int.class, 10))))) { 
 BA.debugLineNum = 156;BA.debugLine="start = 1 'might be a broken end of line charac";
Debug.ShouldStop(134217728);
_start = BA.numberCast(int.class, 1);Debug.locals.put("start", _start);
 BA.debugLineNum = 157;BA.debugLine="Continue";
Debug.ShouldStop(268435456);
if (true) continue;
 };
 BA.debugLineNum = 159;BA.debugLine="If c = Chr(10) Then '\\n";
Debug.ShouldStop(1073741824);
if (RemoteObject.solveBoolean("=",_c,bluetoothasynchstream.__c.runMethod(true,"Chr",(Object)(BA.numberCast(int.class, 10))))) { 
 BA.debugLineNum = 160;BA.debugLine="CallSubDelayed2(mParent, mEventName & \"_NewText";
Debug.ShouldStop(-2147483648);
bluetoothasynchstream.__c.runVoidMethod ("CallSubDelayed2",__ref.getField(false, "ba"),(Object)(__ref.getField(false,"_mparent" /*RemoteObject*/ )),(Object)(RemoteObject.concat(__ref.getField(true,"_meventname" /*RemoteObject*/ ),RemoteObject.createImmutable("_NewText"))),(Object)((_s.runMethod(true,"substring",(Object)(_start),(Object)(BA.numberCast(int.class, _i))))));
 BA.debugLineNum = 161;BA.debugLine="start = i + 1";
Debug.ShouldStop(1);
_start = RemoteObject.solve(new RemoteObject[] {RemoteObject.createImmutable(_i),RemoteObject.createImmutable(1)}, "+",1, 1);Debug.locals.put("start", _start);
 }else 
{ BA.debugLineNum = 162;BA.debugLine="Else If c = Chr(13) Then '\\r";
Debug.ShouldStop(2);
if (RemoteObject.solveBoolean("=",_c,bluetoothasynchstream.__c.runMethod(true,"Chr",(Object)(BA.numberCast(int.class, 13))))) { 
 BA.debugLineNum = 163;BA.debugLine="CallSubDelayed2(mParent, mEventName & \"_NewText";
Debug.ShouldStop(4);
bluetoothasynchstream.__c.runVoidMethod ("CallSubDelayed2",__ref.getField(false, "ba"),(Object)(__ref.getField(false,"_mparent" /*RemoteObject*/ )),(Object)(RemoteObject.concat(__ref.getField(true,"_meventname" /*RemoteObject*/ ),RemoteObject.createImmutable("_NewText"))),(Object)((_s.runMethod(true,"substring",(Object)(_start),(Object)(BA.numberCast(int.class, _i))))));
 BA.debugLineNum = 164;BA.debugLine="If i < s.Length - 1 And s.CharAt(i + 1) = Chr(1";
Debug.ShouldStop(8);
if (RemoteObject.solveBoolean("<",RemoteObject.createImmutable(_i),BA.numberCast(double.class, RemoteObject.solve(new RemoteObject[] {_s.runMethod(true,"length"),RemoteObject.createImmutable(1)}, "-",1, 1))) && RemoteObject.solveBoolean("=",_s.runMethod(true,"charAt",(Object)(RemoteObject.solve(new RemoteObject[] {RemoteObject.createImmutable(_i),RemoteObject.createImmutable(1)}, "+",1, 1))),bluetoothasynchstream.__c.runMethod(true,"Chr",(Object)(BA.numberCast(int.class, 10))))) { 
 BA.debugLineNum = 165;BA.debugLine="i = i + 1";
Debug.ShouldStop(16);
_i = RemoteObject.solve(new RemoteObject[] {RemoteObject.createImmutable(_i),RemoteObject.createImmutable(1)}, "+",1, 1).<Integer>get().intValue();Debug.locals.put("i", _i);
 };
 BA.debugLineNum = 167;BA.debugLine="start = i + 1";
Debug.ShouldStop(64);
_start = RemoteObject.solve(new RemoteObject[] {RemoteObject.createImmutable(_i),RemoteObject.createImmutable(1)}, "+",1, 1);Debug.locals.put("start", _start);
 }}
;
 }
}Debug.locals.put("i", _i);
;
 BA.debugLineNum = 170;BA.debugLine="If start > 0 Then sb.Remove(0, start)";
Debug.ShouldStop(512);
if (RemoteObject.solveBoolean(">",_start,BA.numberCast(double.class, 0))) { 
__ref.getField(false,"_sb" /*RemoteObject*/ ).runVoidMethod ("Remove",(Object)(BA.numberCast(int.class, 0)),(Object)(_start));};
 BA.debugLineNum = 171;BA.debugLine="End Sub";
Debug.ShouldStop(1024);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _astreams_terminated(RemoteObject __ref) throws Exception{
try {
		Debug.PushSubsStack("Astreams_Terminated (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,173);
if (RapidSub.canDelegate("astreams_terminated")) { return __ref.runUserSub(false, "bluetoothasynchstream","astreams_terminated", __ref);}
 BA.debugLineNum = 173;BA.debugLine="Private Sub Astreams_Terminated";
Debug.ShouldStop(4096);
 BA.debugLineNum = 174;BA.debugLine="CallSubDelayed(mParent, mEventName & \"_Terminated";
Debug.ShouldStop(8192);
bluetoothasynchstream.__c.runVoidMethod ("CallSubDelayed",__ref.getField(false, "ba"),(Object)(__ref.getField(false,"_mparent" /*RemoteObject*/ )),(Object)(RemoteObject.concat(__ref.getField(true,"_meventname" /*RemoteObject*/ ),RemoteObject.createImmutable("_Terminated"))));
 BA.debugLineNum = 175;BA.debugLine="End Sub";
Debug.ShouldStop(16384);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _class_globals(RemoteObject __ref) throws Exception{
 //BA.debugLineNum = 6;BA.debugLine="Sub Class_Globals";
 //BA.debugLineNum = 7;BA.debugLine="Private Admin As BluetoothAdmin";
bluetoothasynchstream._admin = RemoteObject.createNew ("anywheresoftware.b4a.objects.Serial.BluetoothAdmin");__ref.setField("_admin",bluetoothasynchstream._admin);
 //BA.debugLineNum = 8;BA.debugLine="Public Astreams As AsyncStreams";
bluetoothasynchstream._astreams = RemoteObject.createNew ("anywheresoftware.b4a.randomaccessfile.AsyncStreams");__ref.setField("_astreams",bluetoothasynchstream._astreams);
 //BA.debugLineNum = 9;BA.debugLine="Private Serial As Serial";
bluetoothasynchstream._serial = RemoteObject.createNew ("anywheresoftware.b4a.objects.Serial");__ref.setField("_serial",bluetoothasynchstream._serial);
 //BA.debugLineNum = 10;BA.debugLine="Private PH As Phone";
bluetoothasynchstream._ph = RemoteObject.createNew ("anywheresoftware.b4a.phone.Phone");__ref.setField("_ph",bluetoothasynchstream._ph);
 //BA.debugLineNum = 11;BA.debugLine="Private mParent As Object";
bluetoothasynchstream._mparent = RemoteObject.createNew ("Object");__ref.setField("_mparent",bluetoothasynchstream._mparent);
 //BA.debugLineNum = 12;BA.debugLine="Private mEventName As String";
bluetoothasynchstream._meventname = RemoteObject.createImmutable("");__ref.setField("_meventname",bluetoothasynchstream._meventname);
 //BA.debugLineNum = 13;BA.debugLine="Private lblStatus As Label";
bluetoothasynchstream._lblstatus = RemoteObject.createNew ("anywheresoftware.b4a.objects.LabelWrapper");__ref.setField("_lblstatus",bluetoothasynchstream._lblstatus);
 //BA.debugLineNum = 14;BA.debugLine="Private ProgressBar1 As ProgressBar";
bluetoothasynchstream._progressbar1 = RemoteObject.createNew ("anywheresoftware.b4a.objects.ProgressBarWrapper");__ref.setField("_progressbar1",bluetoothasynchstream._progressbar1);
 //BA.debugLineNum = 16;BA.debugLine="Private GenericDeviceName, DeviceName As String";
bluetoothasynchstream._genericdevicename = RemoteObject.createImmutable("");__ref.setField("_genericdevicename",bluetoothasynchstream._genericdevicename);
bluetoothasynchstream._devicename = RemoteObject.createImmutable("");__ref.setField("_devicename",bluetoothasynchstream._devicename);
 //BA.debugLineNum = 18;BA.debugLine="Public BluetoothState, ConnectionState, DeviceFou";
bluetoothasynchstream._bluetoothstate = RemoteObject.createImmutable(false);__ref.setField("_bluetoothstate",bluetoothasynchstream._bluetoothstate);
bluetoothasynchstream._connectionstate = RemoteObject.createImmutable(false);__ref.setField("_connectionstate",bluetoothasynchstream._connectionstate);
bluetoothasynchstream._devicefound = RemoteObject.createImmutable(false);__ref.setField("_devicefound",bluetoothasynchstream._devicefound);
 //BA.debugLineNum = 19;BA.debugLine="Private DeviceName, DeviceMacAdress As String";
bluetoothasynchstream._devicename = RemoteObject.createImmutable("");__ref.setField("_devicename",bluetoothasynchstream._devicename);
bluetoothasynchstream._devicemacadress = RemoteObject.createImmutable("");__ref.setField("_devicemacadress",bluetoothasynchstream._devicemacadress);
 //BA.debugLineNum = 21;BA.debugLine="Public CharSet = \"UTF-8\" As String";
bluetoothasynchstream._charset = BA.ObjectToString("UTF-8");__ref.setField("_charset",bluetoothasynchstream._charset);
 //BA.debugLineNum = 22;BA.debugLine="Private sb As StringBuilder";
bluetoothasynchstream._sb = RemoteObject.createNew ("anywheresoftware.b4a.keywords.StringBuilderWrapper");__ref.setField("_sb",bluetoothasynchstream._sb);
 //BA.debugLineNum = 23;BA.debugLine="Public State As String";
bluetoothasynchstream._state = RemoteObject.createImmutable("");__ref.setField("_state",bluetoothasynchstream._state);
 //BA.debugLineNum = 24;BA.debugLine="End Sub";
return RemoteObject.createImmutable("");
}
public static RemoteObject  _close(RemoteObject __ref) throws Exception{
try {
		Debug.PushSubsStack("Close (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,183);
if (RapidSub.canDelegate("close")) { return __ref.runUserSub(false, "bluetoothasynchstream","close", __ref);}
 BA.debugLineNum = 183;BA.debugLine="Public Sub Close";
Debug.ShouldStop(4194304);
 BA.debugLineNum = 184;BA.debugLine="Astreams.Close";
Debug.ShouldStop(8388608);
__ref.getField(false,"_astreams" /*RemoteObject*/ ).runVoidMethod ("Close");
 BA.debugLineNum = 185;BA.debugLine="End Sub";
Debug.ShouldStop(16777216);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _connect(RemoteObject __ref,RemoteObject _name) throws Exception{
try {
		Debug.PushSubsStack("Connect (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,52);
if (RapidSub.canDelegate("connect")) { return __ref.runUserSub(false, "bluetoothasynchstream","connect", __ref, _name);}
RemoteObject _success = RemoteObject.createImmutable(false);
Debug.locals.put("Name", _name);
 BA.debugLineNum = 52;BA.debugLine="Public Sub Connect(Name As String)";
Debug.ShouldStop(524288);
 BA.debugLineNum = 53;BA.debugLine="GenericDeviceName = Name";
Debug.ShouldStop(1048576);
__ref.setField ("_genericdevicename" /*RemoteObject*/ ,_name);
 BA.debugLineNum = 54;BA.debugLine="Dim success As Boolean = Admin.StartDiscovery";
Debug.ShouldStop(2097152);
_success = __ref.getField(false,"_admin" /*RemoteObject*/ ).runMethod(true,"StartDiscovery");Debug.locals.put("success", _success);Debug.locals.put("success", _success);
 BA.debugLineNum = 55;BA.debugLine="If success = False Then";
Debug.ShouldStop(4194304);
if (RemoteObject.solveBoolean("=",_success,bluetoothasynchstream.__c.getField(true,"False"))) { 
 BA.debugLineNum = 56;BA.debugLine="lblStatus.Text = \"Error starting discovery proce";
Debug.ShouldStop(8388608);
__ref.getField(false,"_lblstatus" /*RemoteObject*/ ).runMethod(true,"setText",BA.ObjectToCharSequence("Error starting discovery process."));
 }else {
 BA.debugLineNum = 58;BA.debugLine="lblStatus.Text = \"Start discovery\"";
Debug.ShouldStop(33554432);
__ref.getField(false,"_lblstatus" /*RemoteObject*/ ).runMethod(true,"setText",BA.ObjectToCharSequence("Start discovery"));
 BA.debugLineNum = 59;BA.debugLine="ProgressBar1.Visible = True";
Debug.ShouldStop(67108864);
__ref.getField(false,"_progressbar1" /*RemoteObject*/ ).runMethod(true,"setVisible",bluetoothasynchstream.__c.getField(true,"True"));
 };
 BA.debugLineNum = 61;BA.debugLine="End Sub";
Debug.ShouldStop(268435456);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _disconnect(RemoteObject __ref) throws Exception{
try {
		Debug.PushSubsStack("Disconnect (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,63);
if (RapidSub.canDelegate("disconnect")) { return __ref.runUserSub(false, "bluetoothasynchstream","disconnect", __ref);}
 BA.debugLineNum = 63;BA.debugLine="Public Sub Disconnect";
Debug.ShouldStop(1073741824);
 BA.debugLineNum = 64;BA.debugLine="If Astreams.IsInitialized Then Astreams.Close";
Debug.ShouldStop(-2147483648);
if (__ref.getField(false,"_astreams" /*RemoteObject*/ ).runMethod(true,"IsInitialized").<Boolean>get().booleanValue()) { 
__ref.getField(false,"_astreams" /*RemoteObject*/ ).runVoidMethod ("Close");};
 BA.debugLineNum = 65;BA.debugLine="If Serial.IsInitialized Then Serial.Disconnect";
Debug.ShouldStop(1);
if (__ref.getField(false,"_serial" /*RemoteObject*/ ).runMethod(true,"IsInitialized").<Boolean>get().booleanValue()) { 
__ref.getField(false,"_serial" /*RemoteObject*/ ).runVoidMethod ("Disconnect");};
 BA.debugLineNum = 66;BA.debugLine="End Sub";
Debug.ShouldStop(2);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _initialize(RemoteObject __ref,RemoteObject _ba,RemoteObject _parent,RemoteObject _eventname,RemoteObject _statuslabel,RemoteObject _pgb) throws Exception{
try {
		Debug.PushSubsStack("Initialize (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,32);
if (RapidSub.canDelegate("initialize")) { return __ref.runUserSub(false, "bluetoothasynchstream","initialize", __ref, _ba, _parent, _eventname, _statuslabel, _pgb);}
__ref.runVoidMethodAndSync("innerInitializeHelper", _ba);
Debug.locals.put("ba", _ba);
Debug.locals.put("Parent", _parent);
Debug.locals.put("EventName", _eventname);
Debug.locals.put("StatusLabel", _statuslabel);
Debug.locals.put("Pgb", _pgb);
 BA.debugLineNum = 32;BA.debugLine="Public Sub Initialize(Parent As Object, EventName";
Debug.ShouldStop(-2147483648);
 BA.debugLineNum = 33;BA.debugLine="mParent = Parent";
Debug.ShouldStop(1);
__ref.setField ("_mparent" /*RemoteObject*/ ,_parent);
 BA.debugLineNum = 34;BA.debugLine="mEventName = EventName";
Debug.ShouldStop(2);
__ref.setField ("_meventname" /*RemoteObject*/ ,_eventname);
 BA.debugLineNum = 35;BA.debugLine="lblStatus = StatusLabel";
Debug.ShouldStop(4);
__ref.setField ("_lblstatus" /*RemoteObject*/ ,_statuslabel);
 BA.debugLineNum = 36;BA.debugLine="Admin.Initialize(\"Admin\")";
Debug.ShouldStop(8);
__ref.getField(false,"_admin" /*RemoteObject*/ ).runVoidMethod ("Initialize",__ref.getField(false, "ba"),(Object)(RemoteObject.createImmutable("Admin")));
 BA.debugLineNum = 37;BA.debugLine="Serial.Initialize(\"Serial\")";
Debug.ShouldStop(16);
__ref.getField(false,"_serial" /*RemoteObject*/ ).runVoidMethod ("Initialize",(Object)(RemoteObject.createImmutable("Serial")));
 BA.debugLineNum = 38;BA.debugLine="ProgressBar1 = Pgb";
Debug.ShouldStop(32);
__ref.setField ("_progressbar1" /*RemoteObject*/ ,_pgb);
 BA.debugLineNum = 39;BA.debugLine="sb.Initialize";
Debug.ShouldStop(64);
__ref.getField(false,"_sb" /*RemoteObject*/ ).runVoidMethod ("Initialize");
 BA.debugLineNum = 41;BA.debugLine="If Admin.IsEnabled = False Then";
Debug.ShouldStop(256);
if (RemoteObject.solveBoolean("=",__ref.getField(false,"_admin" /*RemoteObject*/ ).runMethod(true,"IsEnabled"),bluetoothasynchstream.__c.getField(true,"False"))) { 
 BA.debugLineNum = 42;BA.debugLine="If Admin.Enable = False Then";
Debug.ShouldStop(512);
if (RemoteObject.solveBoolean("=",__ref.getField(false,"_admin" /*RemoteObject*/ ).runMethod(true,"Enable"),bluetoothasynchstream.__c.getField(true,"False"))) { 
 BA.debugLineNum = 43;BA.debugLine="ToastMessageShow(\"Error enabling Bluetooth adap";
Debug.ShouldStop(1024);
bluetoothasynchstream.__c.runVoidMethod ("ToastMessageShow",(Object)(BA.ObjectToCharSequence("Error enabling Bluetooth adapter.")),(Object)(bluetoothasynchstream.__c.getField(true,"True")));
 }else {
 BA.debugLineNum = 45;BA.debugLine="ToastMessageShow(\"Enabling Bluetooth adapter...";
Debug.ShouldStop(4096);
bluetoothasynchstream.__c.runVoidMethod ("ToastMessageShow",(Object)(BA.ObjectToCharSequence("Enabling Bluetooth adapter...")),(Object)(bluetoothasynchstream.__c.getField(true,"False")));
 };
 }else {
 BA.debugLineNum = 48;BA.debugLine="BluetoothState = True";
Debug.ShouldStop(32768);
__ref.setField ("_bluetoothstate" /*RemoteObject*/ ,bluetoothasynchstream.__c.getField(true,"True"));
 };
 BA.debugLineNum = 50;BA.debugLine="End Sub";
Debug.ShouldStop(131072);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _sendbytes(RemoteObject __ref,RemoteObject _buffer) throws Exception{
try {
		Debug.PushSubsStack("SendBytes (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,122);
if (RapidSub.canDelegate("sendbytes")) { return __ref.runUserSub(false, "bluetoothasynchstream","sendbytes", __ref, _buffer);}
Debug.locals.put("Buffer", _buffer);
 BA.debugLineNum = 122;BA.debugLine="Public Sub SendBytes(Buffer() As Byte)";
Debug.ShouldStop(33554432);
 BA.debugLineNum = 123;BA.debugLine="Astreams.Write(Buffer)";
Debug.ShouldStop(67108864);
__ref.getField(false,"_astreams" /*RemoteObject*/ ).runVoidMethod ("Write",(Object)(_buffer));
 BA.debugLineNum = 124;BA.debugLine="End Sub";
Debug.ShouldStop(134217728);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _sendtext(RemoteObject __ref,RemoteObject _text) throws Exception{
try {
		Debug.PushSubsStack("SendText (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,129);
if (RapidSub.canDelegate("sendtext")) { return __ref.runUserSub(false, "bluetoothasynchstream","sendtext", __ref, _text);}
Debug.locals.put("Text", _text);
 BA.debugLineNum = 129;BA.debugLine="Public Sub SendText(Text As String)";
Debug.ShouldStop(1);
 BA.debugLineNum = 130;BA.debugLine="Astreams.Write(Text.GetBytes(CharSet))";
Debug.ShouldStop(2);
__ref.getField(false,"_astreams" /*RemoteObject*/ ).runVoidMethod ("Write",(Object)(_text.runMethod(false,"getBytes",(Object)(__ref.getField(true,"_charset" /*RemoteObject*/ )))));
 BA.debugLineNum = 131;BA.debugLine="End Sub";
Debug.ShouldStop(4);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _serial_connected(RemoteObject __ref,RemoteObject _success) throws Exception{
try {
		Debug.PushSubsStack("Serial_Connected (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,106);
if (RapidSub.canDelegate("serial_connected")) { return __ref.runUserSub(false, "bluetoothasynchstream","serial_connected", __ref, _success);}
RemoteObject _msg = RemoteObject.createImmutable("");
Debug.locals.put("Success", _success);
 BA.debugLineNum = 106;BA.debugLine="Sub Serial_Connected (Success As Boolean)";
Debug.ShouldStop(512);
 BA.debugLineNum = 107;BA.debugLine="Private msg As String";
Debug.ShouldStop(1024);
_msg = RemoteObject.createImmutable("");Debug.locals.put("msg", _msg);
 BA.debugLineNum = 108;BA.debugLine="If Success = True Then";
Debug.ShouldStop(2048);
if (RemoteObject.solveBoolean("=",_success,bluetoothasynchstream.__c.getField(true,"True"))) { 
 BA.debugLineNum = 109;BA.debugLine="If Astreams.IsInitialized Then Astreams.Close";
Debug.ShouldStop(4096);
if (__ref.getField(false,"_astreams" /*RemoteObject*/ ).runMethod(true,"IsInitialized").<Boolean>get().booleanValue()) { 
__ref.getField(false,"_astreams" /*RemoteObject*/ ).runVoidMethod ("Close");};
 BA.debugLineNum = 110;BA.debugLine="Astreams.Initialize(Serial.InputStream, Serial.O";
Debug.ShouldStop(8192);
__ref.getField(false,"_astreams" /*RemoteObject*/ ).runVoidMethod ("Initialize",__ref.getField(false, "ba"),(Object)(__ref.getField(false,"_serial" /*RemoteObject*/ ).runMethod(false,"getInputStream")),(Object)(__ref.getField(false,"_serial" /*RemoteObject*/ ).runMethod(false,"getOutputStream")),(Object)(RemoteObject.createImmutable("Astreams")));
 BA.debugLineNum = 111;BA.debugLine="msg = \"Connected\"";
Debug.ShouldStop(16384);
_msg = BA.ObjectToString("Connected");Debug.locals.put("msg", _msg);
 BA.debugLineNum = 112;BA.debugLine="ProgressBar1.Visible = False";
Debug.ShouldStop(32768);
__ref.getField(false,"_progressbar1" /*RemoteObject*/ ).runMethod(true,"setVisible",bluetoothasynchstream.__c.getField(true,"False"));
 }else {
 BA.debugLineNum = 114;BA.debugLine="Log(LastException.Message)";
Debug.ShouldStop(131072);
bluetoothasynchstream.__c.runVoidMethod ("LogImpl","31572872",bluetoothasynchstream.__c.runMethod(false,"LastException",__ref.getField(false, "ba")).runMethod(true,"getMessage"),0);
 BA.debugLineNum = 115;BA.debugLine="msg = LastException.Message";
Debug.ShouldStop(262144);
_msg = bluetoothasynchstream.__c.runMethod(false,"LastException",__ref.getField(false, "ba")).runMethod(true,"getMessage");Debug.locals.put("msg", _msg);
 };
 BA.debugLineNum = 117;BA.debugLine="lblStatus.Text = msg";
Debug.ShouldStop(1048576);
__ref.getField(false,"_lblstatus" /*RemoteObject*/ ).runMethod(true,"setText",BA.ObjectToCharSequence(_msg));
 BA.debugLineNum = 118;BA.debugLine="CallSubDelayed2(mParent, mEventName & \"_Connected";
Debug.ShouldStop(2097152);
bluetoothasynchstream.__c.runVoidMethod ("CallSubDelayed2",__ref.getField(false, "ba"),(Object)(__ref.getField(false,"_mparent" /*RemoteObject*/ )),(Object)(RemoteObject.concat(__ref.getField(true,"_meventname" /*RemoteObject*/ ),RemoteObject.createImmutable("_Connected"))),(Object)((_success)));
 BA.debugLineNum = 119;BA.debugLine="End Sub";
Debug.ShouldStop(4194304);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _writebytes(RemoteObject __ref,RemoteObject _buffer) throws Exception{
try {
		Debug.PushSubsStack("WriteBytes (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,144);
if (RapidSub.canDelegate("writebytes")) { return __ref.runUserSub(false, "bluetoothasynchstream","writebytes", __ref, _buffer);}
Debug.locals.put("Buffer", _buffer);
 BA.debugLineNum = 144;BA.debugLine="Public Sub WriteBytes(Buffer() As Byte)";
Debug.ShouldStop(32768);
 BA.debugLineNum = 145;BA.debugLine="Astreams.Write(Buffer)";
Debug.ShouldStop(65536);
__ref.getField(false,"_astreams" /*RemoteObject*/ ).runVoidMethod ("Write",(Object)(_buffer));
 BA.debugLineNum = 146;BA.debugLine="End Sub";
Debug.ShouldStop(131072);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _writetext(RemoteObject __ref,RemoteObject _text) throws Exception{
try {
		Debug.PushSubsStack("WriteText (bluetoothasynchstream) ","bluetoothasynchstream",2,__ref.getField(false, "ba"),__ref,139);
if (RapidSub.canDelegate("writetext")) { return __ref.runUserSub(false, "bluetoothasynchstream","writetext", __ref, _text);}
Debug.locals.put("Text", _text);
 BA.debugLineNum = 139;BA.debugLine="Public Sub WriteText(Text As String)";
Debug.ShouldStop(1024);
 BA.debugLineNum = 140;BA.debugLine="Astreams.Write(Text.GetBytes(CharSet))";
Debug.ShouldStop(2048);
__ref.getField(false,"_astreams" /*RemoteObject*/ ).runVoidMethod ("Write",(Object)(_text.runMethod(false,"getBytes",(Object)(__ref.getField(true,"_charset" /*RemoteObject*/ )))));
 BA.debugLineNum = 141;BA.debugLine="End Sub";
Debug.ShouldStop(4096);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
}