summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-04-20 15:09:24 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-04-21 22:45:52 -0700
commit8e97722e96916a8a2f444645bac4a6ea5434c262 (patch)
tree3c5ec672471b4220ddf6da1c3e13a25ec1b75ae0
parentad867a98c184bb884f2f540f6588e8775fbe9fc4 (diff)
libqtappfw: bluetooth: add initial avrcp controls
To allow the Mediaplayer application to control avrcp there needs to be a callable set_avrcp_controls() function Bug-AGL: SPEC-1385 Change-Id: I10d9cbaca5688548b8fb174754c19874e2357fab Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--bluetooth.cpp22
-rw-r--r--bluetooth.h4
2 files changed, 26 insertions, 0 deletions
diff --git a/bluetooth.cpp b/bluetooth.cpp
index 377139c..3af6ac3 100644
--- a/bluetooth.cpp
+++ b/bluetooth.cpp
@@ -27,6 +27,9 @@ Bluetooth::Bluetooth (QUrl &url, QObject * parent) :
QObject::connect(m_mloop, &MessageEngine::connected, this, &Bluetooth::onConnected);
QObject::connect(m_mloop, &MessageEngine::disconnected, this, &Bluetooth::onDisconnected);
QObject::connect(m_mloop, &MessageEngine::messageReceived, this, &Bluetooth::onMessageReceived);
+
+ uuids.insert("a2dp", "0000110a-0000-1000-8000-00805f9b34fb");
+ uuids.insert("avrcp", "0000110e-0000-1000-8000-00805f9b34fb");
}
Bluetooth::~Bluetooth()
@@ -109,6 +112,8 @@ void Bluetooth::connect(QString address, QString uuid)
BluetoothMessage *tmsg = new BluetoothMessage();
QJsonObject parameter;
+ uuid = process_uuid(uuid);
+
parameter.insert("value", address);
parameter.insert("uuid", uuid);
tmsg->createRequest("connect", parameter);
@@ -126,6 +131,8 @@ void Bluetooth::disconnect(QString address, QString uuid)
BluetoothMessage *tmsg = new BluetoothMessage();
QJsonObject parameter;
+ uuid = process_uuid(uuid);
+
parameter.insert("value", address);
parameter.insert("uuid", uuid);
tmsg->createRequest("disconnect", parameter);
@@ -143,6 +150,18 @@ void Bluetooth::send_confirmation()
generic_command("send_confirmation", "yes");
}
+void Bluetooth::set_avrcp_controls(QString address, QString cmd)
+{
+ BluetoothMessage *tmsg = new BluetoothMessage();
+ QJsonObject parameter;
+
+ parameter.insert("Address", address);
+ parameter.insert("value", cmd);
+ tmsg->createRequest("set_avrcp_controls", parameter);
+ m_mloop->sendMessage(tmsg);
+ tmsg->deleteLater();
+}
+
void Bluetooth::onConnected()
{
QStringListIterator eventIterator(events);
@@ -159,6 +178,9 @@ void Bluetooth::onConnected()
// get initial power state
generic_command("power", QString());
+
+ // send initial list
+ generic_command("discovery_result", "");
}
void Bluetooth::onDisconnected()
diff --git a/bluetooth.h b/bluetooth.h
index 0bce40f..41e1719 100644
--- a/bluetooth.h
+++ b/bluetooth.h
@@ -49,6 +49,7 @@ class Bluetooth : public QObject
Q_INVOKABLE void disconnect(QString address);
Q_INVOKABLE void send_confirmation(void);
+ Q_INVOKABLE void set_avrcp_controls(QString address, QString cmd);
bool power() const { return m_power; };
bool discoverable() const { return m_discoverable; };
@@ -73,6 +74,7 @@ class Bluetooth : public QObject
void onDisconnected();
void onMessageReceived(MessageType, Message*);
+ QString process_uuid(QString uuid) { if (uuid.length() == 36) return uuid; return uuids.value(uuid); };
bool isDiscoveryListResponse(Message *tmsg) { return (tmsg->replyInfo() == "BT - Scan Result is Displayed"); };
bool isPowerResponse(Message *tmsg) { return (tmsg->replyInfo() == "Radio - Power set"); };
@@ -80,6 +82,8 @@ class Bluetooth : public QObject
bool m_power;
bool m_discoverable;
+ QMap<QString, QString> uuids;
+
const QStringList events {
"connection",
"request_confirmation",