Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What does "radio_order" and "RADIO_EVENT_TYPE_RX_PREEMPTABLE" etc. do? #184

Open
bayou9 opened this issue May 12, 2017 · 1 comment
Open

Comments

@bayou9
Copy link

bayou9 commented May 12, 2017

Hello, in the "radio_event_handler" callback, upon finishing dealing with an TX or RX event, or failed to do so, the function will proceed to execute an idle callback called "m_idle_cb", in which:

a function "order_search" will be called, in which:

an "RADIO_EVENT_TYPE_RX_PREEMPTABLE" type event will be created and subsequently a mesh pool position be allocated for it, and then a function "radio_order" will be called, in which:

this previously created "RADIO_EVENT_TYPE_RX_PREEMPTABLE" type event will be pushed into the "m_radio_fifo" FIFO, via the "radio_order" function this process invokes.

I almost completely missed the point of doing this, aren't all this basically just pushed an empty event into the "m_radio_fifo"? And then such empty events will be purged under certain, but not all circumstances?

What's the point in doing so?

My guess is that it pushes an empty event into the "m_radio_fifo" as a placeholder of some sort, so once an ACTUAL RX event came, it will automatically, at a rather low level which means low CPU consumption, be pushed into the previously empty event, which renders it no longer empty.

Still, I don't know what this function:
"purge_preemptable"
do?

So, a recap, I'm asking:

What does pushing an empty event in radio_order, order_scan etc. do?

What is an RADIO_EVENT_TYPE_RX_PREEMPTABLE event?

What does function "purge_preemptable" do?

@trond-snekvik
Copy link
Contributor

The purge_preemptable function halts any ongoing "preemptable" events. The only preemptable event is the RX_PREEMPTABLE, which is the background scanning event. As the name suggests this event will be preempted by any other requested events, and this function is the function that does this. If there's a new event in the queue, and we're currently in an RX_PREEMPTABLE event, we'll stop it, and start the new event. This is to let advertisements abort any ongoing scanning, as opposed to waiting until scanning is complete before sending advertisements.

In the case of the idle-event, this function has no effect, as there's no preemptable event to push (since we were idle). We don't treat this case differently though, as we don't want to make a new corner case.

We're in RX mode pretty much all the time, and we're only aborted by the advertisements. The RX_PREEMPTABLE radio event can be seen as our "fallback" event, in case there's nothing else for the radio to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants