package b4a.HC05DataLogger;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.B4AClass;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.debug.*;

public class bluetoothasynchstream extends B4AClass.ImplB4AClass implements BA.SubDelegator{
    private static java.util.HashMap<String, java.lang.reflect.Method> htSubs;
    private void innerInitialize(BA _ba) throws Exception {
        if (ba == null) {
            ba = new anywheresoftware.b4a.ShellBA(_ba, this, htSubs, "b4a.HC05DataLogger.bluetoothasynchstream");
            if (htSubs == null) {
                ba.loadHtSubs(this.getClass());
                htSubs = ba.htSubs;
            }
            
        }
        if (BA.isShellModeRuntimeCheck(ba)) 
			   this.getClass().getMethod("_class_globals", b4a.HC05DataLogger.bluetoothasynchstream.class).invoke(this, new Object[] {null});
        else
            ba.raiseEvent2(null, true, "class_globals", false);
    }

 
    public void  innerInitializeHelper(anywheresoftware.b4a.BA _ba) throws Exception{
        innerInitialize(_ba);
    }
    public Object callSub(String sub, Object sender, Object[] args) throws Exception {
        return BA.SubDelegator.SubNotFound;
    }
public anywheresoftware.b4a.keywords.Common __c = null;
public anywheresoftware.b4a.objects.Serial.BluetoothAdmin _admin = null;
public anywheresoftware.b4a.randomaccessfile.AsyncStreams _astreams = null;
public anywheresoftware.b4a.objects.Serial _serial = null;
public anywheresoftware.b4a.phone.Phone _ph = null;
public Object _mparent = null;
public String _meventname = "";
public anywheresoftware.b4a.objects.LabelWrapper _lblstatus = null;
public anywheresoftware.b4a.objects.ProgressBarWrapper _progressbar1 = null;
public String _genericdevicename = "";
public String _devicename = "";
public boolean _bluetoothstate = false;
public boolean _connectionstate = false;
public boolean _devicefound = false;
public String _devicemacadress = "";
public String _charset = "";
public anywheresoftware.b4a.keywords.StringBuilderWrapper _sb = null;
public String _state = "";
public b4a.HC05DataLogger.main _main = null;
public b4a.HC05DataLogger.starter _starter = null;
public String  _initialize(b4a.HC05DataLogger.bluetoothasynchstream __ref,anywheresoftware.b4a.BA _ba,Object _parent,String _eventname,anywheresoftware.b4a.objects.LabelWrapper _statuslabel,anywheresoftware.b4a.objects.ProgressBarWrapper _pgb) throws Exception{
__ref = this;
innerInitialize(_ba);
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "initialize", false))
	 {return ((String) Debug.delegate(ba, "initialize", new Object[] {_ba,_parent,_eventname,_statuslabel,_pgb}));}
RDebugUtils.currentLine=1179648;
 //BA.debugLineNum = 1179648;BA.debugLine="Public Sub Initialize(Parent As Object, EventName";
RDebugUtils.currentLine=1179649;
 //BA.debugLineNum = 1179649;BA.debugLine="mParent = Parent";
__ref._mparent /*Object*/  = _parent;
RDebugUtils.currentLine=1179650;
 //BA.debugLineNum = 1179650;BA.debugLine="mEventName = EventName";
__ref._meventname /*String*/  = _eventname;
RDebugUtils.currentLine=1179651;
 //BA.debugLineNum = 1179651;BA.debugLine="lblStatus = StatusLabel";
__ref._lblstatus /*anywheresoftware.b4a.objects.LabelWrapper*/  = _statuslabel;
RDebugUtils.currentLine=1179652;
 //BA.debugLineNum = 1179652;BA.debugLine="Admin.Initialize(\"Admin\")";
__ref._admin /*anywheresoftware.b4a.objects.Serial.BluetoothAdmin*/ .Initialize(ba,"Admin");
RDebugUtils.currentLine=1179653;
 //BA.debugLineNum = 1179653;BA.debugLine="Serial.Initialize(\"Serial\")";
__ref._serial /*anywheresoftware.b4a.objects.Serial*/ .Initialize("Serial");
RDebugUtils.currentLine=1179654;
 //BA.debugLineNum = 1179654;BA.debugLine="ProgressBar1 = Pgb";
__ref._progressbar1 /*anywheresoftware.b4a.objects.ProgressBarWrapper*/  = _pgb;
RDebugUtils.currentLine=1179655;
 //BA.debugLineNum = 1179655;BA.debugLine="sb.Initialize";
__ref._sb /*anywheresoftware.b4a.keywords.StringBuilderWrapper*/ .Initialize();
RDebugUtils.currentLine=1179657;
 //BA.debugLineNum = 1179657;BA.debugLine="If Admin.IsEnabled = False Then";
if (__ref._admin /*anywheresoftware.b4a.objects.Serial.BluetoothAdmin*/ .IsEnabled()==__c.False) { 
RDebugUtils.currentLine=1179658;
 //BA.debugLineNum = 1179658;BA.debugLine="If Admin.Enable = False Then";
if (__ref._admin /*anywheresoftware.b4a.objects.Serial.BluetoothAdmin*/ .Enable()==__c.False) { 
RDebugUtils.currentLine=1179659;
 //BA.debugLineNum = 1179659;BA.debugLine="ToastMessageShow(\"Error enabling Bluetooth adap";
__c.ToastMessageShow(BA.ObjectToCharSequence("Error enabling Bluetooth adapter."),__c.True);
 }else {
RDebugUtils.currentLine=1179661;
 //BA.debugLineNum = 1179661;BA.debugLine="ToastMessageShow(\"Enabling Bluetooth adapter...";
__c.ToastMessageShow(BA.ObjectToCharSequence("Enabling Bluetooth adapter..."),__c.False);
 };
 }else {
RDebugUtils.currentLine=1179664;
 //BA.debugLineNum = 1179664;BA.debugLine="BluetoothState = True";
__ref._bluetoothstate /*boolean*/  = __c.True;
 };
RDebugUtils.currentLine=1179666;
 //BA.debugLineNum = 1179666;BA.debugLine="End Sub";
return "";
}
public String  _sendbytes(b4a.HC05DataLogger.bluetoothasynchstream __ref,byte[] _buffer) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "sendbytes", false))
	 {return ((String) Debug.delegate(ba, "sendbytes", new Object[] {_buffer}));}
RDebugUtils.currentLine=1638400;
 //BA.debugLineNum = 1638400;BA.debugLine="Public Sub SendBytes(Buffer() As Byte)";
RDebugUtils.currentLine=1638401;
 //BA.debugLineNum = 1638401;BA.debugLine="Astreams.Write(Buffer)";
__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .Write(_buffer);
RDebugUtils.currentLine=1638402;
 //BA.debugLineNum = 1638402;BA.debugLine="End Sub";
return "";
}
public String  _disconnect(b4a.HC05DataLogger.bluetoothasynchstream __ref) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "disconnect", false))
	 {return ((String) Debug.delegate(ba, "disconnect", null));}
RDebugUtils.currentLine=1310720;
 //BA.debugLineNum = 1310720;BA.debugLine="Public Sub Disconnect";
RDebugUtils.currentLine=1310721;
 //BA.debugLineNum = 1310721;BA.debugLine="If Astreams.IsInitialized Then Astreams.Close";
if (__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .IsInitialized()) { 
__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .Close();};
RDebugUtils.currentLine=1310722;
 //BA.debugLineNum = 1310722;BA.debugLine="If Serial.IsInitialized Then Serial.Disconnect";
if (__ref._serial /*anywheresoftware.b4a.objects.Serial*/ .IsInitialized()) { 
__ref._serial /*anywheresoftware.b4a.objects.Serial*/ .Disconnect();};
RDebugUtils.currentLine=1310723;
 //BA.debugLineNum = 1310723;BA.debugLine="End Sub";
return "";
}
public String  _connect(b4a.HC05DataLogger.bluetoothasynchstream __ref,String _name) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "connect", false))
	 {return ((String) Debug.delegate(ba, "connect", new Object[] {_name}));}
boolean _success = false;
RDebugUtils.currentLine=1245184;
 //BA.debugLineNum = 1245184;BA.debugLine="Public Sub Connect(Name As String)";
RDebugUtils.currentLine=1245185;
 //BA.debugLineNum = 1245185;BA.debugLine="GenericDeviceName = Name";
__ref._genericdevicename /*String*/  = _name;
RDebugUtils.currentLine=1245186;
 //BA.debugLineNum = 1245186;BA.debugLine="Dim success As Boolean = Admin.StartDiscovery";
_success = __ref._admin /*anywheresoftware.b4a.objects.Serial.BluetoothAdmin*/ .StartDiscovery();
RDebugUtils.currentLine=1245187;
 //BA.debugLineNum = 1245187;BA.debugLine="If success = False Then";
if (_success==__c.False) { 
RDebugUtils.currentLine=1245188;
 //BA.debugLineNum = 1245188;BA.debugLine="lblStatus.Text = \"Error starting discovery proce";
__ref._lblstatus /*anywheresoftware.b4a.objects.LabelWrapper*/ .setText(BA.ObjectToCharSequence("Error starting discovery process."));
 }else {
RDebugUtils.currentLine=1245190;
 //BA.debugLineNum = 1245190;BA.debugLine="lblStatus.Text = \"Start discovery\"";
__ref._lblstatus /*anywheresoftware.b4a.objects.LabelWrapper*/ .setText(BA.ObjectToCharSequence("Start discovery"));
RDebugUtils.currentLine=1245191;
 //BA.debugLineNum = 1245191;BA.debugLine="ProgressBar1.Visible = True";
__ref._progressbar1 /*anywheresoftware.b4a.objects.ProgressBarWrapper*/ .setVisible(__c.True);
 };
RDebugUtils.currentLine=1245193;
 //BA.debugLineNum = 1245193;BA.debugLine="End Sub";
return "";
}
public String  _admin_devicefound(b4a.HC05DataLogger.bluetoothasynchstream __ref,String _name,String _macaddress) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "admin_devicefound", false))
	 {return ((String) Debug.delegate(ba, "admin_devicefound", new Object[] {_name,_macaddress}));}
RDebugUtils.currentLine=1376256;
 //BA.debugLineNum = 1376256;BA.debugLine="Private Sub Admin_DeviceFound (Name As String, Mac";
RDebugUtils.currentLine=1376257;
 //BA.debugLineNum = 1376257;BA.debugLine="Log(Name & \":\" & MacAddress)";
__c.LogImpl("31376257",_name+":"+_macaddress,0);
RDebugUtils.currentLine=1376258;
 //BA.debugLineNum = 1376258;BA.debugLine="If Name.Contains(GenericDeviceName) Then";
if (_name.contains(__ref._genericdevicename /*String*/ )) { 
RDebugUtils.currentLine=1376259;
 //BA.debugLineNum = 1376259;BA.debugLine="Log(GenericDeviceName & \" found\")";
__c.LogImpl("31376259",__ref._genericdevicename /*String*/ +" found",0);
RDebugUtils.currentLine=1376260;
 //BA.debugLineNum = 1376260;BA.debugLine="DeviceName = Name";
__ref._devicename /*String*/  = _name;
RDebugUtils.currentLine=1376261;
 //BA.debugLineNum = 1376261;BA.debugLine="DeviceMacAdress = MacAddress";
__ref._devicemacadress /*String*/  = _macaddress;
RDebugUtils.currentLine=1376265;
 //BA.debugLineNum = 1376265;BA.debugLine="If PH.SdkVersion <= 24 Then";
if (__ref._ph /*anywheresoftware.b4a.phone.Phone*/ .getSdkVersion()<=24) { 
RDebugUtils.currentLine=1376266;
 //BA.debugLineNum = 1376266;BA.debugLine="Admin.CancelDiscovery";
__ref._admin /*anywheresoftware.b4a.objects.Serial.BluetoothAdmin*/ .CancelDiscovery();
RDebugUtils.currentLine=1376267;
 //BA.debugLineNum = 1376267;BA.debugLine="lblStatus.Text = GenericDeviceName & \" found\"";
__ref._lblstatus /*anywheresoftware.b4a.objects.LabelWrapper*/ .setText(BA.ObjectToCharSequence(__ref._genericdevicename /*String*/ +" found"));
 }else {
RDebugUtils.currentLine=1376269;
 //BA.debugLineNum = 1376269;BA.debugLine="lblStatus.Text = GenericDeviceName & \" found, p";
__ref._lblstatus /*anywheresoftware.b4a.objects.LabelWrapper*/ .setText(BA.ObjectToCharSequence(__ref._genericdevicename /*String*/ +" found, please wait."));
 };
 };
RDebugUtils.currentLine=1376272;
 //BA.debugLineNum = 1376272;BA.debugLine="End Sub";
return "";
}
public String  _admin_discoveryfinished(b4a.HC05DataLogger.bluetoothasynchstream __ref) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "admin_discoveryfinished", false))
	 {return ((String) Debug.delegate(ba, "admin_discoveryfinished", null));}
RDebugUtils.currentLine=1441792;
 //BA.debugLineNum = 1441792;BA.debugLine="Private Sub Admin_DiscoveryFinished";
RDebugUtils.currentLine=1441793;
 //BA.debugLineNum = 1441793;BA.debugLine="If DeviceName = \"\" Then";
if ((__ref._devicename /*String*/ ).equals("")) { 
RDebugUtils.currentLine=1441794;
 //BA.debugLineNum = 1441794;BA.debugLine="lblStatus.Text = \"Device \" & GenericDeviceName &";
__ref._lblstatus /*anywheresoftware.b4a.objects.LabelWrapper*/ .setText(BA.ObjectToCharSequence("Device "+__ref._genericdevicename /*String*/ +" Not found"));
 }else {
RDebugUtils.currentLine=1441796;
 //BA.debugLineNum = 1441796;BA.debugLine="lblStatus.Text = \"Connecting to: \" & GenericDevi";
__ref._lblstatus /*anywheresoftware.b4a.objects.LabelWrapper*/ .setText(BA.ObjectToCharSequence("Connecting to: "+__ref._genericdevicename /*String*/ ));
RDebugUtils.currentLine=1441797;
 //BA.debugLineNum = 1441797;BA.debugLine="Serial.Connect(DeviceMacAdress)";
__ref._serial /*anywheresoftware.b4a.objects.Serial*/ .Connect(ba,__ref._devicemacadress /*String*/ );
 };
RDebugUtils.currentLine=1441799;
 //BA.debugLineNum = 1441799;BA.debugLine="End Sub";
return "";
}
public String  _admin_statechanged(b4a.HC05DataLogger.bluetoothasynchstream __ref,int _newstate,int _oldstate) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "admin_statechanged", false))
	 {return ((String) Debug.delegate(ba, "admin_statechanged", new Object[] {_newstate,_oldstate}));}
RDebugUtils.currentLine=1507328;
 //BA.debugLineNum = 1507328;BA.debugLine="Private Sub Admin_StateChanged (NewState As Int, O";
RDebugUtils.currentLine=1507329;
 //BA.debugLineNum = 1507329;BA.debugLine="Log(\"State changed: \" & NewState)";
__c.LogImpl("31507329","State changed: "+BA.NumberToString(_newstate),0);
RDebugUtils.currentLine=1507330;
 //BA.debugLineNum = 1507330;BA.debugLine="lblStatus.Text = \"State changed: \" & NewState";
__ref._lblstatus /*anywheresoftware.b4a.objects.LabelWrapper*/ .setText(BA.ObjectToCharSequence("State changed: "+BA.NumberToString(_newstate)));
RDebugUtils.currentLine=1507331;
 //BA.debugLineNum = 1507331;BA.debugLine="BluetoothState = NewState = Admin.STATE_ON";
__ref._bluetoothstate /*boolean*/  = _newstate==__ref._admin /*anywheresoftware.b4a.objects.Serial.BluetoothAdmin*/ .STATE_ON;
RDebugUtils.currentLine=1507332;
 //BA.debugLineNum = 1507332;BA.debugLine="End Sub";
return "";
}
public String  _ast_newtext(b4a.HC05DataLogger.bluetoothasynchstream __ref,String _text) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "ast_newtext", false))
	 {return ((String) Debug.delegate(ba, "ast_newtext", new Object[] {_text}));}
RDebugUtils.currentLine=1769472;
 //BA.debugLineNum = 1769472;BA.debugLine="Public Sub Ast_NewText(Text As String)";
RDebugUtils.currentLine=1769473;
 //BA.debugLineNum = 1769473;BA.debugLine="CallSubDelayed2(mParent, mEventName & \"_NewText\",";
__c.CallSubDelayed2(ba,__ref._mparent /*Object*/ ,__ref._meventname /*String*/ +"_NewText",(Object)(_text));
RDebugUtils.currentLine=1769474;
 //BA.debugLineNum = 1769474;BA.debugLine="Log(Text)";
__c.LogImpl("31769474",_text,0);
RDebugUtils.currentLine=1769475;
 //BA.debugLineNum = 1769475;BA.debugLine="End Sub";
return "";
}
public String  _astreams_error(b4a.HC05DataLogger.bluetoothasynchstream __ref) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "astreams_error", false))
	 {return ((String) Debug.delegate(ba, "astreams_error", null));}
RDebugUtils.currentLine=2097152;
 //BA.debugLineNum = 2097152;BA.debugLine="Private Sub Astreams_Error";
RDebugUtils.currentLine=2097153;
 //BA.debugLineNum = 2097153;BA.debugLine="Log(\"error: \" & LastException)";
__c.LogImpl("32097153","error: "+BA.ObjectToString(__c.LastException(ba)),0);
RDebugUtils.currentLine=2097154;
 //BA.debugLineNum = 2097154;BA.debugLine="Astreams.Close";
__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .Close();
RDebugUtils.currentLine=2097155;
 //BA.debugLineNum = 2097155;BA.debugLine="CallSubDelayed(mParent, mEventName & \"_Terminated";
__c.CallSubDelayed(ba,__ref._mparent /*Object*/ ,__ref._meventname /*String*/ +"_Terminated");
RDebugUtils.currentLine=2097156;
 //BA.debugLineNum = 2097156;BA.debugLine="End Sub";
return "";
}
public String  _astreams_newdata(b4a.HC05DataLogger.bluetoothasynchstream __ref,byte[] _buffer) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "astreams_newdata", false))
	 {return ((String) Debug.delegate(ba, "astreams_newdata", new Object[] {_buffer}));}
int _newdatastart = 0;
String _s = "";
int _start = 0;
int _i = 0;
char _c = '\0';
RDebugUtils.currentLine=1966080;
 //BA.debugLineNum = 1966080;BA.debugLine="Private Sub Astreams_NewData (Buffer() As Byte)";
RDebugUtils.currentLine=1966081;
 //BA.debugLineNum = 1966081;BA.debugLine="Dim newDataStart As Int = sb.Length";
_newdatastart = __ref._sb /*anywheresoftware.b4a.keywords.StringBuilderWrapper*/ .getLength();
RDebugUtils.currentLine=1966082;
 //BA.debugLineNum = 1966082;BA.debugLine="sb.Append(BytesToString(Buffer, 0, Buffer.Length,";
__ref._sb /*anywheresoftware.b4a.keywords.StringBuilderWrapper*/ .Append(__c.BytesToString(_buffer,(int) (0),_buffer.length,__ref._charset /*String*/ ));
RDebugUtils.currentLine=1966083;
 //BA.debugLineNum = 1966083;BA.debugLine="Dim s As String = sb.ToString";
_s = __ref._sb /*anywheresoftware.b4a.keywords.StringBuilderWrapper*/ .ToString();
RDebugUtils.currentLine=1966084;
 //BA.debugLineNum = 1966084;BA.debugLine="Dim start As Int = 0";
_start = (int) (0);
RDebugUtils.currentLine=1966085;
 //BA.debugLineNum = 1966085;BA.debugLine="For i = newDataStart To s.Length - 1";
{
final int step5 = 1;
final int limit5 = (int) (_s.length()-1);
_i = _newdatastart ;
for (;_i <= limit5 ;_i = _i + step5 ) {
RDebugUtils.currentLine=1966086;
 //BA.debugLineNum = 1966086;BA.debugLine="Dim c As Char = s.CharAt(i)";
_c = _s.charAt(_i);
RDebugUtils.currentLine=1966087;
 //BA.debugLineNum = 1966087;BA.debugLine="If i = 0 And c = Chr(10) Then '\\n...";
if (_i==0 && _c==__c.Chr((int) (10))) { 
RDebugUtils.currentLine=1966088;
 //BA.debugLineNum = 1966088;BA.debugLine="start = 1 'might be a broken end of line charac";
_start = (int) (1);
RDebugUtils.currentLine=1966089;
 //BA.debugLineNum = 1966089;BA.debugLine="Continue";
if (true) continue;
 };
RDebugUtils.currentLine=1966091;
 //BA.debugLineNum = 1966091;BA.debugLine="If c = Chr(10) Then '\\n";
if (_c==__c.Chr((int) (10))) { 
RDebugUtils.currentLine=1966092;
 //BA.debugLineNum = 1966092;BA.debugLine="CallSubDelayed2(mParent, mEventName & \"_NewText";
__c.CallSubDelayed2(ba,__ref._mparent /*Object*/ ,__ref._meventname /*String*/ +"_NewText",(Object)(_s.substring(_start,_i)));
RDebugUtils.currentLine=1966093;
 //BA.debugLineNum = 1966093;BA.debugLine="start = i + 1";
_start = (int) (_i+1);
 }else 
{RDebugUtils.currentLine=1966094;
 //BA.debugLineNum = 1966094;BA.debugLine="Else If c = Chr(13) Then '\\r";
if (_c==__c.Chr((int) (13))) { 
RDebugUtils.currentLine=1966095;
 //BA.debugLineNum = 1966095;BA.debugLine="CallSubDelayed2(mParent, mEventName & \"_NewText";
__c.CallSubDelayed2(ba,__ref._mparent /*Object*/ ,__ref._meventname /*String*/ +"_NewText",(Object)(_s.substring(_start,_i)));
RDebugUtils.currentLine=1966096;
 //BA.debugLineNum = 1966096;BA.debugLine="If i < s.Length - 1 And s.CharAt(i + 1) = Chr(1";
if (_i<_s.length()-1 && _s.charAt((int) (_i+1))==__c.Chr((int) (10))) { 
RDebugUtils.currentLine=1966097;
 //BA.debugLineNum = 1966097;BA.debugLine="i = i + 1";
_i = (int) (_i+1);
 };
RDebugUtils.currentLine=1966099;
 //BA.debugLineNum = 1966099;BA.debugLine="start = i + 1";
_start = (int) (_i+1);
 }}
;
 }
};
RDebugUtils.currentLine=1966102;
 //BA.debugLineNum = 1966102;BA.debugLine="If start > 0 Then sb.Remove(0, start)";
if (_start>0) { 
__ref._sb /*anywheresoftware.b4a.keywords.StringBuilderWrapper*/ .Remove((int) (0),_start);};
RDebugUtils.currentLine=1966103;
 //BA.debugLineNum = 1966103;BA.debugLine="End Sub";
return "";
}
public String  _astreams_terminated(b4a.HC05DataLogger.bluetoothasynchstream __ref) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "astreams_terminated", false))
	 {return ((String) Debug.delegate(ba, "astreams_terminated", null));}
RDebugUtils.currentLine=2031616;
 //BA.debugLineNum = 2031616;BA.debugLine="Private Sub Astreams_Terminated";
RDebugUtils.currentLine=2031617;
 //BA.debugLineNum = 2031617;BA.debugLine="CallSubDelayed(mParent, mEventName & \"_Terminated";
__c.CallSubDelayed(ba,__ref._mparent /*Object*/ ,__ref._meventname /*String*/ +"_Terminated");
RDebugUtils.currentLine=2031618;
 //BA.debugLineNum = 2031618;BA.debugLine="End Sub";
return "";
}
public String  _class_globals(b4a.HC05DataLogger.bluetoothasynchstream __ref) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
RDebugUtils.currentLine=1114112;
 //BA.debugLineNum = 1114112;BA.debugLine="Sub Class_Globals";
RDebugUtils.currentLine=1114113;
 //BA.debugLineNum = 1114113;BA.debugLine="Private Admin As BluetoothAdmin";
_admin = new anywheresoftware.b4a.objects.Serial.BluetoothAdmin();
RDebugUtils.currentLine=1114114;
 //BA.debugLineNum = 1114114;BA.debugLine="Public Astreams As AsyncStreams";
_astreams = new anywheresoftware.b4a.randomaccessfile.AsyncStreams();
RDebugUtils.currentLine=1114115;
 //BA.debugLineNum = 1114115;BA.debugLine="Private Serial As Serial";
_serial = new anywheresoftware.b4a.objects.Serial();
RDebugUtils.currentLine=1114116;
 //BA.debugLineNum = 1114116;BA.debugLine="Private PH As Phone";
_ph = new anywheresoftware.b4a.phone.Phone();
RDebugUtils.currentLine=1114117;
 //BA.debugLineNum = 1114117;BA.debugLine="Private mParent As Object";
_mparent = new Object();
RDebugUtils.currentLine=1114118;
 //BA.debugLineNum = 1114118;BA.debugLine="Private mEventName As String";
_meventname = "";
RDebugUtils.currentLine=1114119;
 //BA.debugLineNum = 1114119;BA.debugLine="Private lblStatus As Label";
_lblstatus = new anywheresoftware.b4a.objects.LabelWrapper();
RDebugUtils.currentLine=1114120;
 //BA.debugLineNum = 1114120;BA.debugLine="Private ProgressBar1 As ProgressBar";
_progressbar1 = new anywheresoftware.b4a.objects.ProgressBarWrapper();
RDebugUtils.currentLine=1114122;
 //BA.debugLineNum = 1114122;BA.debugLine="Private GenericDeviceName, DeviceName As String";
_genericdevicename = "";
_devicename = "";
RDebugUtils.currentLine=1114124;
 //BA.debugLineNum = 1114124;BA.debugLine="Public BluetoothState, ConnectionState, DeviceFou";
_bluetoothstate = false;
_connectionstate = false;
_devicefound = false;
RDebugUtils.currentLine=1114125;
 //BA.debugLineNum = 1114125;BA.debugLine="Private DeviceName, DeviceMacAdress As String";
_devicename = "";
_devicemacadress = "";
RDebugUtils.currentLine=1114127;
 //BA.debugLineNum = 1114127;BA.debugLine="Public CharSet = \"UTF-8\" As String";
_charset = "UTF-8";
RDebugUtils.currentLine=1114128;
 //BA.debugLineNum = 1114128;BA.debugLine="Private sb As StringBuilder";
_sb = new anywheresoftware.b4a.keywords.StringBuilderWrapper();
RDebugUtils.currentLine=1114129;
 //BA.debugLineNum = 1114129;BA.debugLine="Public State As String";
_state = "";
RDebugUtils.currentLine=1114130;
 //BA.debugLineNum = 1114130;BA.debugLine="End Sub";
return "";
}
public String  _close(b4a.HC05DataLogger.bluetoothasynchstream __ref) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "close", false))
	 {return ((String) Debug.delegate(ba, "close", null));}
RDebugUtils.currentLine=2162688;
 //BA.debugLineNum = 2162688;BA.debugLine="Public Sub Close";
RDebugUtils.currentLine=2162689;
 //BA.debugLineNum = 2162689;BA.debugLine="Astreams.Close";
__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .Close();
RDebugUtils.currentLine=2162690;
 //BA.debugLineNum = 2162690;BA.debugLine="End Sub";
return "";
}
public String  _sendtext(b4a.HC05DataLogger.bluetoothasynchstream __ref,String _text) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "sendtext", false))
	 {return ((String) Debug.delegate(ba, "sendtext", new Object[] {_text}));}
RDebugUtils.currentLine=1703936;
 //BA.debugLineNum = 1703936;BA.debugLine="Public Sub SendText(Text As String)";
RDebugUtils.currentLine=1703937;
 //BA.debugLineNum = 1703937;BA.debugLine="Astreams.Write(Text.GetBytes(CharSet))";
__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .Write(_text.getBytes(__ref._charset /*String*/ ));
RDebugUtils.currentLine=1703938;
 //BA.debugLineNum = 1703938;BA.debugLine="End Sub";
return "";
}
public String  _serial_connected(b4a.HC05DataLogger.bluetoothasynchstream __ref,boolean _success) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "serial_connected", false))
	 {return ((String) Debug.delegate(ba, "serial_connected", new Object[] {_success}));}
String _msg = "";
RDebugUtils.currentLine=1572864;
 //BA.debugLineNum = 1572864;BA.debugLine="Sub Serial_Connected (Success As Boolean)";
RDebugUtils.currentLine=1572865;
 //BA.debugLineNum = 1572865;BA.debugLine="Private msg As String";
_msg = "";
RDebugUtils.currentLine=1572866;
 //BA.debugLineNum = 1572866;BA.debugLine="If Success = True Then";
if (_success==__c.True) { 
RDebugUtils.currentLine=1572867;
 //BA.debugLineNum = 1572867;BA.debugLine="If Astreams.IsInitialized Then Astreams.Close";
if (__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .IsInitialized()) { 
__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .Close();};
RDebugUtils.currentLine=1572868;
 //BA.debugLineNum = 1572868;BA.debugLine="Astreams.Initialize(Serial.InputStream, Serial.O";
__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .Initialize(ba,__ref._serial /*anywheresoftware.b4a.objects.Serial*/ .getInputStream(),__ref._serial /*anywheresoftware.b4a.objects.Serial*/ .getOutputStream(),"Astreams");
RDebugUtils.currentLine=1572869;
 //BA.debugLineNum = 1572869;BA.debugLine="msg = \"Connected\"";
_msg = "Connected";
RDebugUtils.currentLine=1572870;
 //BA.debugLineNum = 1572870;BA.debugLine="ProgressBar1.Visible = False";
__ref._progressbar1 /*anywheresoftware.b4a.objects.ProgressBarWrapper*/ .setVisible(__c.False);
 }else {
RDebugUtils.currentLine=1572872;
 //BA.debugLineNum = 1572872;BA.debugLine="Log(LastException.Message)";
__c.LogImpl("31572872",__c.LastException(ba).getMessage(),0);
RDebugUtils.currentLine=1572873;
 //BA.debugLineNum = 1572873;BA.debugLine="msg = LastException.Message";
_msg = __c.LastException(ba).getMessage();
 };
RDebugUtils.currentLine=1572875;
 //BA.debugLineNum = 1572875;BA.debugLine="lblStatus.Text = msg";
__ref._lblstatus /*anywheresoftware.b4a.objects.LabelWrapper*/ .setText(BA.ObjectToCharSequence(_msg));
RDebugUtils.currentLine=1572876;
 //BA.debugLineNum = 1572876;BA.debugLine="CallSubDelayed2(mParent, mEventName & \"_Connected";
__c.CallSubDelayed2(ba,__ref._mparent /*Object*/ ,__ref._meventname /*String*/ +"_Connected",(Object)(_success));
RDebugUtils.currentLine=1572877;
 //BA.debugLineNum = 1572877;BA.debugLine="End Sub";
return "";
}
public String  _writebytes(b4a.HC05DataLogger.bluetoothasynchstream __ref,byte[] _buffer) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "writebytes", false))
	 {return ((String) Debug.delegate(ba, "writebytes", new Object[] {_buffer}));}
RDebugUtils.currentLine=1900544;
 //BA.debugLineNum = 1900544;BA.debugLine="Public Sub WriteBytes(Buffer() As Byte)";
RDebugUtils.currentLine=1900545;
 //BA.debugLineNum = 1900545;BA.debugLine="Astreams.Write(Buffer)";
__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .Write(_buffer);
RDebugUtils.currentLine=1900546;
 //BA.debugLineNum = 1900546;BA.debugLine="End Sub";
return "";
}
public String  _writetext(b4a.HC05DataLogger.bluetoothasynchstream __ref,String _text) throws Exception{
__ref = this;
RDebugUtils.currentModule="bluetoothasynchstream";
if (Debug.shouldDelegate(ba, "writetext", false))
	 {return ((String) Debug.delegate(ba, "writetext", new Object[] {_text}));}
RDebugUtils.currentLine=1835008;
 //BA.debugLineNum = 1835008;BA.debugLine="Public Sub WriteText(Text As String)";
RDebugUtils.currentLine=1835009;
 //BA.debugLineNum = 1835009;BA.debugLine="Astreams.Write(Text.GetBytes(CharSet))";
__ref._astreams /*anywheresoftware.b4a.randomaccessfile.AsyncStreams*/ .Write(_text.getBytes(__ref._charset /*String*/ ));
RDebugUtils.currentLine=1835010;
 //BA.debugLineNum = 1835010;BA.debugLine="End Sub";
return "";
}
}