From fd336ead89dc9173a18d80fb9727ffdb7699c0ab Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Fri, 5 Jun 2020 10:58:55 -0700 Subject: [PATCH] Modified Power events, to always send battery level --- agents/meshcore.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index 36920ef8..b35a45d9 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -255,13 +255,14 @@ function createMeshCore(agent) { { require('MeshAgent')._battLevelChanged = function _battLevelChanged(val) { + _battLevelChanged.self._currentBatteryLevel = 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') }); + _powerChanged.self.SendCommand({ action: 'battery', state: (val == 'AC' ? 'ac' : 'dc'), level: _powerChanged.self._currentBatteryLevel }); }; require('MeshAgent')._powerChanged.self = require('MeshAgent'); require('MeshAgent').on('Connected', function (status)