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

Problems connecting with my band 3 bracelet

$
0
0

@lex2012 wrote:

Hello everyone,
I am trying to connect to a my band 3 bracelet through bluethoot ble to read the heart rate. I try to pair the device through the protocol in which I must send a message and wait for a response with a startnotify before, but I do not receive anything from the bracelet. I have read that before I must activate the notifications through the descriptor 2902, but I could not get it. This is code I have at the moment. Any help will be very welcome, thanks.

var auint=new Uint8Array(18);
    auint[0]=0x01;
    auint[1]=0x08;
    auint[2]=0x30;
    auint[3]=0x31;
    auint[4]=0x32;
    auint[5]=0x33;
    auint[6]=0x34;
    auint[7]=0x35;
    auint[8]=0x36;
    auint[9]=0x37;
    auint[10]=0x38;
    auint[11]=0x39;
    auint[12]=0x40;
    auint[13]=0x41;
    auint[14]=0x42;
    auint[15]=0x43;
    auint[16]=0x44;
    auint[17]=0x45;
    //let buffer = new Uint8Array([ 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]).buffer

    this.ble.connect(device.id).subscribe(
        data => {
            console.log("conectado");
            this.conectado=true;
            console.log("vinculando....");
            console.log("Realizando la primera escritura...");
            this.
           // this.ble.write(device.id,'fee1', '00000009-0000-3512-2118-0009af100700', data.buffer).then(d=>{}).catch(err=>console.log(err));
             this.ble.writeWithoutResponse(device.id,'fee1', '00000009-0000-3512-2118-0009af100700', data.buffer);
        
            this.ble.startNotification(device.id,'fee1','00000009-0000-3512-2118-0009af100700').subscribe(buffer=>{
                console.log("ha habido cambios! se ha recibido lo siguiente:");
                let data= new Uint8Array(buffer);
                console.log(data);
                if (data[1]==0x01){
                    console.log("al principio");
                    let buffer1=new Uint8Array([2, 8]).buffer;
                    this.ble.write(device.id,'fee1', '00000009-0000-3512-2118-0009af100700', buffer1).then(d=>{}).catch(err=>console.log(err));
        
                }else if(data[1]=0x02){
                    console.log("en medio");
                    let buffer1=new Uint8Array([3, 8,]).buffer;
                    this.ble.write(device.id,'fee1', '00000009-0000-3512-2118-0009af100700', buffer1).then(d=>{}).catch(err=>console.log(err));
        
                }else{
                    console.log("ha finalizado");
                }
           },err=>console.log("no notificacion",err) );
        },err=>console.log("Errrir¡¡¡ a conectar", err)

    );

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70432

Trending Articles