You are reading a single comment by @user118764 and its replies. Click here to read the full conversation.
  • Hi Gordon,

    Thanks for getting back to me.

    So I've narrowed the problem to different behaviour between using the Web BT library on MacOS verses on iOS with the WebBLE app.

    Turns out that this code works on MacOS but does nothing on iOS:

    connection.device.ongattserverdisconnected = event => {
    	console.log(`${connection.device.name} disconnected. Reconnecting...`)
    	connection.reconnect(c => console.log('Reconnected'))
    }
    
    

    So now I've changed over to this instead which does work the same on both platforms:

    connection.on('close', event => {
    ...
    

    Reconnection works as expected on MacOS but never works on iOS. The error that is returned immediately upon calling connection.reconnect is this:

    <BLE> ERROR: Premature cancellation.
    

    This causes the close event to trigger again so the reconnect method is called a second time, for which the following error is returned:

    <BLE> ERROR: No known device for device transaction Transaction(id: 287, key: device:connectGATT)
    

    Do you have any idea how I can successfully reconnect the device from iOS?
    Thanks

About

Avatar for user118764 @user118764 started