GithubHelp home page GithubHelp logo

android / connectivity-samples Goto Github PK

View Code? Open in Web Editor NEW
1.6K 128.0 1.3K 5.63 MB

Multiple samples showing the best practices in connectivity on Android.

License: Apache License 2.0

Java 55.75% Kotlin 44.25%

connectivity-samples's Introduction

Warning Bluetooth samples have been migrated to the new platform-samples repo. Others might follow.

Connectivity Samples Repository

This repository contains a set of individual Android Studio projects to help you get started writing Connectivity apps in Android.

If you find an issue or bug in one of the projects, feel free to file an issue on this repository with the following information:

  • The specific project that pertains to the issue (for example: the 'BluetoothLeGatt' project)
  • Steps to repro the issue, including the API version and Android device model

Example of a good issue: In the BluetoothLeGatt sample, I am unable to see any BLE devices after the initial scan. I ran the sample on a Pixel 2 running API version 28.

Examples of bad issues:

  1. Bluetooth scanning doesn't work.
  2. My app is crashing when I try to send a large file.
  3. How can I support BLE in my app?

Requests for samples related to Android connectivity are also welcome.

connectivity-samples's People

Contributors

bobwzy avatar calren avatar carolinakinetic avatar cedricferry avatar chinesco avatar clownshen avatar codingjeremy avatar ggfan avatar isaidamier avatar kokoro-team avatar marcelpinto avatar nic0lette avatar owahltinez avatar rawmain avatar whitevegagabriel avatar xiangjun-z avatar yaraki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

connectivity-samples's Issues

Trouble with the working of the app.

I have got two set of android mobile phone with BLE enabled. And app also successfully gets installed on both. But neither of them are showing the result, means 'No devices found-....'. I have turned on mobile broadcast device option on, and other for scanning. Still showing the same. Help me here, why is this happening, and what is the solution for this? @google-automerger

Missing Unit Tests

There are no unit tests at all. Please add them to verify correctness of code

iOS-Android interconnection

Hi guys,

I have an issue:
with Google Example Apps (iOS, Android):

  • iOS works perfectly with iOS
  • Android works perfectly with Android
  • iOS doesn't work at all with Android

with a custom app we made:

  • iOS works perfectly with iOS
  • Android works perfectly with Android
  • iOS doesn't see any messages from Android while Android does receive a message from iOS.
  • Both iOS and Android apps have API keys created for a specific platform inside a single Google Console project.

Android is using:
DISCOVERY_MODE_DEFAULT
DISTANCE_TYPE_DEFAULT

iOS is using:
kGNSDiscoveryMediumsDefault
kGNSDiscoveryModeDefault

Any hints on how to make those work will be greatly appreciated!

Support for marshmallow is not there

In android for the Intent Filter ACTION_FOUND we need one more permission and that is a dangerous permission

those things should be addressed

Recieving messages does not work

Sometimes the chat do not recieve messages. After investigation I found the problem.
When ConnectedThread was started state was not set to STATE_CONNECTED yet.
The line
mConnectedThread.start();
should be moved after
setState(STATE_CONNECTED);

add .gitignore

it is a good practice to add a .gitignore file so accidentally avoid checking in unwanted files.
also facilitates ease of selecting changed files.

End point not found

I have an HTC One_M8 running Android 5.0.1 and a Galaxy Note3 running Android 4.4.2 connected to the same WiFi and both of the have bluetooth activated. I have clicked "Advertise" in one and "Discover" in the other one but I am never getting the dialog displaying the endpoints to connect to.

What could be the reason?

Thanks,

M

Nearby Connections API not working in some devices

Tested connections-quickstart sample with Nexus 9 (5.0) and moto g2(6.0 rooted) with both devices in the same WiFi network. Both show success status in advertising and discovery. But doesn't show nearby devices (i.e. fails to go into onEndPointFound() method). The same was the result when tried with Nexus 9 (5.0) and Nexus 9 (7.0). But when tested with Galaxy tab S(5.0.3) with moto g2(6.0 rooted) works good for some time (say 5 times) and later requires reboot of Galaxy device to work good again.
P.s. My WiFi network do support mDNS discoverability and I've also tested with various other WiFi networks

May be an update on Nearby API samples is needed.

Nearby API does not work with GMS 9.4.0 (works with 8.7.03)

Device: Samsung Galaxy Note 5
OS: Android 6.0.1

The Nearby API does not work with Google Play Services 9.4.0 + on this device. With the sample app, no errors are seen (advertising or discovery is started successfully, no error callbacks, etc.) but no endpoint can be found (whether this device is advertising or discovering).

After reverting Google Play Services to 8.7.03, using the API works perfectly.

Note: I do not see this problem on Samsung Galaxy S5 (works on GMS 9.4.52).

BluetoothLeService read the wrong flag for Heart Rate Measurement

It seems to me on lines 130 of BluetoothLeService.java there is an error for reading flag for Heart Rate Measurement.
In specification, the first 8 bits of this characteristic determines if it's FORMAT_UINT16 or FORMAT_UINT8. Or in sample, the flag is define by
int flag = characteristic.getProperties();
It should be something like this :
int flag = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0);

Not compatible with Android 6

Getting error when trying to scan for Bluetooth devices. I assume this is due to not requesting permissions at runtime?

10-16 10:57:52.526 9400-9400/? D/BluetoothAdapter: startLeScan(): null
10-16 10:57:52.534 9400-9400/? D/BluetoothAdapter: STATE_ON
10-16 10:57:52.541 9400-9412/? D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5
10-16 10:57:52.543 9400-9412/? W/Binder: Caught a RuntimeException from the binder stub implementation.
10-16 10:57:52.543 9400-9412/? W/Binder: java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results
10-16 10:57:52.543 9400-9412/? W/Binder: at android.os.Parcel.readException(Parcel.java:1599)
10-16 10:57:52.543 9400-9412/? W/Binder: at android.os.Parcel.readException(Parcel.java:1552)
10-16 10:57:52.543 9400-9412/? W/Binder: at android.bluetooth.IBluetoothGatt$Stub$Proxy.startScan(IBluetoothGatt.java:772)
10-16 10:57:52.543 9400-9412/? W/Binder: at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper.onClientRegistered(BluetoothLeScanner.java:324)
10-16 10:57:52.543 9400-9412/? W/Binder: at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:56)
10-16 10:57:52.543 9400-9412/? W/Binder: at android.os.Binder.execTransact(Binder.java:453)
10-16 10:57:54.485 9400-9405/com.example.android.bluetoothlegatt I/art: Ignoring second debugger -- accepting and dropping
10-16 10:57:54.545 9400-9480/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
10-16 10:57:54.630 9400-9480/? I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 09/02/15, 76f806e, Ibddc658e36
10-16 10:57:54.638 9400-9480/? I/OpenGLRenderer: Initialized EGL, version 1.4`

Bluetooth message corruption

Message data is corrupted if a given message is not consumed by the associated handler before more bytes are read into the buffer by mmInStread.read() in connectedThread.run(). This occurs when BluetoothChat is used as a baseline for bluetooth communications with a device that transfers bluetooth data in many small message packets, instead of buffering data into single (larger) message packets, with significant dead time in between.

Note that BluetoothChat IS the go-to sample code for bluetooth communications (at least non-BLE comms), so this issue is likely to be encountered by users looking for examples.

When the message is created by:

mHandler.obtainMessage(Constants.MESSAGE_READ, bytes, -1, buffer)

the message data is not COPIED, but a pointer to buffer is embedded in the message structure.
'bytes' indicates how many bytes of legitimate data are in the buffer, and will appear in msg.arg1.

This is documented in more detail here:
http://stackoverflow.com/questions/6417945/java-threading-issue-with-handler-message-data-being-overwritten-by-next-message/38922407#38922407

One possible fix is to allocate a bundle for received bytes, and attach them to the message with .setData(). I've not tested this, so can't confirm it will work. Also, it seems like allot of overhead to transfer a few bytes to the handler at a higher level thread.

In my case, received Bluetooth message are line-oriented, so I added a string builder to the connected thread .run() function, that only sent a message when a complete line was detected (looked for '\r' termination). This MAY NOT be an appropriate general solution.

android 6.0 watch not connecting or disconnect after some time

Can you pls help
my bluetooth watch is not connecting in only android 6.0 .In other version its connecting and giving heartrate.

I have change method mBluetoothGatt = (BluetoothGatt) connectGattMethod.invoke(device, this, false, mGattCallback, TRANSPORT_LE); in only 6.0 after this method watch is connected but disconnected after some time

Background Service not responding after 5 minutes

Hello,

While implementing Nearby in my app i encountered a problem which i couldn't get rid of. I have followed the google example in terms of implementation the service and set the Strategy to BLE_ONLY which includes TTL_INFINITY. Unfortunately my service is not receiving any messages after 5 minutes of working which is the default TTL period. Is that the limitation of Nearby in background or a bug which shouldn't exist. If so how can you make it work full time ?

App crashes when I click on unknown characteristics

06-22 18:42:28.290 27111-27111/com.example.android.bluetoothlegatt E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.android.bluetoothlegatt, PID: 27111
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.bluetooth.BluetoothGattDescriptor.setValue(byte[])' on a null object reference
at com.example.android.bluetoothlegatt.BluetoothLeService.setCharacteristicIndication(BluetoothLeService.java:339)
at com.example.android.bluetoothlegatt.DeviceControlActivity$3.onChildClick(DeviceControlActivity.java:142)
at android.widget.ExpandableListView.handleItemClick(ExpandableListView.java:716)
at android.widget.ExpandableListView.performItemClick(ExpandableListView.java:655)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3053)
at android.widget.AbsListView$3.run(AbsListView.java:3860)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

Google nearby API background scan doesn´t work after application kill

I have kontakt.io beacon and I try to write application for background scanning with nearby API.

I use this method to subscribe messages:

SubscribeOptions options = new SubscribeOptions.Builder()
// Finds messages attached to BLE beacons. See
// https://developers.google.com/beacons/
.setStrategy(Strategy.BLE_ONLY)
.build();

Nearby.Messages.subscribe(mGoogleApiClient, getPendingIntent(), options)
        .setResultCallback(new ResultCallback<Status>() {
            @Override
            public void onResult(@NonNull Status status) {
                if (status.isSuccess()) {
                    Log.i(TAG, "subscribed successfully");
                    mSubState = SubState.SUBSCRIBING;
                    // Start background service for handling the notification.
                    getActivity().startService(getBackgroundSubscribeServiceIntent());
                } else {
                    Log.i(TAG, "could not subscribe");
                    handleUnsuccessfulNearbyResult(status);
                }
            }
        });

My code is according to this sample.

I´m receiving messages correctly, but when I kill application no more message come.

Is there any way to get messages from nearby after killing application?

Discovery/Connection impossible

When I used this demo one year ago (with Kitkat and Lollipop) everything was ok, but not now.

I'm using a Nexus 5 (6.0.1) and Nexus 6P ( N preview 1). From Settings app I can see and connect two devices.
When I start the discovery on these two devices (from this demo app) I can't see any devices and obviously I can't start the connection procedure. Why?

It's a bug on Nexus 6p android n preview 1 related to bluetooth? Or this demo is broken on Android 6.x and N?

Not able to connect with clients

Hi , i am Nearby Connections API, i have downloaded the demo form this url https://github.com/tutsplus/Android-NearbyMessages
and i have 2 android devices which are connected with same WIFI , when i run the code on first android device as Host i got below in console
* getStatus=Status{statusCode=SUCCESS, resolution=null}
getStatusCode=0
getLocalEndpointName=Nearby Advertising
*

device-2016-02-06-153316

*and when i run the same demo as Client in my second android device * i got below in console
*onConnected
getStatusMessage(18004): null
getStatusCode(18004): 0
.getStatus(18004): Status{statusCode=SUCCESS, resolution=null}
*

device-2016-02-06-153514

Please any one guide me why i am not able to connect ?
and where i am doing wrong ?

Failed to connect

I just downloaded and installed this. Testing with a Galaxy S7, the app shows me the bluetooth devices, but when I tap on my one, it tells me it failed to connect. I found a web page that says you need to change the UUID as follows:

private static final UUID MY_UUID_SECURE =
            UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
    private static final UUID MY_UUID_INSECURE =
            UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");

This does allow it to connect. I don't know why it needs changed, but perhaps the sample code should be updated so it works out of the box?

Marshmallow Discoverable Timeout

This runs well after adding permission requests on marshmallow.
However, I've noticed that when the device is made discoverable it never timeouts.

I've tried to find the cause and make a fix but I haven't found anything yet.
Anyone else willing to look into this?

Getting error..want a help to solve.

I got an Error in values-v11

<style name="Theme.Base" parent="@android:style/Theme.Holo" /> (error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.Holo') will i get some help to solve this..?

Can send message but can't receive

Hi.

Thanks for the sample, it's been very helpful to get me started!
I tested the sample on two devices:

  1. Nexus 5 (Android 6.0.1)
  2. ASUS K019 (Android 4.4.2)

I paired both devices, and ASUS K019 can send message perfectly to my Nexus 5 (and received perfectly too).
But, my Nexus 5 can't seem to send message to ASUS device. There's no error message on Nexus, but ASUS isn't showing up any messages sent from Nexus device.

Any idea?

Thanks!

Beacon messages cause exception

NearbyDevices expects a JSON formatted message passed from another Nearby device. However when a beacon attachment is received, the app has no idea what to expect, resulting in an unhandled exception.

Recommendation: add exception handling to onFound() and onLost() functions in MainFragment.java.

If we wanted to get fancy we could add some code to detect whether the message is from a Nearby device or a beacon.

Send data from Android to remote Bluetooth LE device

Is it possible to include in this sample an event and a method?
One would be an event for incoming data, let's call this "onDataReceived".
The second one would be a method to send data, let's call this "sendData".

I'm pretty new to Bluetooth and is too much quantity of information to understand it as it is.
I have an Android device which needs to have a Bluetooth connection in a service (already exists in this sample). The device connects to a remove UART capable BLE device and should transmit and receive data. So in this case, the event + method would be very helpful.

Thank you

Nexus 6 not found when running app in nexus 5

i am trying to find out the devices which is capable with BLE technology. now as i read motorola nexus 6 has the capability of BLE. now i want to scan from my Nexus 5 with marshmallow 6.0.1. even though i have given permission of location the device(Nexus 6) not found. I am struggling with this issue. Please help.

Connecting device is connected but will not receive data

In BluetoothChatService.java's connected() function there seems to be a bug. The connected() function is only called from two places the AcceptThread or the ConnectThread. I've noticed an error arise when the function is called from the AcceptThread.

In AcceptThread, connected() is called with the state is either STATE_LISTEN, or STATE_CONNECTING. In line 197 when mConnectedThread.Start() is called, the thread will finish immediately because the state is not STATE_CONNECTED.

To fix this issue line 206, setState(STATE_CONNECTED) should be moved to above line 197.

Samsung Galaxy Note LTE 10.1 is not able to reconnect

I am not really sure if this is an issue with Samsung devices or the framework itself or the sample, so I thought I would go about posting it here first.

This issue is coming forth on a Samsung Galaxy Note LTE 10.1 (GT-N8020) using Android 4.4.2.
Tested on three different devices with the same specification.
It is working on Galaxy Express (GT-I8730) using 4.4.4 (even when using Cyanogen, interestingly) and on Nexus 4 using 5.1.1

When I launch the sample application in Android Studio (1.4) it finds the devices correctly at first (tested with iPhone and Nexus devices) and it can connect to them, but after a few seconds it disconnects and when I tap on reconnect mBluetoothGatt.connect() returns with success, but onConnectionStateChange is never called. If I tap a second time onConnectionStateChange is called, but onServicesDiscovered is never called even though mBluetoothGatt.discoverServices() returns true.

If I return to the main Activity and tap on the device again (thus restarting the service) it works again until the eventual disconnect.

Please redirect me to the appropriate place if this is not a suitable forum where I should have posted this.

Background scanning combined with foreground scanning

My goal is to subscribe to Google Nearby Messages in BLE-only mode. While my app is not running (in background or simply not started after phone restart) I want just low-power background scanning. I can live with scanning only on screen-on events. When the app is active I want to do foreground scanning with fast reactions to found and lost beacons and mainly with distance estimations.

What am I doing now is to subscribe in background (with PendingIntent) in a BroadcastReceiver reacting to "BOOT_COMPLETED" intent. I receive an intent when my app is in background and other application makes a scan. So this part works.

Now when my Activity starts (onResume), I subscribe second time in foreground mode (with MessageListener instead of PendingIntent). And I unsubscribe in onPause. I get updates very fast including distance estimations. So this also works.

There are some issues with this:

  1. When I subscribe in foreground, I first receive onLost for all messages by background receiver. Right after I receive onFound by both background and foreground receivers. The same occurs on unsubscribe call. Leads to ugly flickering and lower performance...

  2. The battery consumption is enormous. Mainly after many subscribe/unsubscribe cycles. I was able to completely discharge battery through the night (around 10 hours) when phone was not used at all and thus in background scanning. The battery consumption screen shows Google Play Services as the biggest battery consumer(25%).

Or is this wrong approach? Is there a better way how to achieve the combination of background and foreground scanning?

Auto connect in the BluetoothLeGatt

Hi,

When i scan the device it showing and connecting and displaying read characteristics. But once its disconnected there is no values are coming that is fine. After some time the devices is available i need to auto connect to that device.

private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
       @Override
       public void onReceive(Context context, Intent intent) {
           final String action = intent.getAction();
          // Utility.showLog("action", "action" + action);
           if (BluetoothLeService.ACTION_GATT_CONNECTED.equals(action)) {
               mConnected = true;
               updateConnectionState(Utility.getResourcesString(StartWorkoutNewActivity.this, R.string.connected));
           } else if (BluetoothLeService.ACTION_GATT_DISCONNECTED.equals(action)) {
               mConnected = false;
               updateConnectionState(Utility.getResourcesString(StartWorkoutNewActivity.this, R.string.disconnected));
           } else if (BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
               displayGattServices(mBluetoothLeService.getSupportedGattServices());
               enableHeartRateSensor();
           } else if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
               displayData(intent.getStringExtra(BluetoothLeService.EXTRA_DATA));
           }
       }
   }
public void displayGattServices(List<BluetoothGattService> gattServices) {
        if (gattServices == null)
            return;
        gattServiceAdapter = new BleServicesAdapter(this, gattServices);
    }


    public boolean enableHeartRateSensor() {
        if (gattServiceAdapter == null)
            return false;

        BluetoothGattCharacteristic characteristic = gattServiceAdapter
                .getHeartRateCharacteristic();
        Log.d("", "characteristic: " + characteristic);
        if (characteristic != null) {
            final int charaProp = characteristic.getProperties();
            if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
                // If there is an active notification on a characteristic, clear
                // it first so it doesn't update the data field on the user interface.
                if (mNotifyCharacteristic != null) {
                    mBluetoothLeService.setCharacteristicNotification(
                            mNotifyCharacteristic, false);
                    mNotifyCharacteristic = null;
                }
                mBluetoothLeService.readCharacteristic(characteristic);
            }
            if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
                mNotifyCharacteristic = characteristic;
                mBluetoothLeService.setCharacteristicNotification(
                        characteristic, true);
            }
        }

        return true;
    }

Can you please help me on this issue.

Background Scanning does not happen when app is killed

Hi

I tried out this sample application and it seems that background scanning does not happen when app is killed. Is this just a normal behaviour? Does background scanning means app is in the background( but not yet killed in the task manager)?

I am using a samsung Galaxy s6 for the testing. Thanks!

How to automatically connect the BlueTooth device when it discovered?

Thank you for gives us a great Bluetooth app. I have a question about the connection between two paired devices. I connected to an Android phone and chat, it worked well. However, when a device goes far another device, the connection is lost. Then, I want to make them automatically connect (without click button connect again) when these devices go to close together (Bluetooth range). Could you give me some guidance for my task? Thanks

Nearby notifications when Beacon is INACTIVE

I continue to see notification's from a Google Nearby registered Beacon even when the Beacon is set to be INACTIVE in the Dashboard. Is this expected? I was hoping to not see the Nearby notifications any longer but I still see them constantly irrespective of the Beacon's state. Is this a known bug?

Legacy Audio

Is there any way to use this by broadcasting the sounds via legacy audio equipment such as loudspeakers?

App crashes on API 17,18

i Changed the minsdk and targeted sdk to 17 ...then i run it on API 17 it runs and asks to turn on Bluetooth when turned on the app flashes out. I tried to read stack and found this Please answer it in first priority Thanks in advance.

java.lang.NoClassDefFoundError: android.bluetooth.BluetoothManager
at com.example.android.bluetoothadvertisements.MainActivity.onCreate(MainActivity.java:44)
When i opened the file it was pointing towards this line
if (mBluetoothAdapter.isMultipleAdvertisementSupported())

DeviceControlActivity attempts to read value for any characteristic

It seems to me on lines 129 and 139 of DeviceControlActivity.java that the code means to only perform logic if the characteristic properties include READ or NOTIFY. Instead of bitwise or, I think it should be bitwise and, like this:

if ((charaProp & BluetoothGattCharacteristic.PROPERTY_READ) > 0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.