Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

蓝牙读取被拦截 #91

Open
Chilisauce1212 opened this issue Apr 14, 2021 · 0 comments
Open

蓝牙读取被拦截 #91

Chilisauce1212 opened this issue Apr 14, 2021 · 0 comments

Comments

@Chilisauce1212
Copy link

Chilisauce1212 commented Apr 14, 2021

在基于nordic nrf52832ble5.0蓝牙芯片开发时,通过一项自定义的可读写服务只能有效写入数据,无法读取。后来在<DeviceControlActivity.Java>Line 342发现在进行特征属性判断时将读写分为互斥事件,实现并行判断后可进行读取。

if ((charaProp & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) {
                    mSpCache.put(WRITE_CHARACTERISTI_UUID_KEY + mDevice.getAddress(), characteristic.getUuid().toString());
                    ((EditText) findViewById(R.id.show_write_characteristic)).setText(characteristic.getUuid().toString());
                    BluetoothDeviceManager.getInstance().bindChannel(mDevice, PropertyType.PROPERTY_WRITE, service.getUuid(), characteristic.getUuid(), null);
                } else if ((charaProp & BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
                    BluetoothDeviceManager.getInstance().bindChannel(mDevice, PropertyType.PROPERTY_READ, service.getUuid(), characteristic.getUuid(), null);
                    BluetoothDeviceManager.getInstance().read(mDevice);
                }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant