cordova-plugin-bluetoothle icon indicating copy to clipboard operation
cordova-plugin-bluetoothle copied to clipboard

retrieveConnected returns empty array

Open czzplnm opened this issue 4 years ago • 2 comments

Using a Samsung S8 with Ionic/VueX/Capacitor, here is my code:

getConnected: ({commit, state, dispatch}) => {
    return new Promise((resolve, reject) => {
      window.bluetoothle.retrieveConnected(
        function (success) {
          if (success.length === 0) {
            console.log('retrieveConneccted is empty!');
          } else {
            commit('setIsConnectedTo', success)
          }
          console.log('getConnected: retrieveConnected: success:', success);

          resolve();
        },
        function (error) {
          commit('setIsConnectedTo', null)
          console.log('getConnected: retrieveConnected: error:', error);
          reject();
        },
        {
          "services": [
            SERVICE_180D,
            SERVICE_180F
          ]
        }
      );
    })
  },

retrieveConnected's success function is always returning an empty array. I have tried invoking it without params as well.

czzplnm avatar Dec 23 '20 23:12 czzplnm

So it seems this only returns the paired devices. How are you supposed to figure out what you are connected to then!?!?

czzplnm avatar Dec 28 '20 21:12 czzplnm

Have an similar problem on Iphone. After hot reload my iphone stays connected to my device but there is no possibility to kill that connection.

MonksterFX avatar Jan 23 '21 17:01 MonksterFX