summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2019-06-02 17:02:54 +0200
committerBjørn Mork <bjorn@mork.no>2019-06-02 17:02:54 +0200
commit09fe069ecef4f6b8906952ee7a3b7f0663ddd167 (patch)
treecad1ac363c02910ac1319b6857d954f8715e8327
parent6d0910308861d3f94a78c377835d322018b91d20 (diff)
add some pre-defined command buttons
Signed-off-by: Bjørn Mork <bjorn@mork.no>
-rw-r--r--Defogger/AndroidManifest.xml3
-rw-r--r--Defogger/res/layout/activity_ipcam.xml92
-rw-r--r--Defogger/res/values/strings.xml17
-rw-r--r--Defogger/src/no/mork/android/defogger/IpCamActivity.java65
4 files changed, 107 insertions, 70 deletions
diff --git a/Defogger/AndroidManifest.xml b/Defogger/AndroidManifest.xml
index eb67dda..074e909 100644
--- a/Defogger/AndroidManifest.xml
+++ b/Defogger/AndroidManifest.xml
@@ -30,7 +30,8 @@
<activity
a:name=".IpCamActivity"
- a:parentActivityName=".MainActivity" />
+ a:parentActivityName=".MainActivity"
+ a:windowSoftInputMode="stateHidden|adjustResize" />
</application>
diff --git a/Defogger/res/layout/activity_ipcam.xml b/Defogger/res/layout/activity_ipcam.xml
index 6101187..faa8226 100644
--- a/Defogger/res/layout/activity_ipcam.xml
+++ b/Defogger/res/layout/activity_ipcam.xml
@@ -9,62 +9,69 @@
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
+
<Button
- android:id="@+id/wificonfig"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:onClick="getWifiConfig"
- android:text="@string/wificonfig"/>
- <Button
- android:id="@+id/ipconfig"
+ android:id="@+id/sysinfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:onClick="getIpConfig"
- android:text="@string/ipconfig"/>
- <TextView
- android:id="@+id/ipaddress"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/netmask"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/gateway"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:onClick="getSysInfo"
+ android:text="@string/sysinfo"/>
<TextView
- android:id="@+id/dns"
+ android:id="@+id/sysstatus"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:layout_height="wrap_content"
+ android:inputType="textMultiLine"/>
<Button
- android:id="@+id/sysinfo"
+ android:id="@+id/wificonfig"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:onClick="getSysInfo"
- android:text="@string/sysinfo"/>
- <TextView
- android:id="@+id/sysname"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
- <TextView
- android:id="@+id/systime"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:onClick="getWifiConfig"
+ android:text="@string/wificonfig"/>
+
<TextView
- android:id="@+id/version"
+ android:id="@+id/wifistatus"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:layout_height="wrap_content"
+ android:inputType="textMultiLine"/>
+
<TextView
- android:id="@+id/macaddress"
+ android:id="@+id/ipstatus"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
+ android:layout_height="wrap_content"
+ android:inputType="textMultiLine"/>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/command" />
+ <Button
+ android:id="@+id/rtsp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="doRtsp"
+ android:text="@string/rtsp"/>
+ <Button
+ android:id="@+id/telnetd"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="doTelnet"
+ android:text="@string/telnetd"/>
+ <Button
+ android:id="@+id/lighttpd"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="doHttp"
+ android:text="@string/lighttpd"/>
+ <Button
+ android:id="@+id/unsignedfw"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="doUnsignedFW"
+ android:text="@string/unsignedfw"/>
+
+ <Button
+ android:id="@+id/runbutton"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="doCommand"
+ android:text="@string/command"/>
<EditText
android:id="@+id/command"
@@ -80,6 +87,7 @@
android:layout_height="wrap_content"
android:onClick="getWifiLink"
android:text="@string/setup"/>
+
<ListView
android:id="@+id/networks"
android:layout_width="wrap_content"
diff --git a/Defogger/res/values/strings.xml b/Defogger/res/values/strings.xml
index 7fd8df3..88502ab 100644
--- a/Defogger/res/values/strings.xml
+++ b/Defogger/res/values/strings.xml
@@ -6,13 +6,16 @@
<!-- Main -->
- <string name="start_scan">Scan for camera</string>
- <string name="read_qrcode">Scan QR Code</string>
- <string name="wificonfig">Show WiFi configuration</string>
- <string name="ipconfig">Show IP configuration</string>
- <string name="sysinfo">Get system information</string>
- <string name="setup">Setup WiFi network</string>
- <string name="command">Run command:</string>
+ <string name="start_scan">Run Bluetooth Scan</string>
+ <string name="read_qrcode">Read QR Code</string>
+ <string name="wificonfig">Network configuration</string>
+ <string name="sysinfo">System information</string>
+ <string name="setup">Configure network</string>
+ <string name="telnetd">Enable telnet (volatile)</string>
+ <string name="lighttpd">Enable http API (volatile)</string>
+ <string name="rtsp">Enable rtsp (permanent)</string>
+ <string name="unsignedfw">Enable unsigned firmware (permanent)</string>
+ <string name="command">Run command</string>
<!-- Scanner -->
diff --git a/Defogger/src/no/mork/android/defogger/IpCamActivity.java b/Defogger/src/no/mork/android/defogger/IpCamActivity.java
index 60ff2c6..436310a 100644
--- a/Defogger/src/no/mork/android/defogger/IpCamActivity.java
+++ b/Defogger/src/no/mork/android/defogger/IpCamActivity.java
@@ -78,6 +78,7 @@ public class IpCamActivity extends Activity {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
runCommand(v.getText().toString());
+ v.setText("");
return true;
}
return false;
@@ -225,7 +226,7 @@ public class IpCamActivity extends Activity {
setStatus("Unlocking failed - Wrong PIN Code?");
break;
default:
- Log.d(msg, "No action defined after " + c.getUuid().toString());
+ Log.d(msg, "No action defined after writing " + c.getUuid().toString());
}
runQueues();
}
@@ -253,8 +254,11 @@ public class IpCamActivity extends Activity {
runOnUiThread(new Runnable() {
@Override
public void run() {
- // TextView status = (TextView) findViewById(R.id.statustext);
- //status.setText(text);
+ TextView t = (TextView) findViewById(R.id.wifistatus);
+ if (kv.get("I").length() > 0)
+ t.setText((wifilink ? "Connected" : "Not connected") + " to '" + kv.get("I") + "' with M=" + kv.get("M") + ", S=" + kv.get("S") + ", E=" + kv.get("E"));
+ else
+ t.setText("WiFi connection is unconfigured");
}
});
}
@@ -264,14 +268,11 @@ public class IpCamActivity extends Activity {
runOnUiThread(new Runnable() {
@Override
public void run() {
- TextView t = (TextView) findViewById(R.id.ipaddress);
- t.setText(kv.get("I"));
- t = (TextView) findViewById(R.id.netmask);
- t.setText(kv.get("N"));
- t = (TextView)findViewById(R.id.gateway);
- t.setText(kv.get("G"));
- t = (TextView)findViewById(R.id.dns);
- t.setText(kv.get("D"));
+ TextView t = (TextView) findViewById(R.id.ipstatus);
+ if (wifilink && kv.get("I").length() > 0)
+ t.setText("IP Address: " + kv.get("I") + "\nNetmask: " + kv.get("N") + "\nGateway: " + kv.get("G") + "\nDNS: " + kv.get("D"));
+ else
+ t.setText("No IP Configured");
}
});
}
@@ -283,14 +284,9 @@ public class IpCamActivity extends Activity {
runOnUiThread(new Runnable() {
@Override
public void run() {
- TextView t = (TextView) findViewById(R.id.sysname);
- t.setText(kv.get("N"));
- t = (TextView) findViewById(R.id.systime);
- t.setText(dateFormat.format(new Date(1000 * Integer.parseInt(kv.get("T"))))); // milliseconds....
- t = (TextView)findViewById(R.id.version);
- t.setText("FW Ver: " + kv.get("F") + ", HW Ver: " + kv.get("H") + ", MyDlink Ver: " + kv.get("V"));
- t = (TextView)findViewById(R.id.macaddress);
- t.setText(kv.get("M"));
+ TextView t = (TextView) findViewById(R.id.sysstatus);
+ t.setText("Name: " + kv.get("N") + "\nTime: " + kv.get("T") + "\nFW Ver: " + kv.get("F") + "\nHW Ver: " + kv.get("H") + "\nMyDlink Ver: " + kv.get("V") + "\nMac: " + kv.get("M"));
+ // t.setText(dateFormat.format(new Date(1000 * Integer.parseInt(kv.get("T"))))); // milliseconds....
}
});
}
@@ -393,8 +389,8 @@ public class IpCamActivity extends Activity {
/* collect current config after unlocking */
View v = new View(this);
- getWifiConfig(v);
getWifiLink(v);
+ getWifiConfig(v);
getIpConfig(v);
getSysInfo(v);
doWifiScan(v);
@@ -487,6 +483,34 @@ public class IpCamActivity extends Activity {
readChar(0xa200);
}
+ public void doCommand(View view) {
+ EditText cmd = (EditText) findViewById(R.id.command);
+ runCommand(cmd.getText().toString());
+ cmd.setText("");
+ }
+
+ public void doRtsp(View view) {
+ runCommand("[ \"$(tdb get RTPServer RejectExtIP_byte)\" -eq \"0\" ]||tdb set RTPServer RejectExtIP_byte=0");
+ runCommand("[ \"$(tdb get RTPServer Authenticate_byte)\" -eq \"1\" ]||tdb set RTPServer Authenticate_byte=1");
+ runCommand("/etc/rc.d/init.d/firewall.sh reload&&/etc/rc.d/init.d/rtspd.sh restart");
+ }
+
+ public void doTelnet(View view) {
+ runCommand("grep -Eq ^admin: /etc/passwd||echo admin:x:0:0::/:/bin/sh >>/etc/passwd");
+ runCommand("grep -Eq ^admin:x: /etc/passwd&&echo admin:" + pincode + "|chpasswd");
+ runCommand("pidof telnetd||telnetd");
+ }
+
+ public void doHttp(View view) {
+ runCommand("[ \"$(tdb get HTTPServer Enable_byte)\" -eq \"1\" ]||tdb set HTTPServer Enable_byte=1");
+ runCommand("/etc/rc.d/init.d/extra_lighttpd.sh start");
+ }
+
+ public void doUnsignedFW(View view) {
+ runCommand("tdb set SecureFW _TrustLevel_byte=0");
+ }
+
+
/*
private void setWifi(String essid, String passwd) {
if (wifiScanResults == null) {
@@ -503,6 +527,7 @@ public class IpCamActivity extends Activity {
}
private void runCommand(String command) {
+ setStatus("Running '" + command + "' on camera...");
writeChar(0xa201, "P=" + pincode + ";N=" + pincode + "&&(" + command + ")&");
}
}