小编emi*_*bet的帖子

Android BLE无法从设备接收Gatt特性通知

当我在特征上写一个值时,我正试图从设备收到通知,但我没有收到任何东西.我启用了关于特征的通知,然后我写了值.我已经看到设备中的特性已经改变了它的价值,但是我无法得到通知.这是我的代码:

DeviceActivity:

public class DevicesActivity extends Activity {

private BLEService mBluetoothLeService;
private String mDeviceAddress;
private boolean mConnected = false;
private BluetoothGattCharacteristic mNotifyCharacteristic;

private final ServiceConnection mServiceConnection = new ServiceConnection() {

    @Override
    public void onServiceConnected(ComponentName componentName, IBinder service) {
        mBluetoothLeService = ((BLEService.LocalBinder) service).getService();
        if (!mBluetoothLeService.initialize()) {
            finish();
        }
        mBluetoothLeService.context = DevicesActivity.this;
        mBluetoothLeService.connect(mDeviceAddress);
    }

    @Override
    public void onServiceDisconnected(ComponentName componentName) {
        mBluetoothLeService = null;
    }
};

private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        final …
Run Code Online (Sandbox Code Playgroud)

android bluetooth-lowenergy

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

bluetooth-lowenergy ×1