简体   繁体   English

如果其他任何尝试连接的应用程序需要断开连接,我们如何才能使BLE外围设备仅连接到我们的Android应用程序(中央)

[英]How we can achieve the BLE peripheral device to connect to only our Android app (Central) if any other app try to connect need to disconnect

As question suggested we have our own BLE device and Android app to connect with that device. 有问题的建议我们拥有自己的BLE设备和与该设备连接的Android应用。 We are able to connect with BLE device and do all operations successfully. 我们能够与BLE设备连接并成功完成所有操作。

In the meantime, we are able to detect our BLE device with other 3rd party apps and able to connect and do operations. 同时,我们能够与其他第三方应用程序一起检测我们的BLE设备,并能够进行连接和操作。

But we want to restrict the other apps to connect with our BLE device and if they connect with device immediately it needs to disconnect. 但是我们想限制其他应用程序与我们的BLE设备连接,如果它们立即与设备连接,则需要断开连接。 I have searched in google and SO but unable to get any information to achieve this, if any one have idea help me out 我已经在Google和SO中进行了搜索,但无法获得任何信息来实现这一目标,如果有人有想法可以帮助我

on connect event send some data from app to the device and get verified data from device to app, change some programmed mechanism that app send some data to device and device verify and gives acknowledgement and based on that you keep connections or else you can disconnect from the device. 在连接事件上,将一些数据从应用程序发送到设备,并从设备到应用程序获取经过验证的数据,更改某种编程机制,使应用程序向设备和设备发送一些数据,并进行确认,并在此基础上保持连接,否则您可以断开连接设备。 I had implemented this things and working perfectly 我已经实现了这些东西,并且工作完美

public boolean connectDeviceBonded(String address, String name) {
        if (address == null) {
            throw new NullPointerException("Address cannot be null or not found");
        }
        macAddress = address;


        boolean value =  bluetoothLe.connectScannerBonded(address);
        if ( value) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            int ret = reqEncryptedKey(10000);
            if (ret != SUCCESS){
                return false;
            }
        }
        return value;
    }

reqEncryptedKey() send some encrypted data to device and device has same encryption algorithm and device verify my data and gives response to app the success and fail, based on success and fail app can keep connection and disconnect. reqEncryptedKey()向设备发送一些加密数据,并且设备具有相同的加密算法,并且设备验证我的数据并根据成功与失败对应用程序做出响应,基于成功与失败,应用程序可以保持连接和断开连接。 and I also put some piece of code in device so that if device is giving fail then device disconnects automatically. 并且我还在设备中放置了一些代码,以便如果设备出现故障,则设备会自动断开连接。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 BLE外围设备可以连接到Android手机上的后台应用程序吗? - Can a BLE peripheral connect to a background app on an Android phone? Android BLE设备发现,连接和断开连接 - Android BLE device discover, connect & disconnect Android BLE App只能订阅1个BLE设备的特征通知 - Android BLE App can ONLY subscribe characteristic notification for 1 BLE device Android设备作为BLE中央和读/写操作,无需外围设备触发 - Android device as BLE central and read/write operations without any trigger from peripheral 在不使用应用程序的情况下将 Android 设备与 BLE 外设连接 - Connecting an Android Device with a BLE Peripheral without using an App 如何结合使用Android的“ openvpn connect”应用程序以编程方式连接和断开VPN连接? - How can I programmatically connect and disconnect vpn connections by using android's “openvpn connect” app in combination with intents? 如何使Android BLE连接到Bluez Peripheral? (连接问题) - How to make Android BLE connect to Bluez Peripheral? (Connection issues) 我们如何将 Android/iOS 应用程序连接到 Azure IoT Central 并发送遥测数据? - How do we connect Android/iOS app to Azure IoT Central and send Telemetry data? BLE-连接仅支持中央模式的Android手机 - BLE - Connect Android phones that support only central mode Android 移动/设备同时作为 BLE GATT 外围设备和中央设备 - Android Mobile/Device as a BLE GATT Peripheral & Central Simultaneously
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM