Skip to content

BLE - Notify HCI driver of host stack inactivity #10162

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

Merged
merged 3 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ uint16_t CordioHCIDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
return _transport_driver.write(type, len, pData);
}

void CordioHCIDriver::on_host_stack_inactivity()
{
}

} // namespace cordio
} // namespace vendor
} // namespace ble
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ class CordioHCIDriver {
*/
uint16_t write(uint8_t type, uint16_t len, uint8_t *pData);

/**
* React to host stack inactivity.
*
* The host stack invoke this function when it is inactive. It allows a
* driver to put its controller to sleep if all the conditions are met.
*
* Any call to write signals to the driver that the host stack is active.
*/
virtual void on_host_stack_inactivity();

protected:
/**
* Return a default set of memory pool that the Cordio stack can use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ void BLE::callDispatcher()

wsfOsDispatcher();

static Timeout nextTimeout;
static LowPowerTimeout nextTimeout;
CriticalSectionLock critical_section;

if (wsfOsReadyToSleep()) {
Expand All @@ -564,6 +564,9 @@ void BLE::callDispatcher()
timestamp_t nextTimestamp = (timestamp_t) (WsfTimerNextExpiration(&pTimerRunning) * WSF_MS_PER_TICK) * 1000;
if (pTimerRunning) {
nextTimeout.attach_us(timeoutCallback, nextTimestamp);
} else {
critical_section.disable();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this, or CriticalSectionLock critical_section; needed to begin with?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our case wsfOsReadyToSleep and WsfTimerNextExpiration needs to be called within a critical section.

_hci_driver->on_host_stack_inactivity();
}
}
}
Expand Down