Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startNotification response empty [{},2] @android8.0.0 #805

Closed
butlet opened this issue Sep 4, 2020 · 3 comments
Closed

startNotification response empty [{},2] @android8.0.0 #805

butlet opened this issue Sep 4, 2020 · 3 comments

Comments

@butlet
Copy link

butlet commented Sep 4, 2020

hi,
i am building an android app using ionic5 framework in which cordova-plugin-ble-central plugin is used. The BLE peripheral has a characteristic which pushes notifications to phone.i can scan,connect,and readrssi,also can write to ble,but when i read 0x1800 0x2a00 it did not response data,it's empty.
i enable the notification and register the callback by calling startNotification(),when the ble sends message, the phone just received [{},1],or [{},2],[{},3].... why no data,just has received times

start_notification(){ this.ble.startNotification(this.connected_device.id, SERVICE_ID_READ,CHARACTERISTICS_ID_READ).subscribe( msg => { this.setStatus("notification succ:" + JSON.stringify(msg)); }, err => { this.setStatus("notification err:" + JSON.stringify(err)); } ) }

@AyalaMan-Main
Copy link

I am facing the same problem. I had to go to an older version to make it work. Had the problem with android 6, 9 and 10

@markamccorkle
Copy link

Have you tried reading the first index in the response to an array buffer? This was changed a little while back and nobody updated the docs.

const data = new Uint8Array(buffer[0]);

@Bozonych
Copy link

Have you tried reading the first index in the response to an array buffer? This was changed a little while back and nobody updated the docs.

const data = new Uint8Array(buffer[0]);

yep, i will changed my code:
from: const data16 = new Uint16Array(buffer);
to: const data16 = new Uint16Array(buffer[0]);
and all works fine ^-^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants