Hello
We have two boards PCA10040, client and peripheral. Blinky exemple.
The project is with two buttons on peripheral side and 2 leds on the client side.
If we hold down button1 on the peripheral and then after reseat the central led3 toggle on the central..
That works ok. Also with button2 and led4.
But now the problem.
If we hold down the two buttons together ( button1 and button2) on the peripheral and then after reseat the central
only 1 led toggle.
We have do a init_state_update on ble_lbs.c . below the code, what we do wrong?
Thank you very much for the help!
#include "boards.h"
void init_state_update(ble_lbs_t * p_lbs)
{
ret_code_t err_code;
ble_gatts_hvx_params_t params;
uint8_t button_state = 0;
if(nrf_gpio_pin_read(BSP_BUTTON_0)==0)
{
button_state=1;
}
//2. button
if(nrf_gpio_pin_read(BSP_BUTTON_1)==0)
{
button_state=3;
}
uint16_t len = sizeof(button_state);
memset(¶ms, 0, sizeof(params));
params.type = BLE_GATT_HVX_NOTIFICATION;
params.handle = p_lbs->button_char_handles.value_handle;
params.p_data = &button_state;
params.p_len = &len;
err_code = sd_ble_gatts_hvx(p_lbs->conn_handle, ¶ms);
nrf_gpio_pin_read(BSP_BOARD_LED_3);
nrf_gpio_pin_read(BSP_BOARD_LED_4);
APP_ERROR_CHECK(err_code);
_____
static void on_write(ble_lbs_t * p_lbs, ble_evt_t * p_ble_evt)
{
ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;
if ((p_evt_write->handle == p_lbs->led_char_handles.value_handle) &&
(p_evt_write->len == 1) &&
(p_lbs->led_write_handler != NULL))
{
p_lbs->led_write_handler(p_lbs, p_evt_write->data[0]);
}
//for after reseat.
else if (p_evt_write->handle == p_lbs->button_char_handles.cccd_handle)
{
if(p_ble_evt->evt.gatts_evt.params.write.len == 2)
{
init_state_update(p_lbs);
}
}
}