Skip to content

Commit

Permalink
bugfix: video and lock status mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
isra67 committed Oct 2, 2017
1 parent f122da5 commit 20321c0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
11 changes: 8 additions & 3 deletions public/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,14 @@ app.controller('mainCtrl', function ($scope, $rootScope, $location, services) {
$scope.sdinfo = d.sdcard;
for (var i = 0; i < d.lockFlag.length; i++) {
if (d.lockFlag[i] != undefined) {
var l1 = Number('0x'+d.lockFlag[i]) & 0x0f, l2 = (Number('0x'+d.lockFlag[i]) >> 4) & 0x0f;
$scope.lockFlag[i] = l1 ? 'U' : 'L';
$scope.lockFlag[i] = $scope.lockFlag[i] + (l2 ? 'U' : 'L');
var lf = Number('0x'+d.lockFlag[i]);
if (lf == 0x55) { // unknown device address or error
$scope.lockFlag[i] = '..';
} else {
var l1 = lf & 0x0f, l2 = (lf >> 4) & 0x0f;
$scope.lockFlag[i] = l1 ? 'U' : 'L';
$scope.lockFlag[i] = $scope.lockFlag[i] + (l2 ? 'U' : 'L');
}
} else {
$scope.lockFlag[i] = '..';
}
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

<script>

var buildVersionNumber = "1.1";
var buildVersionNumber = "1.2";

$(function() {
highlightMenuItem();
Expand Down
2 changes: 1 addition & 1 deletion public/storage/store.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"user":{"name":"admin","p4ssw0rd":"1234"},"system":{"rpi":"0000000085a5ba7f","indoorver":"2.0.0.2"}}
{"user":{"name":"admin","p4ssw0rd":"1234"},"system":{"rpi":"0000000085a5ba7f","indoorver":"2.0.0.3"}}
24 changes: 10 additions & 14 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var express = require('express')
, MUSIC_DIR = SOUNDS + 'ring_'
, sockets = -1

, serverAppVersionString = '1.0.0.1'
, serverAppVersionString = '1.0.0.2'
, appStatusStruct = {}

, webClients = [];
Expand All @@ -48,31 +48,25 @@ function iniStatStruct() {
appStatusStruct.serverVer = serverAppVersionString;
appStatusStruct.indoorVer = store.get('system.indoorver');
appStatusStruct.rpiSN = store.get('system.rpi');
appStatusStruct.lockFlag = ['?','?','?','?'];
appStatusStruct.videoFlag = [];
appStatusStruct.videoFlag = ['?','?','?','?'];
appStatusStruct.lockFlag = [0x55,0x55,0x55,0x55];
appStatusStruct.sdcard = '?';
appStatusStruct.uptime = '?';

exec_process.result('df -h | grep /dev/root | awk \'{printf "%s / %s", $2, $4}\'',
function(err,res1){
// console.log('res1:',res1);
appStatusStruct.sdcard = res1;
/* var sdinfo = res1.toString().split(' ');
try {
appStatusStruct.sdcard = sdinfo[1] + ' / ' + sdinfo[3];
} catch(e) {
appStatusStruct.sdcard = res1;
}//*/
});

exec_process.result('uptime -p',
function(err,a){
// console.log(a);
var ut = a.toString().split(', ');
try {
appStatusStruct.uptime = ut[0] + ', ' + ut[1];
appStatusStruct.uptime = ut.length > 1 ? ut[0] + ', ' + ut[1] : a;
} catch(e) {
appStatusStruct.uptime = a;
appStatusStruct.uptime = a;
}
});

Expand Down Expand Up @@ -262,6 +256,8 @@ app.post('/app/auth', function(req, res) {
//app.get('/app/auth/:usr/:pwd', function(req, res) {
var ret = 'Err', usr = req.body.usr, pwd = req.body.pwd, a, k, o;

iniStatStruct();

a = store.get('user');

if (a === undefined || a.name === undefined || a.p4ssw0rd === undefined) {
Expand Down Expand Up @@ -409,14 +405,14 @@ var socketServer = net.createServer(function(c) {
if (appStatusStruct.lockFlag.length > appStatusStruct.videoFlag.length)
appStatusStruct.lockFlag.length = appStatusStruct.videoFlag.length;
} else if (k === 'LOCK') {
appStatusStruct.lockFlag = appStatusStruct.videoFlag;
// appStatusStruct.lockFlag = appStatusStruct.videoFlag;
for (var kk in struct[k]) {
if (struct[k].hasOwnProperty(kk)) {
appStatusStruct.lockFlag[Number(kk)] = struct[k][kk];
}
}
// if (appStatusStruct.lockFlag.length > appStatusStruct.videoFlag.length)
// appStatusStruct.lockFlag.length = appStatusStruct.videoFlag.length;
if (appStatusStruct.lockFlag.length > appStatusStruct.videoFlag.length)
appStatusStruct.lockFlag.length = appStatusStruct.videoFlag.length;
} else if (k === 'INDOORVER') appStatusStruct.indoorVer = struct[k];
else if (k === 'RPISN') appStatusStruct.rpiSN = struct[k];
else if (k === 'MACADDR') appStatusStruct.macaddr = struct[k];
Expand Down
2 changes: 0 additions & 2 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,3 @@ cp -f /root/tmp/store.dat public/storage
## install NPM files
npm install --silent

## save from cache
#sync

0 comments on commit 20321c0

Please sign in to comment.