package b4a.HC05LightDimmer;

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

public class starter_subs_0 {


public static RemoteObject  _admin_devicefound(RemoteObject _name,RemoteObject _macaddress) throws Exception{
try {
		Debug.PushSubsStack("admin_DeviceFound (starter) ","starter",1,starter.processBA,starter.mostCurrent,26);
if (RapidSub.canDelegate("admin_devicefound")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","admin_devicefound", _name, _macaddress);}
Debug.locals.put("Name", _name);
Debug.locals.put("MacAddress", _macaddress);
 BA.debugLineNum = 26;BA.debugLine="Private Sub admin_DeviceFound (Name As String, Mac";
Debug.ShouldStop(33554432);
 BA.debugLineNum = 27;BA.debugLine="Log($\"Device found: ${Name}\"$)";
Debug.ShouldStop(67108864);
starter.mostCurrent.__c.runVoidMethod ("LogImpl","5786433",(RemoteObject.concat(RemoteObject.createImmutable("Device found: "),starter.mostCurrent.__c.runMethod(true,"SmartStringFormatter",(Object)(BA.ObjectToString("")),(Object)((_name))),RemoteObject.createImmutable(""))),0);
 BA.debugLineNum = 28;BA.debugLine="If Name = \"HC-05\" Then";
Debug.ShouldStop(134217728);
if (RemoteObject.solveBoolean("=",_name,BA.ObjectToString("HC-05"))) { 
 BA.debugLineNum = 29;BA.debugLine="admin.CancelDiscovery";
Debug.ShouldStop(268435456);
starter._admin.runVoidMethod ("CancelDiscovery");
 BA.debugLineNum = 30;BA.debugLine="serial.Connect(MacAddress)";
Debug.ShouldStop(536870912);
starter._serial.runVoidMethod ("Connect",starter.processBA,(Object)(_macaddress));
 BA.debugLineNum = 31;BA.debugLine="TryToConnect = False";
Debug.ShouldStop(1073741824);
starter._trytoconnect = starter.mostCurrent.__c.getField(true,"False");
 BA.debugLineNum = 32;BA.debugLine="Connecting = True";
Debug.ShouldStop(-2147483648);
starter._connecting = starter.mostCurrent.__c.getField(true,"True");
 BA.debugLineNum = 33;BA.debugLine="CallSub(Main, \"SetState\")";
Debug.ShouldStop(1);
starter.mostCurrent.__c.runMethodAndSync(false,"CallSubNew",starter.processBA,(Object)((starter.mostCurrent._main.getObject())),(Object)(RemoteObject.createImmutable("SetState")));
 };
 BA.debugLineNum = 35;BA.debugLine="End Sub";
Debug.ShouldStop(4);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _admin_discoveryfinished() throws Exception{
try {
		Debug.PushSubsStack("admin_DiscoveryFinished (starter) ","starter",1,starter.processBA,starter.mostCurrent,37);
if (RapidSub.canDelegate("admin_discoveryfinished")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","admin_discoveryfinished");}
 BA.debugLineNum = 37;BA.debugLine="Private Sub admin_DiscoveryFinished";
Debug.ShouldStop(16);
 BA.debugLineNum = 38;BA.debugLine="If Connecting = False Then";
Debug.ShouldStop(32);
if (RemoteObject.solveBoolean("=",starter._connecting,starter.mostCurrent.__c.getField(true,"False"))) { 
 BA.debugLineNum = 39;BA.debugLine="TryToConnect = False";
Debug.ShouldStop(64);
starter._trytoconnect = starter.mostCurrent.__c.getField(true,"False");
 BA.debugLineNum = 40;BA.debugLine="CallSub(Main, \"SetState\")";
Debug.ShouldStop(128);
starter.mostCurrent.__c.runMethodAndSync(false,"CallSubNew",starter.processBA,(Object)((starter.mostCurrent._main.getObject())),(Object)(RemoteObject.createImmutable("SetState")));
 };
 BA.debugLineNum = 42;BA.debugLine="End Sub";
Debug.ShouldStop(512);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _application_error(RemoteObject _error,RemoteObject _stacktrace) throws Exception{
try {
		Debug.PushSubsStack("Application_Error (starter) ","starter",1,starter.processBA,starter.mostCurrent,75);
if (RapidSub.canDelegate("application_error")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","application_error", _error, _stacktrace);}
Debug.locals.put("Error", _error);
Debug.locals.put("StackTrace", _stacktrace);
 BA.debugLineNum = 75;BA.debugLine="Sub Application_Error (Error As Exception, StackTr";
Debug.ShouldStop(1024);
 BA.debugLineNum = 76;BA.debugLine="Return True";
Debug.ShouldStop(2048);
if (true) return starter.mostCurrent.__c.getField(true,"True");
 BA.debugLineNum = 77;BA.debugLine="End Sub";
Debug.ShouldStop(4096);
return RemoteObject.createImmutable(false);
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _ast_newtext(RemoteObject _text) throws Exception{
try {
		Debug.PushSubsStack("ast_NewText (starter) ","starter",1,starter.processBA,starter.mostCurrent,61);
if (RapidSub.canDelegate("ast_newtext")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","ast_newtext", _text);}
Debug.locals.put("Text", _text);
 BA.debugLineNum = 61;BA.debugLine="Private Sub ast_NewText (Text As String)";
Debug.ShouldStop(268435456);
 BA.debugLineNum = 62;BA.debugLine="CallSub2(Main, \"MessageFromDevice\", Text)";
Debug.ShouldStop(536870912);
starter.mostCurrent.__c.runMethodAndSync(false,"CallSubNew2",starter.processBA,(Object)((starter.mostCurrent._main.getObject())),(Object)(BA.ObjectToString("MessageFromDevice")),(Object)((_text)));
 BA.debugLineNum = 63;BA.debugLine="End Sub";
Debug.ShouldStop(1073741824);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _ast_terminated() throws Exception{
try {
		Debug.PushSubsStack("ast_Terminated (starter) ","starter",1,starter.processBA,starter.mostCurrent,65);
if (RapidSub.canDelegate("ast_terminated")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","ast_terminated");}
 BA.debugLineNum = 65;BA.debugLine="Private Sub ast_Terminated";
Debug.ShouldStop(1);
 BA.debugLineNum = 66;BA.debugLine="Connected = False";
Debug.ShouldStop(2);
starter._connected = starter.mostCurrent.__c.getField(true,"False");
 BA.debugLineNum = 67;BA.debugLine="CallSub(Main, \"SetState\")";
Debug.ShouldStop(4);
starter.mostCurrent.__c.runMethodAndSync(false,"CallSubNew",starter.processBA,(Object)((starter.mostCurrent._main.getObject())),(Object)(RemoteObject.createImmutable("SetState")));
 BA.debugLineNum = 68;BA.debugLine="End Sub";
Debug.ShouldStop(8);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _connect() throws Exception{
try {
		Debug.PushSubsStack("Connect (starter) ","starter",1,starter.processBA,starter.mostCurrent,20);
if (RapidSub.canDelegate("connect")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","connect");}
 BA.debugLineNum = 20;BA.debugLine="Public Sub Connect";
Debug.ShouldStop(524288);
 BA.debugLineNum = 21;BA.debugLine="admin.StartDiscovery";
Debug.ShouldStop(1048576);
starter._admin.runVoidMethod ("StartDiscovery");
 BA.debugLineNum = 22;BA.debugLine="TryToConnect = True";
Debug.ShouldStop(2097152);
starter._trytoconnect = starter.mostCurrent.__c.getField(true,"True");
 BA.debugLineNum = 23;BA.debugLine="CallSub(Main, \"SetState\")";
Debug.ShouldStop(4194304);
starter.mostCurrent.__c.runMethodAndSync(false,"CallSubNew",starter.processBA,(Object)((starter.mostCurrent._main.getObject())),(Object)(RemoteObject.createImmutable("SetState")));
 BA.debugLineNum = 24;BA.debugLine="End Sub";
Debug.ShouldStop(8388608);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _process_globals() throws Exception{
 //BA.debugLineNum = 6;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 7;BA.debugLine="Private serial As Serial";
starter._serial = RemoteObject.createNew ("anywheresoftware.b4a.objects.Serial");
 //BA.debugLineNum = 8;BA.debugLine="Private admin As BluetoothAdmin";
starter._admin = RemoteObject.createNew ("anywheresoftware.b4a.objects.Serial.BluetoothAdmin");
 //BA.debugLineNum = 9;BA.debugLine="Private ast As AsyncStreamsText";
starter._ast = RemoteObject.createNew ("b4a.HC05LightDimmer.asyncstreamstext");
 //BA.debugLineNum = 10;BA.debugLine="Public Connected = False As Boolean";
starter._connected = starter.mostCurrent.__c.getField(true,"False");
 //BA.debugLineNum = 11;BA.debugLine="Public Connecting = False As Boolean";
starter._connecting = starter.mostCurrent.__c.getField(true,"False");
 //BA.debugLineNum = 12;BA.debugLine="Public TryToConnect = False As Boolean";
starter._trytoconnect = starter.mostCurrent.__c.getField(true,"False");
 //BA.debugLineNum = 13;BA.debugLine="End Sub";
return RemoteObject.createImmutable("");
}
public static RemoteObject  _sendmessage(RemoteObject _msg) throws Exception{
try {
		Debug.PushSubsStack("SendMessage (starter) ","starter",1,starter.processBA,starter.mostCurrent,57);
if (RapidSub.canDelegate("sendmessage")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","sendmessage", _msg);}
Debug.locals.put("msg", _msg);
 BA.debugLineNum = 57;BA.debugLine="Public Sub SendMessage(msg() As Byte)";
Debug.ShouldStop(16777216);
 BA.debugLineNum = 58;BA.debugLine="ast.astreams.Write(msg) 'sending bytes, not text";
Debug.ShouldStop(33554432);
starter._ast.getField(false,"_astreams").runVoidMethod ("Write",(Object)(_msg));
 BA.debugLineNum = 59;BA.debugLine="End Sub";
Debug.ShouldStop(67108864);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _serial_connected(RemoteObject _success) throws Exception{
try {
		Debug.PushSubsStack("Serial_Connected (starter) ","starter",1,starter.processBA,starter.mostCurrent,44);
if (RapidSub.canDelegate("serial_connected")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","serial_connected", _success);}
Debug.locals.put("Success", _success);
 BA.debugLineNum = 44;BA.debugLine="Private Sub Serial_Connected (Success As Boolean)";
Debug.ShouldStop(2048);
 BA.debugLineNum = 45;BA.debugLine="If Success Then";
Debug.ShouldStop(4096);
if (_success.<Boolean>get().booleanValue()) { 
 BA.debugLineNum = 46;BA.debugLine="If ast.IsInitialized Then ast.Close";
Debug.ShouldStop(8192);
if (starter._ast.runMethod(true,"IsInitialized").<Boolean>get().booleanValue()) { 
starter._ast.runClassMethod (b4a.HC05LightDimmer.asyncstreamstext.class, "_close");};
 BA.debugLineNum = 47;BA.debugLine="ast.Initialize(Me, \"Ast\", serial.InputStream, se";
Debug.ShouldStop(16384);
starter._ast.runClassMethod (b4a.HC05LightDimmer.asyncstreamstext.class, "_initialize",starter.processBA,(Object)(starter.getObject()),(Object)(BA.ObjectToString("Ast")),RemoteObject.declareNull("anywheresoftware.b4a.AbsObjectWrapper").runMethod(false, "ConvertToWrapper", RemoteObject.createNew("anywheresoftware.b4a.objects.streams.File.InputStreamWrapper"), starter._serial.runMethod(false,"getInputStream")),RemoteObject.declareNull("anywheresoftware.b4a.AbsObjectWrapper").runMethod(false, "ConvertToWrapper", RemoteObject.createNew("anywheresoftware.b4a.objects.streams.File.OutputStreamWrapper"), starter._serial.runMethod(false,"getOutputStream")));
 BA.debugLineNum = 48;BA.debugLine="Log(\"Connected\")";
Debug.ShouldStop(32768);
starter.mostCurrent.__c.runVoidMethod ("LogImpl","5917508",RemoteObject.createImmutable("Connected"),0);
 BA.debugLineNum = 49;BA.debugLine="Connected = True";
Debug.ShouldStop(65536);
starter._connected = starter.mostCurrent.__c.getField(true,"True");
 }else {
 BA.debugLineNum = 51;BA.debugLine="Log(LastException)";
Debug.ShouldStop(262144);
starter.mostCurrent.__c.runVoidMethod ("LogImpl","5917511",BA.ObjectToString(starter.mostCurrent.__c.runMethod(false,"LastException",starter.processBA)),0);
 };
 BA.debugLineNum = 53;BA.debugLine="Connecting = False";
Debug.ShouldStop(1048576);
starter._connecting = starter.mostCurrent.__c.getField(true,"False");
 BA.debugLineNum = 54;BA.debugLine="CallSub(Main, \"SetState\")";
Debug.ShouldStop(2097152);
starter.mostCurrent.__c.runMethodAndSync(false,"CallSubNew",starter.processBA,(Object)((starter.mostCurrent._main.getObject())),(Object)(RemoteObject.createImmutable("SetState")));
 BA.debugLineNum = 55;BA.debugLine="End Sub";
Debug.ShouldStop(4194304);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _service_create() throws Exception{
try {
		Debug.PushSubsStack("Service_Create (starter) ","starter",1,starter.processBA,starter.mostCurrent,15);
if (RapidSub.canDelegate("service_create")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","service_create");}
 BA.debugLineNum = 15;BA.debugLine="Sub Service_Create";
Debug.ShouldStop(16384);
 BA.debugLineNum = 16;BA.debugLine="serial.Initialize(\"serial\")";
Debug.ShouldStop(32768);
starter._serial.runVoidMethod ("Initialize",(Object)(RemoteObject.createImmutable("serial")));
 BA.debugLineNum = 17;BA.debugLine="admin.Initialize(\"admin\")";
Debug.ShouldStop(65536);
starter._admin.runVoidMethod ("Initialize",starter.processBA,(Object)(RemoteObject.createImmutable("admin")));
 BA.debugLineNum = 18;BA.debugLine="End Sub";
Debug.ShouldStop(131072);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _service_destroy() throws Exception{
try {
		Debug.PushSubsStack("Service_Destroy (starter) ","starter",1,starter.processBA,starter.mostCurrent,79);
if (RapidSub.canDelegate("service_destroy")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","service_destroy");}
 BA.debugLineNum = 79;BA.debugLine="Sub Service_Destroy";
Debug.ShouldStop(16384);
 BA.debugLineNum = 81;BA.debugLine="End Sub";
Debug.ShouldStop(65536);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
public static RemoteObject  _service_start(RemoteObject _startingintent) throws Exception{
try {
		Debug.PushSubsStack("Service_Start (starter) ","starter",1,starter.processBA,starter.mostCurrent,70);
if (RapidSub.canDelegate("service_start")) { return b4a.HC05LightDimmer.starter.remoteMe.runUserSub(false, "starter","service_start", _startingintent);}
Debug.locals.put("StartingIntent", _startingintent);
 BA.debugLineNum = 70;BA.debugLine="Sub Service_Start (StartingIntent As Intent)";
Debug.ShouldStop(32);
 BA.debugLineNum = 72;BA.debugLine="End Sub";
Debug.ShouldStop(128);
return RemoteObject.createImmutable("");
}
catch (Exception e) {
			throw Debug.ErrorCaught(e);
		} 
finally {
			Debug.PopSubsStack();
		}}
}