Skip to content

Commit 00ef6e3

Browse files
committed
Added missing CREATOR used to unparcel the SoloShotOptions message.
Added test code for access to the `SoloState` state.
1 parent cbefc4f commit 00ef6e3

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/SoloFollowOptions.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
*/
1010
public class SoloFollowOptions extends SoloShotOptions {
1111

12-
private static final String TAG = SoloFollowOptions.class.getSimpleName();
13-
1412
private static final int LOOK_AT_ENABLED_VALUE = 1;
1513
private static final int LOOK_AT_DISABLED_VALUE = 0;
1614

ClientLib/src/main/java/com/o3dr/services/android/lib/drone/companion/solo/tlv/SoloShotOptions.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,17 @@ protected SoloShotOptions(Parcel in) {
5555
this.cruiseSpeed = in.readFloat();
5656
}
5757

58+
public static final Creator<SoloShotOptions> CREATOR = new Creator<SoloShotOptions>(){
59+
60+
@Override
61+
public SoloShotOptions createFromParcel(Parcel source) {
62+
return new SoloShotOptions(source);
63+
}
64+
65+
@Override
66+
public SoloShotOptions[] newArray(int size) {
67+
return new SoloShotOptions[size];
68+
}
69+
};
70+
5871
}

samples/StarterApp/src/main/java/com/o3dr/sample/hellodrone/MainActivity.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import com.o3dr.services.android.lib.coordinate.LatLongAlt;
2727
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent;
2828
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
29+
import com.o3dr.services.android.lib.drone.companion.solo.SoloAttributes;
30+
import com.o3dr.services.android.lib.drone.companion.solo.SoloState;
2931
import com.o3dr.services.android.lib.drone.connection.ConnectionParameter;
3032
import com.o3dr.services.android.lib.drone.connection.ConnectionResult;
3133
import com.o3dr.services.android.lib.drone.connection.ConnectionType;
@@ -187,6 +189,7 @@ public void onDroneEvent(String event, Bundle extras) {
187189
alertUser("Drone Connected");
188190
updateConnectedButton(this.drone.isConnected());
189191
updateArmButton();
192+
checkSoloState();
190193
break;
191194

192195
case AttributeEvent.STATE_DISCONNECTED:
@@ -232,6 +235,16 @@ public void onDroneEvent(String event, Bundle extras) {
232235

233236
}
234237

238+
private void checkSoloState() {
239+
final SoloState soloState = drone.getAttribute(SoloAttributes.SOLO_STATE);
240+
if(soloState == null){
241+
alertUser("Unable to retrieve the solo state.");
242+
}
243+
else{
244+
alertUser("Solo state is up to date.");
245+
}
246+
}
247+
235248
@Override
236249
public void onDroneConnectionFailed(ConnectionResult result) {
237250
alertUser("Connection Failed:" + result.getErrorMessage());
@@ -425,7 +438,7 @@ protected void updateVehicleMode() {
425438
// ==========================================================
426439

427440
protected void alertUser(String message) {
428-
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
441+
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
429442
Log.d(TAG, message);
430443
}
431444

0 commit comments

Comments
 (0)