GoogleChrome / GoogleChrome/samples

Get nothing with web bluetooth notification

Open
#623 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.9k
Forks
2.4k
Avg merge
24m
Merged PRs (30d)
2

Description

Hello!
I am trying to connect rn4020 to Web Bluetooth in a Chrome browsers running on Win10.
I have used [this demo](https://googlechrome.github.io/samples/web-bluetooth/battery-level.html) successfully , but every time the value is same
I have used [this demo](https://googlechrome.github.io/samples/web-bluetooth/notifications.html) , and the log is:
```
Requesting Bluetooth Device...
Connecting to GATT Server...
Getting Service...
Getting Characteristic...
> Notifications started
```
The following is c code:
```
uint8_t battery = 100;

EMBARC_PRINTF("rn4020 test application\r\n");

rn4020_setup(rn4020_ble);
rn4020_reset_to_factory(rn4020_ble);
rn4020_set_dev_name(rn4020_ble, "embARC");

rn4020_set_services(rn4020_ble, RN4020_SERVICE_DEVICE_INFORMATION |
RN4020_SERVICE_BATTERY | RN4020_SERVICE_USER_DEFINED);

rn4020_clear_private(rn4020_ble);
rn4020_add_prv_service(rn4020_ble, test_private_services_uuid);
rn4020_add_prv_char(rn4020_ble, test_private_characteristic_0_uuid,
RN4020_PRIVATE_CHAR_PROP_NOTIFY | RN4020_PRIVATE_CHAR_PROP_READ,
5, RN4020_PRIVATE_CHAR_SEC_NONE);
rn4020_add_prv_char(rn4020_ble, test_private_characteristic_1_uuid,
RN4020_PRIVATE_CHAR_PROP_WRITE | RN4020_PRIVATE_CHAR_PROP_READ,
5, RN4020_PRIVATE_CHAR_SEC_NONE);

rn4020_set_features(rn4020_ble, RN4020_FEATURE_SERVER_ONLY);
//rn4020_remove_bond(rn4020_ble);
rn4020_reset(rn4020_ble);

//rn4020_refresh_handle_uuid_table(rn4020_ble);

rn4020_advertise(rn4020_ble);

rn4020_refresh_handle_uuid_table(rn4020_ble);

while (1) {
rn4020_battery_set_level(rn4020_ble, battery--);
//rn4020_server_write_prv_char(rn4020_ble, test_private_characteristic_0_uuid, &battery, 1);
//rn4020_advertise(rn4020_ble);
board_delay_ms(1000, 0);
if(rn4020_ble->need_advertise)
{
rn4020_ble->need_advertise = 0;
rn4020_advertise(rn4020_ble);
}
if (battery < 30) {
battery = 100;
}
}
```
The battery will change every second, and i test it with `nRF Connect` , this app can get the notification data

Why is this happening? :(

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.