This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Android Central connected to 2 peripherals

I have modified the Android Blinky App to connect two peripherals (nRF52 DK)

Scanning and Connecting to two peripherals works.. but when i want to start sending notifications of one of the peripherals the connection is terminated.

in the btsnoop.log I can see that the connection is terminated with "Connection Timeout"..

I am not sure if there is a problem with my implementation or device specific problem.

here is the source code:

        LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mDatathroughputUpdateReceiver, makeGattUpdateIntentFilter());
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mDatathroughputUpdateReceiver2, makeGattUpdateIntentFilter());
    Bundle extras = getArguments();
    mDeviceName = extras.getString(DatathroughputService.EXTRA_DEVICE_NAME);
    mDeviceAddress = extras.getString(DatathroughputService.EXTRA_DEVICE_ADDRESS);
    mDeviceName2 = extras.getString(DatathroughputService.EXTRA_DEVICE_NAME2);
    mDeviceAddress2 = extras.getString(DatathroughputService.EXTRA_DEVICE_ADDRESS2);


    mIntentDatathroughput = new Intent(getActivity(), DatathroughputService.class);
    mIntentDatathroughput.putExtra(DatathroughputService.EXTRA_DEVICE_ADDRESS, mDeviceAddress);
    getActivity().startService(mIntentDatathroughput);
    boolean flag = getActivity().bindService(mIntentDatathroughput, mServiceConnection, 0);

   mIntentDatathroughput2 = new Intent(getActivity(), DatathroughputService.class);
    mIntentDatathroughput2.putExtra(DatathroughputService.EXTRA_DEVICE_ADDRESS, mDeviceAddress2);
    getActivity().startService(mIntentDatathroughput2);
    boolean flag2 = getActivity().bindService(mIntentDatathroughput2, mServiceConnection2, 0);
Parents
  • I don't think there could be any trouble with that. But you wrote earlier that you still can receive data from one device ?

    My suggestion is to test by trying to write to a characteristic (by writeCharacteristic not setCharacteristicNotification ). You can test and check if it works with one device before testing with two, concurrently. You can also check if it's the issue with Android phone by using our nRFMaster Control Panel app. It should work with more than 1 peripheral.

  • What if you enable notification and receive notification from one device, and then after that you connect to second one and enable notification on that ? Make sure you use separate BluetoothGatt instance for each of them.

    setCharacteristicNotification() should work, it should send the write command to the CCCD characteristic. Please check again.

Reply Children
No Data
Related