bcsphere / bluetooth

Please support! Kindly "Star" this standard Bluetooth Smart API / SDK :) The "bcsphere/bluetooth" is a phonegap/cordova plugin. It's a Bluetooth JavaScript API from JUMA, a Bluetooth expert team. It supports both Bluetooth 4.0 GATT/Bluetooth Low Energy (BLE) interface in iOS/Android and Bluetooth 2.1 Classic Rfcomm / L2cap socket interface as Bluetooth Serial Port/SPP, as well as iBeacon!
Apache License 2.0
298 stars 12 forks source link

Android BLE 4.3 reconnect error #18

Closed mrichie closed 10 years ago

mrichie commented 10 years ago

android 4.3 下重新连接设备会发生异常 参考链接:lianhttp://stackoverflow.com/questions/17870189/android-4-3-bluetooth-low-energy-unstable

修改之后,在发起链接请求中加上错误处理,经测试即可解决该问题

       device.connect(function(){
             prepareDevice();
        },  connectError);

        connectError: function(msg){
            console.log('connect error ' + msg);
            if(device.platform == 'Android'){
                BC.Bluetooth.CloseBluetooth(function(){
                    BC.Bluetooth.OpenBluetooth(function(){ console.log('reopened ble')});
                }, function(){ console.log('cannot close ble')});
            };
        },
lizhijumacc commented 10 years ago

Thanks a lot for your commit.