mirror of
https://github.com/TimeCrafters/FTC_2022
synced 2025-12-16 15:52:35 +00:00
Added opmodes to start/stop TACNET service, sync.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package org.timecrafters.tacnet_management;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||
|
||||
import org.firstinspires.ftc.robotcontroller.internal.FtcRobotControllerActivity;
|
||||
|
||||
@TeleOp(name = "Halt TACNET Service", group = "TACNET")
|
||||
public class HaltTACNETService extends OpMode {
|
||||
@Override
|
||||
public void init() {
|
||||
Context appContext = FtcRobotControllerActivity.getAppActivity().getApplicationContext();
|
||||
Intent tacnetIntent = new Intent("org.timecrafters.TimeCraftersConfigurationTool.tacnet.ACTION_START_SERVER");
|
||||
tacnetIntent.setPackage("org.timecrafters.TimeCraftersConfigurationTool");
|
||||
|
||||
appContext.stopService(tacnetIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loop() {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.timecrafters.tacnet_management;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
|
||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||
|
||||
import org.firstinspires.ftc.robotcontroller.internal.FtcRobotControllerActivity;
|
||||
|
||||
@TeleOp(name = "Start TACNET Service", group = "TACNET")
|
||||
public class StartTACNETService extends OpMode {
|
||||
@Override
|
||||
public void init() {
|
||||
Context appContext = FtcRobotControllerActivity.getAppActivity().getApplicationContext();
|
||||
Intent tacnetIntent = new Intent("org.timecrafters.TimeCraftersConfigurationTool.tacnet.ACTION_START_SERVER");
|
||||
tacnetIntent.setPackage("org.timecrafters.TimeCraftersConfigurationTool");
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
appContext.startForegroundService(tacnetIntent);
|
||||
} else {
|
||||
appContext.startService(tacnetIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loop() {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user