Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Ionic BLE plugin work weird on IOS

$
0
0

@pdj wrote:

It works quite well…
but weird things. is that…
On handler of OK button on AlertController,
I want to connect to BLE that is selected.

but the problem is that When I hardcoded id, it works well
for example,
this.ble.connect(“03A23620-E31F-FA2C-5E8C-F1C3CXXXXXXXX”).subscribe(rr=>{

but when I not hardcoded id( for example this.ble.connect(data).subscribe(rr=>{
)

, it doesn’t work even though it is same!( I checked on Log)
and log says
Could not find peripheral “03A23620-E31F-FA2C-5E8C-F1C3CXXXXXXXX”.

what may be the problem?

search(){
    this.result_id=[];
    this.result_name=[];
    this.ble.startScan([]).subscribe(device => {
      this.result_id.push(JSON.stringify(device.id));
      this.result_name.push(JSON.stringify(device.name));
      console.log("list starting as :"+JSON.stringify(device.id)+"///"+JSON.stringify(device.name));
    });
   
    setTimeout(() => {
      this.ble.stopScan();
      let alert = this.alertCtrl.create();
          alert.setTitle('Lightsaber color');
      for(var i=0; i<this.result_name.length; i++){
        console.log(this.result_name[i]);
        if(this.result_name[i]!=null){
          alert.addInput(
            {
              type: 'radio', 
              label: this.result_name[i],
              value: this.result_id[i],
              checked: false
           });
        }
       
      }
      alert.addButton('Cancel');
      alert.addButton({
        text: 'OK',
        handler: data => {
         console.log(data);
         this.a=data;
         //03A23620-E31F-FA2C-5E8C-F1C3CXXXXXXXX

         //"03A23620-E31F-FA2C-5E8C-F1C3CXXXXXXXX"
         console.log("result is : "+this.a);
         this.ble.connect("03A23620-E31F-FA2C-5E8C-F1C3CXXXXXXXX").subscribe(rr=>{
      
          console.log("connecttttttttt "+rr);
          console.log(rr);
          
            
        },rr=>{
        
          console.log(rr+"disconnecteddddddd");
        });

        }
      });
      alert.present();
      
    }, 3000);
  }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



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