Implement enable/disable bluetooth of device (#754)

Signed-off-by: Jussi Vatjus-Anttila <jussiva@gmail.com>
This commit is contained in:
Jussi Vatjus-Anttila
2024-01-29 13:06:57 +02:00
committed by GitHub
parent 63ad4f138e
commit e958a599cb
8 changed files with 163 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
module.exports = function DeviceSettingsCtrl($scope, $timeout) {
$scope.wifiEnabled = true
$scope.bluetoothEnabled = true
$scope.bluetoothPending = false
function getWifiStatus() {
if ($scope.control) {
@@ -19,6 +21,35 @@ module.exports = function DeviceSettingsCtrl($scope, $timeout) {
}
}
function getBluetoothStatus() {
if ($scope.control) {
$scope.bluetoothPending = true
$scope.control.getBluetoothStatus()
.then(function(result) {
$scope.$apply(function() {
$scope.bluetoothEnabled = (result.lastData === 'bluetooth_enabled')
})
})
.finally(function() {
$scope.bluetoothPending = false
})
}
}
getBluetoothStatus()
$scope.toggleBluetooth = function(enable) {
if ($scope.control) {
$scope.bluetoothPending = true
$scope.control.setBluetoothEnabled(enable)
.then(function() {
$scope.bluetoothEnabled = enable
})
.finally(function() {
$scope.bluetoothPending = false
})
}
}
$scope.$watch('ringerMode', function(newValue, oldValue) {
if (oldValue) {
if ($scope.control) {