Added device battery indication
This commit is contained in:
parent
db77db4222
commit
89e82edc28
|
@ -2176,6 +2176,16 @@ function createMeshCore(agent) {
|
||||||
response = "Available commands: \r\n" + fin + ".";
|
response = "Available commands: \r\n" + fin + ".";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'setbattery':
|
||||||
|
// require('MeshAgent').SendCommand({ action: 'battery', state: 'dc', level: 55 });
|
||||||
|
if ((args['_'].length > 0) && ((args['_'][0] == 'ac') || (args['_'][0] == 'dc'))) {
|
||||||
|
var b = { action: 'battery', state: args['_'][0] };
|
||||||
|
if (args['_'].length == 2) { b.level = parseInt(args['_'][1]); }
|
||||||
|
require('MeshAgent').SendCommand(b);
|
||||||
|
} else {
|
||||||
|
require('MeshAgent').SendCommand({ action: 'battery' });
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'fdsnapshot':
|
case 'fdsnapshot':
|
||||||
require('ChainViewer').getSnapshot().then(function (c) { sendConsoleText(c, this.sessionid); }).parentPromise.sessionid = sessionid;
|
require('ChainViewer').getSnapshot().then(function (c) { sendConsoleText(c, this.sessionid); }).parentPromise.sessionid = sessionid;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -27,7 +27,6 @@ function amt_heci() {
|
||||||
this._setupPTHI = function _setupPTHI()
|
this._setupPTHI = function _setupPTHI()
|
||||||
{
|
{
|
||||||
this._amt = heci.create();
|
this._amt = heci.create();
|
||||||
this._amt.descriptorMetadata = "amt-pthi";
|
|
||||||
this._amt.BiosVersionLen = 65;
|
this._amt.BiosVersionLen = 65;
|
||||||
this._amt.UnicodeStringLen = 20;
|
this._amt.UnicodeStringLen = 20;
|
||||||
|
|
||||||
|
@ -398,25 +397,20 @@ function amt_heci() {
|
||||||
fn.apply(this, opt);
|
fn.apply(this, opt);
|
||||||
}, callback, optional);
|
}, callback, optional);
|
||||||
}
|
}
|
||||||
this.getProtocolVersion = function getProtocolVersion(callback)
|
this.getProtocolVersion = function getProtocolVersion(callback) {
|
||||||
{
|
|
||||||
var optional = [];
|
var optional = [];
|
||||||
for (var i = 1; i < arguments.length; ++i) { opt.push(arguments[i]); }
|
for (var i = 1; i < arguments.length; ++i) { opt.push(arguments[i]); }
|
||||||
|
|
||||||
if (!this._tmpSession) { this._tmpSession = heci.create(); this._tmpSession.parent = this;}
|
heci.doIoctl(heci.IOCTL.HECI_VERSION, Buffer.alloc(5), Buffer.alloc(5), function (status, buffer, self, fn, opt) {
|
||||||
this._tmpSession.doIoctl(heci.IOCTL.HECI_VERSION, Buffer.alloc(5), Buffer.alloc(5), function (status, buffer, self, fn, opt)
|
|
||||||
{
|
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
var result = buffer.readUInt8(0).toString() + '.' + buffer.readUInt8(1).toString() + '.' + buffer.readUInt8(2).toString() + '.' + buffer.readUInt16BE(3).toString();
|
var result = buffer.readUInt8(0).toString() + '.' + buffer.readUInt8(1).toString() + '.' + buffer.readUInt8(2).toString() + '.' + buffer.readUInt16BE(3).toString();
|
||||||
opt.unshift(result);
|
opt.unshift(result);
|
||||||
fn.apply(self, opt);
|
fn.apply(self, opt);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
opt.unshift(null);
|
opt.unshift(null);
|
||||||
fn.apply(self, opt);
|
fn.apply(self, opt);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, this, callback, optional);
|
}, this, callback, optional);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1351,6 +1351,15 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||||
obj.updateSessions();
|
obj.updateSessions();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'battery': {
|
||||||
|
// Device battery and power state
|
||||||
|
if (obj.sessions == null) { obj.sessions = {}; }
|
||||||
|
if (obj.sessions.battery == null) { obj.sessions.battery = {}; }
|
||||||
|
if ((command.state == 'ac') || (command.state == 'dc')) { obj.sessions.battery.state = command.state; } else { delete obj.sessions.battery.state; }
|
||||||
|
if ((typeof command.level == 'number') && (command.level >= 0) && (command.level <= 100)) { obj.sessions.battery.level = command.level; } else { delete obj.sessions.battery.level; }
|
||||||
|
obj.updateSessions();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'plugin': {
|
case 'plugin': {
|
||||||
if ((parent.parent.pluginHandler == null) || (typeof command.plugin != 'string')) break;
|
if ((parent.parent.pluginHandler == null) || (typeof command.plugin != 'string')) break;
|
||||||
try {
|
try {
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
|
@ -784,6 +784,23 @@ NoMeshesPanel img {
|
||||||
background-color:#44F;
|
background-color:#44F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.deviceBatteryLarge {
|
||||||
|
position:absolute;
|
||||||
|
left:10px;
|
||||||
|
top:140px;
|
||||||
|
width:28px;
|
||||||
|
height:48px;
|
||||||
|
border:none;
|
||||||
|
box-shadow:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deviceBatteryLarge1 { background: url(../images/batteries48.png) 0px 0px; }
|
||||||
|
.deviceBatteryLarge2 { background: url(../images/batteries48.png) -28px 0px; }
|
||||||
|
.deviceBatteryLarge3 { background: url(../images/batteries48.png) -56px 0px; }
|
||||||
|
.deviceBatteryLarge4 { background: url(../images/batteries48.png) -84px 0px; }
|
||||||
|
.deviceBatteryLarge5 { background: url(../images/batteries48.png) -112px 0px; }
|
||||||
|
.deviceBatteryLarge6 { background: url(../images/batteries48.png) -140px 0px; }
|
||||||
|
|
||||||
.deviceNotifyLargeDot {
|
.deviceNotifyLargeDot {
|
||||||
text-align:center;
|
text-align:center;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -488,6 +488,7 @@
|
||||||
<td style=width:20px></td>
|
<td style=width:20px></td>
|
||||||
<td style=width:200px;vertical-align:top;position:relative valign=top>
|
<td style=width:200px;vertical-align:top;position:relative valign=top>
|
||||||
<img id="p10deviceNotify" onclick=showDeviceSessions(null,null,event) class=deviceNotifyLargeDot src=images/icon-relay-notify-40.png width=40 height=40>
|
<img id="p10deviceNotify" onclick=showDeviceSessions(null,null,event) class=deviceNotifyLargeDot src=images/icon-relay-notify-40.png width=40 height=40>
|
||||||
|
<div id="p10deviceBattery" class="deviceBatteryLarge deviceBatteryLarge1"></div>
|
||||||
<a href=# onclick=p10showiconselector()><img id=MainComputerImage></a>
|
<a href=# onclick=p10showiconselector()><img id=MainComputerImage></a>
|
||||||
<div id=MainComputerState></div>
|
<div id=MainComputerState></div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -2646,8 +2647,8 @@
|
||||||
node.pwr = message.event.pwr;
|
node.pwr = message.event.pwr;
|
||||||
node.lastconnect = Date.now();
|
node.lastconnect = Date.now();
|
||||||
|
|
||||||
// Clear sesssion information if needed
|
// Clear sesssion and battery information if needed
|
||||||
if ((node.conn & 1) == 0) { delete node.sessions; }
|
if ((node.conn & 1) == 0) { delete node.sessions; delete node.battery; }
|
||||||
|
|
||||||
// Web page update
|
// Web page update
|
||||||
masterUpdate(1 | 4 | 16);
|
masterUpdate(1 | 4 | 16);
|
||||||
|
@ -5007,7 +5008,31 @@
|
||||||
currentNode = node;
|
currentNode = node;
|
||||||
|
|
||||||
// Device Notification
|
// Device Notification
|
||||||
QV('p10deviceNotify', currentNode.sessions != null);
|
QV('p10deviceNotify', (currentNode.sessions != null) && ((currentNode.sessions.kvm != null) || (currentNode.sessions.terminal != null) || (currentNode.sessions.files != null)));
|
||||||
|
|
||||||
|
// Device Battery
|
||||||
|
QV('p10deviceBattery', false);
|
||||||
|
if ((currentNode.sessions != null) && (currentNode.sessions.battery != null)) {
|
||||||
|
var bat = currentNode.sessions.battery;
|
||||||
|
if (bat.state == 'ac') {
|
||||||
|
QV('p10deviceBattery', true);
|
||||||
|
Q('p10deviceBattery').className = 'deviceBatteryLarge deviceBatteryLarge6';
|
||||||
|
Q('p10deviceBattery').title = "Device is plugged-in";
|
||||||
|
} else {
|
||||||
|
Q('p10deviceBattery').title = format("Device is battery powered, {0}%", bat.level);
|
||||||
|
if ((typeof bat.level == 'number') && (bat.level >= 0) && (bat.level <= 100)) {
|
||||||
|
QV('p10deviceBattery', true);
|
||||||
|
var lvl = (Math.floor((bat.level + 10) / 25) + 1);
|
||||||
|
if (lvl > 5) { lvl = 5; }
|
||||||
|
Q('p10deviceBattery').className = 'deviceBatteryLarge deviceBatteryLarge' + lvl;
|
||||||
|
} else {
|
||||||
|
QV('p10deviceBattery', true);
|
||||||
|
Q('p10deviceBattery').className = 'deviceBatteryLarge deviceBatteryLarge5';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QV('p10deviceBattery', false);
|
||||||
|
}
|
||||||
|
|
||||||
// Add node name
|
// Add node name
|
||||||
var nname = EscapeHtml(node.name), nnameEx;
|
var nname = EscapeHtml(node.name), nnameEx;
|
||||||
|
|
Loading…
Reference in New Issue