This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Button click to fast to Send Information

Im working with a nRF51422 EK. So, there is an android application with 2 buttons. Each of them can Set a LED. It will be set as long as the button is pressed on the application. When I release the button on the application the LED state should be low. The problem is: if I click and release to fast, it will send a high for the click but it wont send a low for release. This problem I only have when click and release to fast. Is it possible to solve this problem with a notification?

Because I will need an Information from my nRF51422 to Android Device that the information is recieved.

static void led_write_handler(ble_lbs_t * p_lbs, uint8_t led_state) {

	switch (led_state){
		case 0: nrf_gpio_pin_clear(LEDBUTTON_LED_PIN_NO);
						nrf_gpio_pin_clear(AUF);
				break;
		case 1: nrf_gpio_pin_set(LEDBUTTON_LED_PIN_NO);
						nrf_gpio_pin_set(AUF);
				break;
		case 2:	nrf_gpio_pin_clear(LEDBUTTON_LED1_PIN_NO);
						nrf_gpio_pin_clear(AB);
				break;
		case 3: nrf_gpio_pin_set(LEDBUTTON_LED1_PIN_NO);
						nrf_gpio_pin_set(AB);
				break;
	}

Regards,

Inspectron AG

Parents
  • Notifications are used for the server role. With client role you'll use the write command.

    Using write without response (write command) allows for faster throughput and queuing of packets in tx buffer . However, the likely problem here is that the android application doesn't actually send any packet when the button is released too fast. This can be verified by using our sniffer application.

    I'm guessing that the application has not acked the previous packet, hence failing to send the second packet indicating that the button is released. The send function in android should then return the status of the write. If it's not GATT_SUCCESS, you should do a re-transmit when the pending packet is acked at application level.

    Note that write command is considered to be a reliable link and is acked at the link layer. Write commands are easier to implement as it automatically queues and acks packets.

    Link to Android callback: developer.android.com/.../BluetoothGattCallback.html

    EDIT: fixed link to Android callback

  • hello Vidar,as am using the ble_lbs example i found intially button state is invalid(0xff) but later once i press the button it is going to button press state but it alsyws remain the button pressed state why it is not showing button release state any ideas?

Reply Children
No Data
Related