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

What is the proper way to stop Ant-FS?

I have an application using N5150 SOC with S210 softdevice and using softdevice_handler, SDK 10.0.0.0, and I'm using Ant-FS to gather data from this device. I only want to do this at specific times so I need to shut down Ant-FS >99% of the time.

It's easy to start up Ant-FS and use it, but I don't see any way that antfs.c provides to shut down. Now, when I want to shut down, I block Ant Events to the antfs handler and simply close, then unassign the channel. It seems that there is more state within antfs that should be reset, but the state_machine_reset() function is local with no external interface so that doesn't appear to be an intentional interface.

What's the right way to do this?

Tom

  • We have started a refactoring the ANT examples to ease operations like this, unfortuneately we haven't got to the ANT FS example yet.

    In addition to closing and unassigning, you can call sd_ant_burst_handler_wait_flag_disable().

    When you start you should call antfs_init() and antfs_channel_setup().

    Have you experienced that state of the variables antfs affects operation after reinit?

  • Thank you, Petter. I do call antfs_init() and antfs_channel_setup() as well as setting m_pairing_state=PAIRING_OFF every time I start up ant-fs. These were part of the original antFS_client() startup. I can't say I've run it enough times (or enough months ;-) to say that there isn't a 'surprise' somewhere, but, so far it's been working reliably.

    In the dispatch function, it detects that I want to stop the ant-fs, no longer dispatches to antfs_message_process(), and locally handles sd_ant_channel_unassign() after it receives the EVENT_CHANNEL_CLOSED.

    I'll add the sd_ant burst...disable(), thanks for the advice. Do I put this BEFORE I close the channel or when I catch the channel close? Tom

  • One additional piece of information, I had to add a function to antfs.c:

    void antfs_stop(void) // TWS, added to provide clean up on stop { state_machine_reset(); }

    because the timer used by antfs was still running if I called antfs soon after shutting it down and antfs would fail in antfs_init() on the app_timer_create() call.

    Tom

Related