samples icon indicating copy to clipboard operation
samples copied to clipboard

Get nothing with web bluetooth notification

Open wangnuannuan opened this issue 6 years ago • 0 comments

Hello! I am trying to connect rn4020 to Web Bluetooth in a Chrome browsers running on Win10. I have used this demo successfully , but every time the value is same I have used this demo , 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? :(

wangnuannuan avatar Dec 24 '18 07:12 wangnuannuan