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

[Zigbee] zigbee_erase_persistent_storage() function erroneously changes the state of the user button configuration.

Hello.

This function from Zigbee SDK 4.0.0 changes configuration of already configured input pin by calling nrf_gpio_cfg_default(ERASE_PIN);

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**@brief Function to set the Erase persistent storage depending on the erase pin
*/
zb_void_t zigbee_erase_persistent_storage(zb_bool_t erase)
{
#if defined (BOARD_PCA10056) || defined (BOARD_PCA10059) || defined (BOARD_PCA10100)
if (!erase)
{
nrf_gpio_cfg_input(ERASE_PIN, NRF_GPIO_PIN_PULLUP);
int i;
volatile uint32_t pin_state;
/* Read a few times to make sure the value in the register has been updated. */
for (i = 0; i < READ_RETRIES; i++)
{
pin_state = nrf_gpio_pin_read(ERASE_PIN);
}
if (pin_state == 0)
{
erase = ZB_TRUE;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The leds_buttons_init() function in main() configures the GPIO pin for user button, but a subsequent call to the zigbee_erase_persistent_storage() function returns the default configuration, so the button does not work as expected.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**@brief Function for application main entry.
*/
int main(void)
{
zb_ret_t zb_err_code;
zb_ieee_addr_t ieee_addr;
/* Initialize timer, logging system and GPIOs. */
timer_init();
log_init();
leds_buttons_init();
/// Unrelated code removed
zigbee_erase_persistent_storage(ERASE_PERSISTENT_CONFIG);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This behavior is present at least in the zigbee/light_control/light_bulb example for the pca10059 board, but I have a suspicion that this works the same way in other examples.

Parents
  • Hello,

    I see. That is true. I guess if you want to use the button handler with the IDENTIFY_MODE_BSP_EVT event (BSP_EVENT_KEY_0), you need to call buttons_leds_init() after the zigbee_erase_persistent_storage() call, or modify the ERASE_PIN define. 

    I'll report this to our Zigbee team.

    Best regards,

    Edvin

Reply
  • Hello,

    I see. That is true. I guess if you want to use the button handler with the IDENTIFY_MODE_BSP_EVT event (BSP_EVENT_KEY_0), you need to call buttons_leds_init() after the zigbee_erase_persistent_storage() call, or modify the ERASE_PIN define. 

    I'll report this to our Zigbee team.

    Best regards,

    Edvin

Children
  • Hello. Thank you very much. Yes, I understand that I need to call buttons_leds_init after the zigbee_erase_persistent_storage or implement my own version of zigbee_erase_persistent_storage(). I just would like this bug fixed in the SDK for other users to get the best experience with the SDK