Skip to content

Commit 365cf11

Browse files
author
Cruz Monrreal
authored
Merge pull request #10162 from pan-/cordio-driver-notify-inactivity
BLE - Notify HCI driver of host stack inactivity
2 parents ecfe0c8 + 339c57f commit 365cf11

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

features/FEATURE_BLE/targets/TARGET_CORDIO/driver/CordioHCIDriver.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ uint16_t CordioHCIDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
283283
return _transport_driver.write(type, len, pData);
284284
}
285285

286+
void CordioHCIDriver::on_host_stack_inactivity()
287+
{
288+
}
289+
286290
} // namespace cordio
287291
} // namespace vendor
288292
} // namespace ble

features/FEATURE_BLE/targets/TARGET_CORDIO/driver/CordioHCIDriver.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ class CordioHCIDriver {
134134
*/
135135
uint16_t write(uint8_t type, uint16_t len, uint8_t *pData);
136136

137+
/**
138+
* React to host stack inactivity.
139+
*
140+
* The host stack invoke this function when it is inactive. It allows a
141+
* driver to put its controller to sleep if all the conditions are met.
142+
*
143+
* Any call to write signals to the driver that the host stack is active.
144+
*/
145+
virtual void on_host_stack_inactivity();
146+
137147
protected:
138148
/**
139149
* Return a default set of memory pool that the Cordio stack can use.

features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void BLE::callDispatcher()
555555

556556
wsfOsDispatcher();
557557

558-
static Timeout nextTimeout;
558+
static LowPowerTimeout nextTimeout;
559559
CriticalSectionLock critical_section;
560560

561561
if (wsfOsReadyToSleep()) {
@@ -564,6 +564,9 @@ void BLE::callDispatcher()
564564
timestamp_t nextTimestamp = (timestamp_t) (WsfTimerNextExpiration(&pTimerRunning) * WSF_MS_PER_TICK) * 1000;
565565
if (pTimerRunning) {
566566
nextTimeout.attach_us(timeoutCallback, nextTimestamp);
567+
} else {
568+
critical_section.disable();
569+
_hci_driver->on_host_stack_inactivity();
567570
}
568571
}
569572
}

0 commit comments

Comments
 (0)