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

issues about zb_bdb_is_factory_new() and ZB_JOINED() API in sleepy end device

Hi Noridc guys

    recently I got some issues about how to know device network state. then I found there was a issue in zb_bdb_is_factory_new() API.

    first, i formed a network by coordinator, and then i triggered  zigbee netwrok steering in SLEEPY END DEVICE by calling bdb_start_top_level_commissioning( ZB_BDB_NETWORK_STEERING ) function. when the stack posted a steering success event by zboss_signal_handler() signal ZB_BDB_SIGNAL_DEVICE_FIRST_START, I tried to call ZB_JOINED() function and it return TRUE, it is correct. but when I called zb_bdb_is_factory_new() function, it also return TRUE! why?

    also, I did another test. firstly i formed a network by a coordinator, then I made the SLEEPY END DEVICE join this coordinator and waited it success, and then i cut off the power of parent device( gateway ). after few seconds later, stack posted a event ZB_ZDO_SIGNAL_LEAVE with status RET_OK. when all these preparation were done, i tried to leave this network by calling do_leave() function in DK demo code. upon stack told me leave was complete status RET_OK, i recalled zb_bdb_is_factory_new() function. i expected the result is TRUE, but it returned FALSE! how could it be?

    can anyone tells me how to know the device network state excatly? im really confused. thx.

  • Hello,

    I suspect that this is only because you check zb_bdb_is_factory_new() too fast after the joined network event. Try to call it on a button press a short time after this event. I tested with the CLI example, and added a CLI command for printing the result for zb_bdb_is_factory_new(), and it returned false after I called "bdb start" as a coordinator.

    The reason I believe it returns false immediately after joining the network is that I believe that zb_bdb_is_factory_new() checks the flash for stored network data. Since flash operations can take some time, my guess is that it is not yet stored in the event.

    Best regards,

    Edvin

  • Hi

        actually, I'm doing develop in sleepy end device not a coordinator, and I've just tested zb_bdb_is_factory_new() and ZB_JOINED() by button, and it shows the same result after device joined network. I'm sure there were dozens of seconds between joined success and push button.

        can you hlep me check this issue in sleepy end device? thx for your time.

  • Just out of curiosity, is this ticket related to this one:

    https://devzone.nordicsemi.com/f/nordic-q-a/62305/after-the-steering-is-successful-the-zb_bdb_is_factory_new-interface-returns-true

    I have not seen this question before, and they were registered only minutes apart. If you are working together with the poster of the other thread, perhaps we can continue the discussion in only one of them. If not, no worries.

    I agree with you. I tested today with the light_control examples. The coordinator returned false, but the other nodes (light_bulb and light_switch) returned true (which should return false as well). I noticed, however, that if I reset the device after they have joined the network, then the zb_bdb_is_factory_new() returned false on all devices. I have to check with our zigbee team whether this is a bug or not.

    In the meantime, perhaps you can use some workaround where you set a custom variable in the event when you join the network. Before you join the network, you can use zb_bdb_is_factory_new(). After you have joined the network, then it is obviously no longer "is_factory_new". How does that sound?

    Best regards,

    Edvin

  • Hello,

    I received a reply from our Zigbee team today. Please try calling bdb_load_factory_new_flag(void); before zb_bdb_is_factory_new(); It should load the flags, making zb_bdb_is_factory_new() return the correct value. 

    Best regards,

    Edvin

Related