Hooked up power events
This commit is contained in:
parent
1736269b3f
commit
c7e95dadc3
|
@ -251,6 +251,35 @@ function createMeshCore(agent) {
|
|||
return (svc);
|
||||
}
|
||||
|
||||
if (require('identifiers').isBatteryPowered && require('identifiers').isBatteryPowered())
|
||||
{
|
||||
require('MeshAgent')._battLevelChanged = function _battLevelChanged(val)
|
||||
{
|
||||
_battLevelChanged.self.SendCommand({ action: 'battery', state: _battLevelChanged.self._currentPowerState, level: val });
|
||||
};
|
||||
require('MeshAgent')._battLevelChanged.self = require('MeshAgent');
|
||||
require('MeshAgent')._powerChanged = function _powerChanged(val)
|
||||
{
|
||||
_powerChanged.self._currentPowerState = (val == 'AC' ? 'ac' : 'dc');
|
||||
_powerChanged.self.SendCommand({ action: 'battery', state: (val == 'AC' ? 'ac' : 'dc') });
|
||||
};
|
||||
require('MeshAgent')._powerChanged.self = require('MeshAgent');
|
||||
require('MeshAgent').on('Connected', function (status)
|
||||
{
|
||||
if (status == 0)
|
||||
{
|
||||
require('power-monitor').removeListener('acdc', this._powerChanged);
|
||||
require('power-monitor').removeListener('batteryLevel', this._battLevelChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
require('power-monitor').on('acdc', this._powerChanged);
|
||||
require('power-monitor').on('batteryLevel', this._battLevelChanged);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
function borderController() {
|
||||
this.container = null;
|
||||
|
|
Loading…
Reference in New Issue