[common][bluetooth][TSIX-6237, add new tct-help wgt with wearable profile] 53/244153/4
authorzhaofeng <feng.zhao@samsung.com>
Tue, 15 Sep 2020 08:45:21 +0000 (16:45 +0800)
committerFENG ZHAO <feng.zhao@samsung.com>
Wed, 23 Sep 2020 09:03:54 +0000 (09:03 +0000)
Change-Id: Iccd83daef894055bfeb1c68d94c7f8737309e94f
Signed-off-by: zhaofeng <feng.zhao@samsung.com>
common/tct-bluetooth-tizen-tests/suite.json
common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/config.xml [new file with mode: 0755]
common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/css/style.css [new file with mode: 0755]
common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/icon.png [new file with mode: 0755]
common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/images/tizen_32.png [new file with mode: 0755]
common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/index.html [new file with mode: 0755]
common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/js/main.js [new file with mode: 0755]

index dc3c85281b2937372004b20aa9a944cea3229f7c..44db392490905084fb5cd61ce496aba0bd8288e3 100755 (executable)
                     ],
                     "install-path": "apps",
                     "sign-flag": "true"
+                },
+                "wearable-tct-bt-helper": {
+                    "app-name": "wearable-tct-bt-helper",
+                    "blacklist": [
+                        "manifest.json"
+                    ],
+                    "install-path": "apps",
+                    "sign-flag": "true"
                 }
             }
         },
diff --git a/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/config.xml b/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/config.xml
new file mode 100755 (executable)
index 0000000..8a4c03b
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/wearable-tct-bt-helper" version="1.0.0" viewmodes="maximized">
+    <tizen:application id="lqF5SD9s9A.TctBtHelper" package="lqF5SD9s9A" required_version="6.0"/>
+    <content src="index.html"/>
+    <icon src="icon.png"/>
+    <name>wearable-tct-bt-helper</name>
+    <tizen:privilege name="http://tizen.org/privilege/bluetooth"/>
+    <tizen:privilege name="http://tizen.org/privilege/telephony"/>
+    <tizen:profile name="wearable"/>
+</widget>
diff --git a/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/css/style.css b/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/css/style.css
new file mode 100755 (executable)
index 0000000..a55f482
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd.
+
+Licensed under the Apache License, Version 2.0 (the License);
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+
+Authors:
+
+
+
+*/
+
+* {
+    font-family: Lucida Sans, Arial, Helvetica, sans-serif;
+}
+
+body {
+    margin: 0px auto;
+}
+
+header h1 {
+    font-size: 36px;
+    margin: 0px;
+}
+
+header h2 {
+    font-size: 18px;
+    margin: 0px;
+    color: #888;
+    font-style: italic;
+}
+
+article select {
+    width: 150px;
+}
+
+article p {
+    clear: both;
+}
+
+article > section form {
+    border: 1px solid #888;
+    -moz-border-radius: 10px;
+    -webkit-border-radius: 10px;
+    border-radius: 10px;
+    -moz-box-shadow: 10px 10px 5px #888;
+    -webkit-box-shadow: 10px 10px 5px #888;
+    box-shadow: 10px 10px 5px #888;
+    background-color: #eee;
+    padding: 10px;
+    margin-bottom: 30px;
+}
+
+article > section label {
+    font-weight: bold;
+    font-size: 13px;
+}
+
+article > section input {
+    margin-bottom: 3px;
+    font-size: 13px;
+}
+
+#serviceTxt {
+    width: 300px;
+}
+
+footer p {
+    text-align: center;
+    font-size: 12px;
+    color: #888;
+    margin-top: 24px;
+}
+
diff --git a/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/icon.png b/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/icon.png
new file mode 100755 (executable)
index 0000000..c22cfa8
Binary files /dev/null and b/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/icon.png differ
diff --git a/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/images/tizen_32.png b/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/images/tizen_32.png
new file mode 100755 (executable)
index 0000000..983c883
Binary files /dev/null and b/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/images/tizen_32.png differ
diff --git a/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/index.html b/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/index.html
new file mode 100755 (executable)
index 0000000..133059d
--- /dev/null
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<!--
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd.
+
+Licensed under the Apache License, Version 2.0 (the License);
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+
+Authors:
+    Karol Surma <k.surma@samsung.com>
+-->
+
+<html>
+<head>
+    <meta charset="utf-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
+    <meta name="description" content="Tizen basic template generated by Tizen Web IDE"/>
+
+    <title>tct-bt-helper</title>
+
+    <link rel="stylesheet" type="text/css" href="css/style.css"/>
+    <script src="js/main.js"></script>
+</head>
+
+<body>
+  <header>
+    <hgroup>
+      <h1>Bluetooth</h1>
+      <h2>tct-bt-helper</h2>
+    </hgroup>
+  </header>
+
+
+
+  <article>
+    <p>Service UUID</p>
+    <div id="serviceUUID">
+        <input type="text" id="serviceTxt" value="5BCE9431-6C75-32AB-AFE0-2EC108A30860">
+    </div>
+    <div id="registerSection">
+      <button onclick="registerService();">Register service</button>
+      &nbsp;&nbsp;
+      <button onclick="unregisterService();">Unregister service</button>
+    </div>
+    <div id="discoverSection">
+      <p>Bluetooth device list</p>
+      <select id="devicesList" >
+      </select>
+      <button onclick="discover();">Search</button>
+    </div>
+    <div id="connectService">
+      <p>Connect to service</p>
+      <button onclick="connectService();">Connect to service</button>
+    </div>
+  </article>
+
+  <footer>
+    <p>&copy; 2013 Samsung. All rights reserved.</p>
+  </footer>
+</body>
+</html>
diff --git a/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/js/main.js b/common/tct-bluetooth-tizen-tests/wearable-tct-bt-helper/js/main.js
new file mode 100755 (executable)
index 0000000..89d08bf
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+
+Copyright (c) 2013 Samsung Electronics Co., Ltd.
+
+Licensed under the Apache License, Version 2.0 (the License);
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+
+Authors:
+
+
+
+*/
+
+var serviceHandler = null;
+
+function discoverDevicesError() {
+    alert("Error discoverDevices");
+}
+
+function setPoweredError() {
+    alert("Error setPowered");
+}
+
+function startDiscoveryDevice() {
+    var length, k;
+    alert("searching - it's gona take about 10 seconds");
+    var discoverDevicesSuccessCallback = {
+            onstarted: function() {
+            },
+            ondevicefound: function(device) {
+            },
+            ondevicedisappeared: function(address) {
+            },
+            onfinished: function(devices) {
+                length = devices.length;
+                document.getElementById("devicesList").options.length = 0;
+                for (k = 0; k < length; k++) {
+                    document.getElementById("devicesList").options[k] = new Option(devices[k].address + " - " + devices[k].name, devices[k].address);
+                }
+                alert("search completed");
+            }
+        };
+    adapter.discoverDevices(discoverDevicesSuccessCallback, discoverDevicesError);
+}
+
+function registerServiceSuccessCallback(handler) {
+    serviceHandler = handler;
+    handler.onconnect = function(socket) {
+        var textmsg = "Test", sendtextmsg = [], length, i;
+        length = textmsg.length;
+        for (i = 0; i < length; i++) {
+            sendtextmsg[i] = textmsg.charCodeAt(i);
+        }
+        socket.writeData(sendtextmsg);
+    }
+    alert("service registered");
+}
+
+function registerServiceError() {
+    alert("Error registerService");
+}
+
+function startRegisterService() {
+    adapter.registerRFCOMMServiceByUUID(document.getElementById("serviceTxt").value,"Chat service",registerServiceSuccessCallback,registerServiceError);
+}
+
+function discover() {
+    adapter = tizen.bluetooth.getDefaultAdapter();
+    adapter.setPowered(true, startDiscoveryDevice, setPoweredError)
+}
+
+function registerService() {
+    adapter = tizen.bluetooth.getDefaultAdapter();
+    adapter.setPowered(true,startRegisterService,setPoweredError);
+}
+
+function unregisterServiceSuccessCallback() {
+    chatServiceHandler = null;
+    alert("Service is unregistered.");
+}
+
+function unregisterServiceError() {
+    alert("Error unregisterService");
+}
+
+function unregisterService() {
+    if (serviceHandler != null) {
+         serviceHandler.unregister(unregisterServiceSuccessCallback,unregisterServiceError);
+    }
+}
+
+function createBondingError() {
+    alert("Error createBonding");
+}
+
+function getDeviceError() {
+    alert("Error getDevice");
+}
+
+function connectError() {
+    alert("Error connectToServiceByUUID");
+}
+
+function connectCallback(device) {
+    if (device != null && device.uuids.indexOf(document.getElementById("serviceTxt").value) !== -1) {
+        // open socket
+            device.connectToServiceByUUID(document.getElementById("serviceTxt").value, function() {
+                alert("connected");
+            },connectError);
+    } else {
+        alert("device UUID is null");
+    }
+}
+
+function getDeviceCallback() {
+    adapter.getDevice(document.getElementById("devicesList").value, connectCallback, getDeviceError);
+}
+
+function createBondingCallback() {
+    adapter.createBonding(document.getElementById("devicesList").value, getDeviceCallback, createBondingError);
+}
+
+function connectService() {
+    adapter = tizen.bluetooth.getDefaultAdapter();
+    adapter.setPowered(true, createBondingCallback, setPoweredError);
+}