mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
Allow selecting the IP address from the preferences
This commit is contained in:
parent
65861b4b8d
commit
45f4ae0701
@ -10,6 +10,6 @@
|
|||||||
<EditTextPreference android:name="ip_address"
|
<EditTextPreference android:name="ip_address"
|
||||||
android:summary="Enter a TCP/IP address here"
|
android:summary="Enter a TCP/IP address here"
|
||||||
android:defaultValue="192.168.0.1" android:title="IP address:"
|
android:defaultValue="192.168.0.1" android:title="IP address:"
|
||||||
android:key="editTextPref" />
|
android:key="ip_address" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -8,6 +8,8 @@ import org.openpilot.uavtalk.UAVObjectManager;
|
|||||||
import org.openpilot.uavtalk.UAVTalk;
|
import org.openpilot.uavtalk.UAVTalk;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class TcpUAVTalk {
|
public class TcpUAVTalk {
|
||||||
@ -17,14 +19,17 @@ public class TcpUAVTalk {
|
|||||||
public static boolean DEBUG = LOGLEVEL > 0;
|
public static boolean DEBUG = LOGLEVEL > 0;
|
||||||
|
|
||||||
// Temporarily define fixed device name
|
// Temporarily define fixed device name
|
||||||
public final static String IP_ADDRESS = "10.21.18.120";
|
private String ip_address = "1";
|
||||||
public final static int PORT = 9001;
|
public final static int PORT = 9001;
|
||||||
|
|
||||||
private UAVTalk uavTalk;
|
private UAVTalk uavTalk;
|
||||||
private boolean connected;
|
private boolean connected;
|
||||||
|
|
||||||
public TcpUAVTalk(Context caller) {
|
public TcpUAVTalk(Context caller) {
|
||||||
if (DEBUG) Log.d(TAG, "Trying to open UAVTalk with " + IP_ADDRESS);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(caller);
|
||||||
|
ip_address = prefs.getString("ip_address","127.0.0.1");
|
||||||
|
|
||||||
|
if (DEBUG) Log.d(TAG, "Trying to open UAVTalk with " + ip_address);
|
||||||
|
|
||||||
connected = false;
|
connected = false;
|
||||||
}
|
}
|
||||||
@ -47,11 +52,11 @@ public class TcpUAVTalk {
|
|||||||
|
|
||||||
|
|
||||||
private boolean openTelemetryTcp(UAVObjectManager objMngr) {
|
private boolean openTelemetryTcp(UAVObjectManager objMngr) {
|
||||||
Log.d(TAG, "Opening conncetion to " + IP_ADDRESS + " at address " + PORT);
|
Log.d(TAG, "Opening connection to " + ip_address + " at address " + PORT);
|
||||||
|
|
||||||
InetAddress serverAddr = null;
|
InetAddress serverAddr = null;
|
||||||
try {
|
try {
|
||||||
serverAddr = InetAddress.getByName(IP_ADDRESS);
|
serverAddr = InetAddress.getByName(ip_address);
|
||||||
} catch (UnknownHostException e1) {
|
} catch (UnknownHostException e1) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user