-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bring back kill switch #1511
Bring back kill switch #1511
Changes from 4 commits
9fb2984
337ca72
98d5eca
790591d
1bd1a66
356cb43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,11 @@ | |
import android.view.MenuItem; | ||
|
||
import com.o3dr.android.client.Drone; | ||
import com.o3dr.android.client.apis.drone.DroneStateApi; | ||
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; | ||
import com.o3dr.services.android.lib.drone.attribute.AttributeType; | ||
import com.o3dr.services.android.lib.drone.property.Type; | ||
import com.o3dr.services.android.lib.drone.property.VehicleMode; | ||
|
||
import org.droidplanner.android.DroidPlannerApp; | ||
import org.droidplanner.android.R; | ||
|
@@ -40,7 +44,6 @@ public abstract class SuperUI extends AppCompatActivity implements DroidPlannerA | |
static { | ||
superIntentFilter.addAction(AttributeEvent.STATE_CONNECTED); | ||
superIntentFilter.addAction(AttributeEvent.STATE_DISCONNECTED); | ||
superIntentFilter.addAction(SettingsFragment.ACTION_ADVANCED_MENU_UPDATED); | ||
} | ||
|
||
private final BroadcastReceiver superReceiver = new BroadcastReceiver() { | ||
|
@@ -55,10 +58,6 @@ public void onReceive(Context context, Intent intent) { | |
case AttributeEvent.STATE_DISCONNECTED: | ||
onDroneDisconnected(); | ||
break; | ||
|
||
case SettingsFragment.ACTION_ADVANCED_MENU_UPDATED: | ||
supportInvalidateOptionsMenu(); | ||
break; | ||
} | ||
} | ||
}; | ||
|
@@ -175,12 +174,6 @@ public boolean onCreateOptionsMenu(Menu menu) { | |
menu.setGroupEnabled(R.id.menu_group_connected, true); | ||
menu.setGroupVisible(R.id.menu_group_connected, true); | ||
|
||
final boolean isAdvancedEnabled = mAppPrefs.isAdvancedMenuEnabled(); | ||
final MenuItem advancedSubMenu = menu.findItem(R.id.menu_advanced); | ||
advancedSubMenu.setEnabled(isAdvancedEnabled); | ||
advancedSubMenu.setVisible(isAdvancedEnabled); | ||
|
||
//Enable specific sub items within the advanced menu section. | ||
final MenuItem killSwitchItem = menu.findItem(R.id.menu_kill_switch); | ||
final boolean isKillEnabled = mAppPrefs.isKillSwitchEnabled(); | ||
killSwitchItem.setEnabled(isKillEnabled); | ||
|
@@ -256,7 +249,20 @@ public void onNo() { | |
SlideToUnlockDialog unlockDialog = SlideToUnlockDialog.newInstance("disable vehicle", new Runnable() { | ||
@Override | ||
public void run() { | ||
dpApp.getDrone().arm(false); | ||
/* If the vehicle is a Copter running a firmware older than 3.3, | ||
set the vehicle to stabilize. Otherwise, leave the mode alone. | ||
Then send the emergency disarm command. | ||
*/ | ||
Drone drone = dpApp.getDrone(); | ||
Type droneType = drone.getAttribute(AttributeType.TYPE); | ||
if(droneType !=null){ | ||
if(droneType.getDroneType() == (Type.TYPE_COPTER) && | ||
!droneType.getFirmwareVersion().startsWith("APM:Copter V3.3") && | ||
!droneType.getFirmwareVersion().startsWith("APM:Copter V3.4")){ | ||
DroneStateApi.setVehicleMode(drone, VehicleMode.COPTER_STABILIZE); | ||
} | ||
} | ||
DroneStateApi.arm(drone, false, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @squilter the version check logic can be removed. It's handled by 3DR Services in https://github.com/DroidPlanner/DroneKit-Android/blob/371cfd568046fc772726f9af3b2baf3e9e1dd866/ServiceApp/src/org/droidplanner/services/android/api/DroneApiUtils.java#L682-L748 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That logic is now up in the develop branch for 3DR Services. |
||
} | ||
}); | ||
unlockDialog.show(getSupportFragmentManager(), "Slide to use the Kill Switch"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upgrade to version
2.3.34
. Version2.3.33
has a bug that the newer version fixes.