summaryrefslogtreecommitdiffstats
path: root/app/bluetooth/Bluetooth.qml
diff options
.highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */

ss='add'>+ btState = 'on' //bt is on
//search_device()
periodicRefresh.start()
@@ -70,7 +73,9 @@ SettingPage {
//showRequestInfo(o.responseText)
console.log(o.responseText)
})
+ buttonScan.text = "SEARCH" //when power off the button should be set to SEARCH
currentState = 'idle'
+ btState = 'off' //bt off
}
}
@@ -91,7 +96,7 @@ SettingPage {
id: buttonScan
anchors.centerIn: parent
width: 100
- text: "SEARCH"
+ text: "SEARCH" //default value is SEARCH
MouseArea {
//id: mouseArea
@@ -99,15 +104,18 @@ SettingPage {
onClicked: {
if (buttonScan.text == "SEARCH"){
- request(btAPIpath + 'start_discovery', function (o) {
+ if (btState == 'on'){ //only response to the requirement when bt is on
+ request(btAPIpath + 'start_discovery', function (o) {
// log the json response
//showRequestInfo(o.responseText)
console.log(o.responseText)
})
- buttonScan.text = "CANCEL"
- currentState = 'discovering'
- periodicRefresh.start()
+ buttonScan.text = "STOP"
+ currentState = 'discovering'
+ periodicRefresh.start()
+ }
+
}else{
request(btAPIpath + 'stop_discovery', function (o) {
@@ -140,127 +148,154 @@ SettingPage {
Component {
id:blueToothDevice
Rectangle {
- height: 150
+ height: 120
width: parent.width
- color: "#222"
-
- Column {
- Text {
- id: btName
- text: deviceName
- font.pointSize: 36
- color: "#ffffff"
- }
- Text {
- id: btAddr
- text: deviceAddress
- visible: false
- }
- Text {
- text: {
- if ((devicePairable === "True")
- && (deviceConnect === "False"))
- text = "paired"
- else if ((devicePairable === "True")
- && (deviceConnect === "True")
- && (connectAVP) === "True")
- text = "AV Connection"
- else if ((devicePairable === "True")
- && (deviceConnect === "True")
- && (connectHFP) === "True")
- text = "Handsfree Connection"
- else
- text = ""
- }
- font.pointSize: 18
- color: "#ffffff"
- font.italic: true
- }
- Text {
- id: btPairable
- text: devicePairable
- visible: false
- }
- Text {
- id: btConnectstatus
- text: deviceConnect
- visible: false
- }
-
- }
- Button {
- id: removeButton
- anchors.top:parent.top
- anchors.topMargin: 15
- anchors.right: parent.right
- text: "Unpair"
+ color: "transparent"
MouseArea {
- anchors.fill: parent
- onClicked: {
- request(btAPIpath + 'remove_device?value=' + btAddr.text, function (o) {
- console.log(o.responseText)
- })
- btDeviceList.remove(findDevice(btAddr.text))
- }
- }
+ anchors.fill: parent
+ Column {
+ anchors.left: parent.left
+ anchors.leftMargin: 80
+ Text {
+ id: btName
+ text: deviceName
+ color: '#66FF99'
+ font.pixelSize: 48
+ }
+// Text {
+// id: btAddr
+// text: deviceAddress
+// font.pixelSize: 24
+// color: 'white'
+// }
+ Text {
+ text: {
+ if ((devicePairable === "True")
+ && (deviceConnect === "False"))
+ text = "paired, "
+ else if ((devicePairable === "True")
+ && (deviceConnect === "True")
+ && (connectAVP === "True")
+ && (connectHFP === "False"))
+ text = "AV Connection, "
+ else if ((devicePairable === "True")
+ && (deviceConnect === "True")
+ && (connectHFP === "True")
+ && (connectAVP === "False"))
+ text = "Handsfree Connection, "
+ else if ((devicePairable === "True")
+ && (deviceConnect === "True")
+ && (connectHFP === "True")
+ && (connectAVP === "True"))
+ text = "Handsfree & AV Connection, "
+ else
+ text = ""
+ text = text + deviceAddress
+ }
+ font.pointSize: 18
+ color: "#ffffff"
+ font.italic: true
+ }
+ Text {
+ id: btPairable
+ text: devicePairable
+ visible: false
+ }
+ Text {
+ id: btConnectstatus
+ text: deviceConnect
+ visible: false
+ }
- }
-
- Button {
- id: connectButton
- anchors.top:parent.top
- anchors.topMargin: 15
- anchors.right: removeButton.left
- anchors.rightMargin: 10
-
- text:(btConnectstatus.text == "True")? "Disconnect":((btPairable.text == "True")? "Connect":"Pair")
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (currentState == 'discovering'){
- request(btAPIpath + 'stop_discovery', function (o) {
- currentState = "idle"
- console.log(o.responseText)
- })
- }
- if (connectButton.text == "Pair"){
- connectButton.text = "Connect"
- request(btAPIpath + 'pair?value=' + btAddr.text, function (o) {
- btPairable.text = "True"
- console.log(o.responseText)
- })
- request(btAPIpath + 'set_property?Address=' + btAddr.text + '\&Property=Trusted\&value=true', function (o) {
- console.log(o.responseText)
- })
}
- else if (connectButton.text == "Connect"){
- connectButton.text = "Disconnect"
- request(btAPIpath + 'connect?value=' + btAddr.text, function (o) {
- console.log(o.responseText)
- })
+ Button {
+ id: removeButton
+ anchors.top:parent.top
+ anchors.topMargin: 15
+ //anchors.horizontalCenter: btName.horizontalCenter
+ anchors.right: parent.right
+ anchors.rightMargin: 100
+
+ text: "Unpair"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ request(btAPIpath + 'remove_device?value=' + deviceAddress, function (o) {
+ console.log(o.responseText)
+ })
+ btDeviceList.remove(findDevice(deviceAddress))
+ }
+ }
+
}
- else if (connectButton.text == "Disconnect"){
- request(btAPIpath + 'disconnect?value=' + btAddr.text, function (o) {
- console.log(o.responseText)
- })
- connectButton.text = "Connect"
- btDeviceList.remove(findDevice(btAddr.text))
- }
- }
- }
+
+ Button {
+ id: connectButton
+ anchors.top:parent.top
+ anchors.topMargin: 15
+ //anchors.horizontalCenter: btName.horizontalCenter
+ anchors.right: removeButton.left
+ anchors.rightMargin: 10
+
+ text:((connectHFP === "True") || (connectAVP === "True"))? "Disconnect":((btPairable.text == "True")? "Connect":"Pair")
+ // only when HFP or AVP is connected, button will be shown as Disconnect
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (currentState == 'discovering'){
+ request(btAPIpath + 'stop_discovery', function (o) {
+ currentState = "idle"
+ console.log(o.responseText)
+ })
+ }
+ if (connectButton.text == "Pair"){
+ connectButton.text = "Connect"
+ request(btAPIpath + 'pair?value=' + deviceAddress, function (o) {
+ btPairable.text = "True"
+ console.log(o.responseText)
+ })
+ request(btAPIpath + 'set_property?Address=' + deviceAddress + '\&Property=Trusted\&value=true', function (o) {
+ console.log(o.responseText)
+ })
+ }
+ else if (connectButton.text == "Connect"){
+ connectButton.text = "Disconnect"
+ request(btAPIpath + 'connect?value=' + deviceAddress, function (o) {
+ console.log(o.responseText)
+ })
+ }
+ else if (connectButton.text == "Disconnect"){
+ request(btAPIpath + 'disconnect?value=' + deviceAddress, function (o) {
+ console.log(o.responseText)
+ })
+ connectButton.text = "Connect"
+ btDeviceList.remove(findDevice(deviceAddress))
+ }
+ }
+ }
+ }
+ }
+
+ Image {
+ source: '../images/HMI_Settings_DividingLine.svg'
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.top: parent.top
+ anchors.topMargin: -15
+
+ visible: model.index > 0
+ }
}
- }
}
ListView {
- width: parent.width
- anchors.top: parent.top
- anchors.topMargin: 200
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 150
- model: btDeviceList
- delegate: blueToothDevice
- clip: true
+ width: parent.width
+ anchors.top: parent.top
+ anchors.topMargin: 70
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 150
+ model: btDeviceList
+ delegate: blueToothDevice
+ clip: true
}
function findDevice(address){