randdusing / cordova-plugin-bluetoothle

Bluetooth Low Energy Phonegap Plugin
803 stars 353 forks source link

App crash in Windows 10 #454

Open rifathaqueamit opened 7 years ago

rifathaqueamit commented 7 years ago

Hello.

I am having a problem with windows Javascript application. During the running of the application, if I disable the bluetooth and then re-enable it again, and after that, if the subscribe() function is called then the app crashes.

It is happening after calling the subscribe() function for the above circumstance only. Can you provide any clue why this is happening ?

randdusing commented 7 years ago

Any stack trace or error log? Can't provide much input without that.

rifathaqueamit commented 7 years ago

I solved it by myself. In the function getService(...), when a service is found by fromIdAsync(), it pushes the service object into the cachedService array. After I turn bluetooth off and then on, this service object gets lost that is already in the cachedService. If the getService(...) is called again, it returns success as the serviceId and deviceId is still inside the cachedService array, although the service itself does not work at that time. So I commented out ' for (var i = 0; i < cachedServices.length; i++) { var service = cachedServices[i]; if (service.deviceId == deviceId && service.serviceId == serviceId) { successCallback(service.deviceService); return; } }' inside the getService(..) function and it solved the crashing problem.