Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions src/local/BLELocalDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ void BLELocalDevice::noDebug()
HCI.noDebug();
}

void BLELocalDevice::setLowPowerMode(bool status)
{
HCI.leSetLPMode(status);
}

#if !defined(FAKE_BLELOCALDEVICE)
BLELocalDevice BLEObj;
BLELocalDevice& BLE = BLEObj;
Expand Down
3 changes: 3 additions & 0 deletions src/local/BLELocalDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class BLELocalDevice {

virtual void setDisplayCode(void (*displayCode)(uint32_t confirmationCode));
virtual void setBinaryConfirmPairing(bool (*binaryConfirmPairing)());

virtual void setLowPowerMode(bool status);

uint8_t BDaddress[6];

protected:
Expand Down
5 changes: 5 additions & 0 deletions src/utility/HCI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,11 @@ void HCIClass::dumpPkt(const char* prefix, uint8_t plen, uint8_t pdata[])
}
}

void HCIClass::leSetLPMode(bool status)
{
HCITransport.setLPMode(status);
}

#if !defined(FAKE_HCI)
HCIClass HCIObj;
HCIClass& HCI = HCIObj;
Expand Down
2 changes: 2 additions & 0 deletions src/utility/HCI.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class HCIClass {
virtual int leStartResolvingAddresses();
virtual int leReadPeerResolvableAddress(uint8_t peerAddressType, uint8_t* peerIdentityAddress, uint8_t* peerResolvableAddress);

virtual void leSetLPMode(bool status);

virtual void readStoredLKs();
virtual int readStoredLK(uint8_t BD_ADDR[], uint8_t read_all = 0);
virtual void writeLK(uint8_t peerAddress[], uint8_t LK[]);
Expand Down
10 changes: 10 additions & 0 deletions src/utility/HCICordioTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#endif

extern BLE_NAMESPACE::CordioHCIDriver& ble_cordio_get_hci_driver();
extern void ble_cordio_set_lp_mode(bool status);

namespace BLE_NAMESPACE {
struct CordioHCIHook {
Expand All @@ -68,6 +69,10 @@ namespace BLE_NAMESPACE {
static void setDataReceivedHandler(void (*handler)(uint8_t*, uint8_t)) {
getTransportDriver().set_data_received_handler(handler);
}

static void setLowPowerMode(bool status) {
ble_cordio_set_lp_mode(status);
}
};
}

Expand Down Expand Up @@ -309,4 +314,9 @@ void HCICordioTransportClass::onDataReceived(uint8_t* data, uint8_t len)
HCICordioTransport.handleRxData(data, len);
}

void HCICordioTransportClass::setLPMode(bool status)
{
CordioHCIHook::setLowPowerMode(status);
}

#endif
2 changes: 2 additions & 0 deletions src/utility/HCICordioTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class HCICordioTransportClass : public HCITransportInterface {

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

virtual void setLPMode(bool status);

private:
static void onDataReceived(uint8_t* data, uint8_t len);
void handleRxData(uint8_t* data, uint8_t len);
Expand Down
2 changes: 2 additions & 0 deletions src/utility/HCITransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class HCITransportInterface {
virtual int read() = 0;

virtual size_t write(const uint8_t* data, size_t length) = 0;

virtual void setLPMode(bool status);
};

extern HCITransportInterface& HCITransport;
Expand Down
5 changes: 5 additions & 0 deletions src/utility/HCIUartTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ size_t HCIUartTransportClass::write(const uint8_t* data, size_t length)
return result;
}

void HCIUartTransportClass::setLPMode(bool status)
{
(void)status;
}

#if defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_NANO_RP2040_CONNECT)
HCIUartTransportClass HCIUartTransport(SerialHCI, 119600);
#else
Expand Down
2 changes: 2 additions & 0 deletions src/utility/HCIUartTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class HCIUartTransportClass : public HCITransportInterface {

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

virtual void setLPMode(bool status);

private:
HardwareSerial* _uart;
unsigned long _baudrate;
Expand Down
5 changes: 5 additions & 0 deletions src/utility/HCIVirtualTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ size_t HCIVirtualTransportClass::write(const uint8_t* data, size_t length)
return result;
}

void HCIVirtualTransportClass::setLPMode(bool status)
{
(void)status;
}

HCIVirtualTransportClass HCIVirtualTransport;

HCITransportInterface& HCITransport = HCIVirtualTransport;
Expand Down
2 changes: 2 additions & 0 deletions src/utility/HCIVirtualTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ class HCIVirtualTransportClass : public HCITransportInterface {
virtual int read();

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

virtual void setLPMode(bool status);
};
5 changes: 5 additions & 0 deletions src/utility/HCIVirtualTransportAT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ size_t HCIVirtualTransportATClass::write(const uint8_t* data, size_t length)
return 0;
}

void HCIVirtualTransportATClass::setLPMode(bool status)
{
(void)status;
}

HCIVirtualTransportATClass HCIVirtualTransportAT;

HCITransportInterface& HCITransport = HCIVirtualTransportAT;
Expand Down
2 changes: 2 additions & 0 deletions src/utility/HCIVirtualTransportAT.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ class HCIVirtualTransportATClass : public HCITransportInterface {
virtual int read();

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

virtual void setLPMode(bool status);
};