This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Android BLE 与CC2541通信问题

Other Parts Discussed in Thread: CC2541

您好,

        我想通过Android手机的蓝牙与CC2541建立通信,从网上下载的Android示例看,手机上的蓝牙只能与一个BLE设备建立连接(connectGatt(mContext, false, mGattCallback))。现在我想有多个BLE终端设备,请问要怎样使android上的蓝牙与多个设备建立连接,或是以怎样的方式连接会让传输效率最高???

  • yong,

    过程是一样的。

    你可以搜索SensorTag 的Android 代码,final BluetoothDevice device = mBtAdapter.getRemoteDevice(address);

    然后你会发现,mBluetoothGatt = device.connectGatt(this, false, mGattCallbacks);

    这就是得到远端的地址,然后发起连接。

    对多个设备无非是重复几次这个。

  • Yan,

           您好,我看SensorTag的android代码将Connect在OnDeviceLick中调用的,我原以为只能是点击某个DeviceList后就连接该BLE设备。按照您上面说的,是不是对每个device 的address都可以用final BluetoothDevice device = mBtAdapter.getRemoteDevice(address);mBluetoothGatt = device.connectGatt(this, false, mGattCallbacks);这两个函数来建立同时与多个BLE设备的连接而不会互相干扰?   当多个BLE设备同时向Android手机发送数据时,最终都是在同一个回调mGattCallbacks中处理?