Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for selecting bluetooth devices and pair them #561

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/app/i18n/locale-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,12 @@
"SIDEMENU": {
"ANALOG_INPUT": "Analoger Eingang",
"BLUETOOTH": "Bluetooth"
}
},
"BLUETOOTH": {
"AUDIO":"Audio Device",
"COMPUTER":"Computer",
"CONNECT":"Verbinden",
"DISCONNECT":"Trennen",
"SCAN":"Suchen"
}
}
14 changes: 14 additions & 0 deletions src/app/i18n/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@
"ANALOG_INPUT": "ANALOG INPUT",
"BLUETOOTH": "BLUETOOTH"
},
"BLUETOOTH": {
"AUDIO":"Audio Device",
"COMPUTER":"Computer",
"CONNECT":"Connect",
"DISCONNECT":"Disconnect",
"SCAN":"Scan"
},
"MYVOLUMIO": {
"MY_VOLUMIO": "MyVolumio (Beta)",
"ERROR": "Error",
Expand Down Expand Up @@ -363,5 +370,12 @@
"AUTO_SYNC": "Automatic Sync of Personal items",
"MYVOLUMIO_6_DEVICES": "Use MyVolumio on up to 6 devices",
"REMOTE_CONNECTION_6_DEVICES": "Remote connection to up to 6 devices"
},
"BLUETOOTH": {
"AUDIO":"Audio Device",
"COMPUTER":"Computer",
"CONNECT":"Connect",
"DISCONNECT":"Disconnect",
"REFRESH":"Refresh"
}
}
2 changes: 2 additions & 0 deletions src/app/index.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import MyVolumioPayingModalController from './components/myvolumio/modals/myvolu


//Core plugin controller
import BluetoothPluginController from './plugin/core-plugin/bluetooth-plugin.controller';
import WifiPluginController from './plugin/core-plugin/wifi-plugin.controller';
import NetworkStatusPluginController from './plugin/core-plugin/network-status-plugin.controller';
import MyMusicPluginController from './plugin/core-plugin/my-music-plugin.controller';
Expand Down Expand Up @@ -305,6 +306,7 @@ angular.module('volumio', [
.controller('ModalCryptoController', ModalCryptoController)
.controller('MyVolumioTermsModalController', MyVolumioTermsModalController)
.controller('MyVolumioPayingModalController', MyVolumioPayingModalController)
.controller('BluetoothPluginController', BluetoothPluginController)
.controller('WifiPluginController', WifiPluginController)
.controller('NetworkStatusPluginController', NetworkStatusPluginController)
.controller('MyMusicPluginController', MyMusicPluginController)
Expand Down
65 changes: 65 additions & 0 deletions src/app/plugin/core-plugin/bluetooth-plugin.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class BluetoothPluginController {
constructor($scope, socketService, mockService, $log, $translate, $interval) {
'ngInject';
this.socketService = socketService;
this.$scope = $scope;
this.$log = $log;
this.$translate = $translate;
this.$interval = $interval;
this.init();
}

init() {
this.registerListner();
this.initService();
}

startScan() {
this.socketService.emit('callMethod', {
"endpoint" : "audio_interface/bluetooth_controller",
"method" : "startScan",
"data" : {}
});
}

refreshBluetoothDevices() {
this.socketService.emit('callMethod', {
"endpoint" : "audio_interface/bluetooth_controller",
"method" : "getBluetoothDevices",
"data" : {}
});
}

registerListner() {
this.socketService.on('pushBluetoothDevices', (data) => {
this.$log.debug('pushBluetoothDevices', data);
this.bluetooth = data;
});
this.$scope.$on('$destroy', () => {
this.socketService.off('pushBluetoothDevices');
});
}

initService() {
this.startScan();
this.$interval( () => { this.refreshBluetoothDevices(); }, 5000);
}

connectDevice(mac) {
this.socketService.emit("callMethod", {
"endpoint" : "audio_interface/bluetooth_controller",
"method" : "connectBluetoothDevice",
"data" : {mac}
});
}

disconnectDevice(mac) {
this.socketService.emit("callMethod", {
"endpoint" : "audio_interface/bluetooth_controller",
"method" : "disconnectBluetoothDevice",
"data" : {mac}
});
}
}

export default BluetoothPluginController;
56 changes: 56 additions & 0 deletions src/app/plugin/core-plugin/bluetooth-plugin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<div
id="bluetoothPlugin"
ng-controller="BluetoothPluginController as bluetoothPlugin"
class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-bluetooth"></i> Bluetooth devices </h3>
</div>

<div class="panel-body">
<!-- <h4 ng-if="false" class="sectionDescription"></h4> -->
<table class="table">
<tr
ng-if="::bluetoothPlugin.bluetooth.devices.length > 0"
ng-repeat-start="device in bluetoothPlugin.bluetooth.devices track by $index">
<td class="bluetoothIcon">
<i ng-if="device.signal > 0" class="fa fa-signal" title="{{::device.signal}}"></i>
<i ng-if="device.signal == 0" class="fa fa-eye-slash" title="{{::device.signal}}"></i>
</td>
<td class="deviceIcon">
<span>
<i ng-if="device.icon === 'audio-card'" class="fa fa-headphones" title="{{'BLUETOOTH.AUDIO' | translate}}"></i>
<i ng-if="device.icon === 'computer'" class="fa fa-laptop" title="{{'BLUETOOTH.COMPUTER' | translate}}"></i>
</span>
</td>
<td>
<span>{{::device.name}} ({{::device.mac}})</span>
</td>
<td class="commandCol">
<button ng-if="device.connected === 'yes'"
type="button"
class="btn btn-info"
ng-click="bluetoothPlugin.disconnectDevice(device.mac)">
<i class="fa fa-unlink"></i>
<span class="hidden-xs" translate="BLUETOOTH.DISCONNECT"></span>
</button>
<button ng-if="device.connected !== 'yes'"
type="button"
class="btn btn-info"
ng-click="bluetoothPlugin.connectDevice(device.mac)">
<i class="fa fa-link"></i>
<span class="hidden-xs" translate="BLUETOOTH.CONNECT"></span>
</button>
</td>
</tr >

<tr ng-repeat-end>
</tr>
</table >


<button type="button" class="btn btn-info scanBluetoothDevices" ng-click="bluetoothPlugin.startScan()">
<i class="fa fa-refresh" title="{{'BLUETOOTH.SCAN' | translate}}"></i>
<span translate="BLUETOOTH.SCAN"></span>
</button>
</div>
</div>
54 changes: 54 additions & 0 deletions src/app/plugin/core-plugin/bluetooth-plugin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#bluetoothPlugin {
tr {
td{
border-top: 0 !important;
border-bottom: 1px solid #7C7C7C;
&.insertPasswordRow {
label {
margin-right: 10px;
}
input[type=checkbox] {
width: auto;
}
input[type=text], input[type=password] {
width: 140px;
display: inline-block;
margin-right: 10px;
}
text-align: center;
}
&.commandCol {
max-width: 210px;
text-align: right;
}
&.bluetoothIcon {
width: 36px;
text-align: center;
img {
width: 20px;
}
}
&.deviceIcon {
width: 30px;
text-align: center;
}
.securitySelectWrapper {
width: 120px;
display: inline-block;
margin-right: 15px;
position: relative;
.ui-select-choices {
position: absolute;
top: -22px;
left: 0;
}
}
.showHidePassword {
margin-right: 10px;
}
}
}
.refreshbluetoothNetworks {
margin-top: 15px;
}
}