8 | * Created by ttdevs
9 | * 2017-05-18 (android)
10 | * https://github.com/ttdevs
11 | */
12 | public class BLEUtils {
13 |
14 | /**
15 | * @return Returns true if property is writable
16 | */
17 | public static boolean isCharacteristicWriteable(BluetoothGattCharacteristic pChar) {
18 | return (pChar.getProperties() & (BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE)) != 0;
19 | }
20 |
21 | /**
22 | * @return Returns true if property is Readable
23 | */
24 | public static boolean isCharacteristicReadable(BluetoothGattCharacteristic pChar) {
25 | return ((pChar.getProperties() & BluetoothGattCharacteristic.PROPERTY_READ) != 0);
26 | }
27 |
28 | /**
29 | * @return Returns true if property is supports notification
30 | */
31 | public static boolean isCharacteristicNotifiable(BluetoothGattCharacteristic pChar) {
32 | return (pChar.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0;
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/DemoOld/apps/air/src/main/java/com/ttdevs/air/utils/BaseWorkerThread.java:
--------------------------------------------------------------------------------
1 | package com.ttdevs.air.utils;
2 |
3 | /**
4 | * Created by ttdevs
5 | * 2017-01-22 (android)
6 | * https://github.com/ttdevs
7 | */
8 | public abstract class BaseWorkerThread extends Thread {
9 |
10 | private boolean isRunning = true;
11 |
12 | @Override
13 | public void run() {
14 | super.run();
15 | isRunning = workerBefore();
16 |
17 | while (isRunning) {
18 | workerCycle();
19 | }
20 |
21 | workerAfter();
22 | }
23 |
24 | /**
25 | * 提前执行 true: 继续 false: 结束
26 | *
27 | * @return
28 | */
29 | public boolean workerBefore() {
30 | return true;
31 | }
32 |
33 | /**
34 | * 工作方法,被循环调用
35 | *
36 | * @return true: 继续 false: 结束
37 | */
38 | public abstract void workerCycle();
39 |
40 |
41 | /**
42 | * 结束执行
43 | */
44 | public void workerAfter() {
45 |
46 | }
47 |
48 | /**
49 | * 开始线程
50 | */
51 | public void startThread() {
52 | isRunning = true;
53 | try {
54 | start();
55 | } catch (Exception e) {
56 | e.printStackTrace();
57 | isRunning = false;
58 | }
59 | }
60 |
61 | /**
62 | * 结束线程
63 | */
64 | public void stopThread() {
65 | isRunning = false;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/DemoOld/apps/air/src/main/res/drawable/side_nav_bar.xml:
--------------------------------------------------------------------------------
1 |