onDeviceConnected and onStateChanged are not working
Mobile Device Environment Provide a list of operating systems on which this issue is relevant.
Device: Android 10
OS: API 29
Application Environment Provide information about your development environment:
React Native version: 0.78.0
RN Bluetooth Classic version: 1.73.0-rc.13
Describe the bug On connecting to bluetooth device using device.connect({ connectionType: 'binary' }), onDeviceConnected and onStateChanged are not called after successfull connection event i tried using RNBluetoothClassic.connectToDevice(address, { connectionType: 'binary' }). But i saw on diconnecting bluetooth device onDeviceDisconnected get called successfully
useEffect(() => {
const con_sub = RNBluetoothClassic.onDeviceConnected((event) => {
console.log('onDeviceConnected', event);
updateStatus('connect');
});
const dis_sub = RNBluetoothClassic.onDeviceDisconnected((event) => {
console.log('onDeviceDisconnected');
updateStatus('disconnect');
});
const state_sub = RNBluetoothClassic.onStateChanged((event) => {
console.log('onStateChanged', event);
});
return ()=>{
con_sub.remove()
dis_sub.remove()
state_sub.remove()
}
}, []);
Expected behavior on successfully connected to bluetooth device, it should call onDeviceConnected and onStateChanged.
And the events work for the regular String Delimited connection? I have a feeling I removed the Events of these types on purpose, since you can now Await the connection and know when you're connected. If you want them back, or if this is incorrect, feel free to open a PR in order to get them working.
As you may have realized, I don't do any active development on this project, I just maintain it at this point.