Skip to content

Commit dee6e34

Browse files
BLE local device: add function to manage low power mode status
1 parent dff9e41 commit dee6e34

File tree

7 files changed

+29
-0
lines changed

7 files changed

+29
-0
lines changed

src/local/BLELocalDevice.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ void BLELocalDevice::noDebug()
478478
HCI.noDebug();
479479
}
480480

481+
void BLELocalDevice::setLowPowerMode(bool status)
482+
{
483+
HCI.leSetLPMode(status);
484+
}
485+
481486
#if !defined(FAKE_BLELOCALDEVICE)
482487
BLELocalDevice BLEObj;
483488
BLELocalDevice& BLE = BLEObj;

src/local/BLELocalDevice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class BLELocalDevice {
107107

108108
virtual void setDisplayCode(void (*displayCode)(uint32_t confirmationCode));
109109
virtual void setBinaryConfirmPairing(bool (*binaryConfirmPairing)());
110+
111+
virtual void setLowPowerMode(bool status);
112+
110113
uint8_t BDaddress[6];
111114

112115
protected:

src/utility/HCI.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,11 @@ void HCIClass::dumpPkt(const char* prefix, uint8_t plen, uint8_t pdata[])
14811481
}
14821482
}
14831483

1484+
void HCIClass::leSetLPMode(bool status)
1485+
{
1486+
HCITransport.setLPMode(status);
1487+
}
1488+
14841489
#if !defined(FAKE_HCI)
14851490
HCIClass HCIObj;
14861491
HCIClass& HCI = HCIObj;

src/utility/HCI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class HCIClass {
105105
virtual int leStartResolvingAddresses();
106106
virtual int leReadPeerResolvableAddress(uint8_t peerAddressType, uint8_t* peerIdentityAddress, uint8_t* peerResolvableAddress);
107107

108+
virtual void leSetLPMode(bool status);
109+
108110
virtual void readStoredLKs();
109111
virtual int readStoredLK(uint8_t BD_ADDR[], uint8_t read_all = 0);
110112
virtual void writeLK(uint8_t peerAddress[], uint8_t LK[]);

src/utility/HCICordioTransport.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#endif
5555

5656
extern BLE_NAMESPACE::CordioHCIDriver& ble_cordio_get_hci_driver();
57+
extern void ble_cordio_set_lp_mode(bool status);
5758

5859
namespace BLE_NAMESPACE {
5960
struct CordioHCIHook {
@@ -68,6 +69,10 @@ namespace BLE_NAMESPACE {
6869
static void setDataReceivedHandler(void (*handler)(uint8_t*, uint8_t)) {
6970
getTransportDriver().set_data_received_handler(handler);
7071
}
72+
73+
static void setLowPowerMode(bool status) {
74+
ble_cordio_set_lp_mode(status);
75+
}
7176
};
7277
}
7378

@@ -309,4 +314,9 @@ void HCICordioTransportClass::onDataReceived(uint8_t* data, uint8_t len)
309314
HCICordioTransport.handleRxData(data, len);
310315
}
311316

317+
void HCICordioTransportClass::setLPMode(bool status)
318+
{
319+
CordioHCIHook::setLowPowerMode(status);
320+
}
321+
312322
#endif

src/utility/HCICordioTransport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class HCICordioTransportClass : public HCITransportInterface {
4242

4343
virtual size_t write(const uint8_t* data, size_t length);
4444

45+
virtual void setLPMode(bool status);
46+
4547
private:
4648
static void onDataReceived(uint8_t* data, uint8_t len);
4749
void handleRxData(uint8_t* data, uint8_t len);

src/utility/HCITransport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class HCITransportInterface {
3434
virtual int read() = 0;
3535

3636
virtual size_t write(const uint8_t* data, size_t length) = 0;
37+
38+
virtual void setLPMode(bool status);
3739
};
3840

3941
extern HCITransportInterface& HCITransport;

0 commit comments

Comments
 (0)