Explorar o código

updates to www (#264)

* updated shared.cgi to read T20 firmware ver

* improvements and fixes

1. now composes urls for RTSP
2. css improvements
3. added diagnostics (got to test first hand with a corrupt file system SD card!)
4. fixed reboot not rebooting ...
5. remove debug code from jpeg.cgi
virmaior %!s(int64=3) %!d(string=hai) anos
pai
achega
da3ffcd467

+ 6 - 3
SD_ROOT/wz_mini/www/cgi-bin/config.cgi

@@ -16,6 +16,7 @@ echo ""
 reboot_camera()  {
     echo "rebooting camera (refreshing screen in 90 seconds)"
     echo '<script type="text/javascript">setTimeout(function(){ document.location.reload (); },90 * 1000)</script>'
+    reboot 
     exit
 }
 
@@ -210,7 +211,8 @@ handle_css wz_mini_web.css
 echo '<script type="text/javascript" src="/config.js" ></script>'
 echo -ne "</head>"
 
-echo -ne '<body>'
+
+echo -ne '<body ip="'$ipaddr'" mac="'$macaddr'"  >'
 echo -ne "<h1>$title</h1>";
 
 
@@ -242,9 +244,10 @@ while IFS= read -r ARGUMENT; do
 	      echo '</div>'
            fi
            CONFIG_BLOCK=$((CONFIG_BLOCK + 1))
-	   echo '<div class="ii_block" block_number="'$CONFIG_BLOCK'" >'
 	   BTITLE=${ARGUMENT//#/ }
-           echo -ne '<div class="ii_block_name">'$BTITLE'</div>'
+           BN=$(echo $BTITLE | tr -d ' ')
+           echo '<div class="ii_block" block_number="'$CONFIG_BLOCK'" block_name="'$BN'" >'
+           echo -ne '<div class="ii_block_name" >'$BTITLE'</div>'
 	else
             echo -ne '<div class="ii_info">'$ARGUMENT'</div>'
 	fi

+ 5 - 6
SD_ROOT/wz_mini/www/cgi-bin/config.css

@@ -57,10 +57,11 @@ H1 {
   z-index:10;
 }
 .ii_explain {
-   height:25px;
+   height:20px;
    overflow:hidden;
-   width:25px;
+   width:20px;
    position:relative;
+   color:transparent;
 }
 .ii_explain:hover {
     height: auto;
@@ -74,6 +75,7 @@ H1 {
     border: 3px solid blue;
     font-family: monospace;
     white-space:pre-wrap;
+    color:black;
 }
 .ii_explain:hover PRE {
  white-space:pre-wrap;
@@ -91,10 +93,7 @@ H1 {
  content:"?";
  text-align:center;
  background-color:blue;
- border:2px solid #ccc;
- border-radius:3px;
- padding-left:2px;
- padding-right:2px;
+ border-radius:50%;
  position:absolute;
  left:0;
  top:0;

+ 16 - 3
SD_ROOT/wz_mini/www/cgi-bin/diagnostics.cgi

@@ -15,8 +15,8 @@ echo -ne '</style>';
 
 dmesg_test()
 {
-x=$(dmesg | grep $1)
-if [-n "$x" ]; then
+x=$(dmesg | grep "$1")
+if [ -n "$x" ]; then
         echo "<div>$2 error found</div>"
 else    
         echo "<div>no $2 error</div>"
@@ -24,6 +24,18 @@ fi
 
 }
 
+logread_test()
+{
+x=$(logread | grep "$1")
+
+if [ -n "$x" ]; then
+        echo "<div>$2 error found</div>"
+else
+        echo "<div>no $2 error</div>"
+fi
+
+}
+
 echo "HTTP/1.1 200"
 echo -e "Content-type: text/html\n\n"
 echo ""
@@ -42,7 +54,8 @@ echo "<h2>SD Card Test</h2>"
 dmesg_test "invalid access to FAT" "SD card"
 dmesg_test "Filesystem has been set read-only" "SD read only"
 dmesg_test "fat_get_cluster: invalid cluster chain" "file system"
-
+logread_test "run: tf_prepare failed!" "SD card (tf_prepare)"
+logread_test "(health_test) fail" "SD card health fail"
 
 echo "<h2>Firmware Version Test</h2>"
 

+ 3 - 0
SD_ROOT/wz_mini/www/cgi-bin/shared.cgi

@@ -19,6 +19,9 @@ camver="$camtype($cammodel)"
 
 hackver=$(cat /opt/wz_mini/usr/bin/app.ver)
 
+ipaddr=$(ifconfig wlan0  | grep inet | cut -d ':' -f2 | cut -d ' ' -f0)
+macaddr=$(ifconfig wlan0  | grep HWaddr | cut -d 'HW' -f2 | cut -d ' ' -f2)
+
 function version_info
 {          
  echo "<div id='$1'>"

+ 40 - 0
SD_ROOT/wz_mini/www/config.js

@@ -18,6 +18,44 @@ window.scrollTo({
 }
 
 
+function compose_rtsp_block(stype)
+{
+  const formElement = document.querySelector("form");
+  var fdata = new FormData(formElement);
+
+  var stype = (typeof stype !== "undefined") ? stype: "RTSP_HI_RES";
+
+
+  if (fdata.get(stype + "_ENABLED") != "true") {
+ 	console.log(stype + " not enabled");
+    return false;
+  } 
+  
+  var auth = "";
+  if (fdata.get('RTSP_AUTH_DISABLE') != "true") {
+	auth = fdata.get('RTSP_LOGIN') + ':';
+	if (fdata.get('RTSP_PASSWORD') != '') {
+		auth += fdata.get('RTSP_PASSWORD');
+	} else {
+		auth += document.body.getAttribute('mac');
+	}
+	auth += "@";
+  } 
+
+  
+  stream = "/unicast";
+  if ((fdata.get('RTSP_HI_RES_ENABLED') == "true") && (fdata.get('RTSP_LOW_RES_ENABLED') == "true")) {
+	if (stype == "RTSP_HI") {  stream = "/video1_unicast"  } else { stream ="/video2_unicast" }
+  }
+
+  var link = "rtsp://" + auth + document.body.getAttribute("ip") + ":" + fdata.get('RTSP_PORT') + stream;  
+
+  var vb = document.querySelectorAll('[block_name="VIDEOSTREAM"]')[0];
+  var url_block = document.createElement('DIV');
+  url_block.innerHTML = 'Stream ' + stype + ' URL: ' + '<a href="' + link +  '">' + link +  '</a>' ;
+  vb.appendChild(url_block);
+}
+
 window.onload = function()
 {
 	var feed = document.getElementById("current_feed");
@@ -27,6 +65,8 @@ window.onload = function()
 	}
 	feed_interval = setInterval(update_image, feed_interval_frequency);
 	
+	compose_rtsp_block('RTSP_HI_RES');
+	compose_rtsp_block('RTSP_LOW_RES');
 
 	document.querySelector('[name="update_config"]').addEventListener('submit',
 	function(e){