Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48983

Ionic BLE ble.write return null on ios

$
0
0

I’m using this plugin inside a ionic + stencil app

I’m send a write command to a characteristic that support WRITE.
If I call ble.write on Android, the callback returns me OK
If I call ble.write on iOS, the callback returns me NULL.
in both cases, I can see on my peripheral device that the command has been sent correctly.

I connect to the device like this:

  connectToDevice(device){
var toast = new utils();
let tclass;
let tmessage;

console.log('----connectToDevice----');
BLE.connect(device.id).subscribe( 
    peripheralData => {
      this.device = peripheralData;
      let connectBtn = document.querySelector('#connectBtn') as any;
      console.log('device connected: ', this.device);
    },
    error => {
      console.log('connect error: ', error);
    }
);

}

And then, send the command with this code:

async sendCommandNew(id){
    let noteOk;
    let noteError;

    let data;
    data = this.stringToBytes(this.commandToSend);
    let timerId = setInterval(() => {
      BLE.write(id, "49535343-fe7d-4ae5-8fa9-9fafd205e455", "49535343-1e4d-4bd9-ba61-23c647249616", data).then((res) => {
        console.log('res: ', res);
       
      }).catch(() => {
        console.log('res no');
      }
      )
    }, 1000);
    setTimeout(() => { clearInterval(timerId); console.log('stopped'); }, 5000);
  }

This is the characteristic

enter image description here

Inside the plugin issue many people had this problem but no solution provided.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>