Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

add method to handle nrf power

Geo019b07326ce3
diff --git a/src/Services/Rf24Service.cpp b/src/Services/Rf24Service.cpp
index 06cdf81e..b68a95d7 100644
--- a/src/Services/Rf24Service.cpp
+++ b/src/Services/Rf24Service.cpp
@@ -47,12 +47,38 @@ uint8_t Rf24Service::getChannel() {
return 0;
}
+void Rf24Service::powerUp() {
+ if (isInitialized) {
+ radio_->powerUp();
+ }
+}
+
+void Rf24Service::powerDown(bool hard) {
+ if (!isInitialized) {
+ return;
+ }
+
+ if (hard) {
+ radio_->powerDown();
+ return;
+ }
+
+ radio_->stopConstCarrier();
+}
+
void Rf24Service::setPowerLevel(rf24_pa_dbm_e level) {
if (isInitialized) {
radio_->setPALevel(level);
}
}
+void Rf24Service::setPowerMax() {
+ if (isInitialized) {
+ radio_->setPALevel(RF24_PA_MAX);
+ radio_->startConstCarrier(RF24_PA_MAX, 45);
+ }
+}
+
void Rf24Service::startListening() {
if (isInitialized) {
radio_->startListening();
@@ -91,9 +117,7 @@ void Rf24Service::openReadingPipe(uint8_t number, uint64_t address) {
bool Rf24Service::send(const void* buf, uint8_t len) {
if (!isInitialized) return false;
- radio_->stopListening();
bool ok = radio_->write(buf, len);
- radio_->startListening();
return ok;
}
diff --git a/src/Services/Rf24Service.h b/src/Services/Rf24Service.h
index 99a0bddf..84b012da 100644
--- a/src/Services/Rf24Service.h
+++ b/src/Services/Rf24Service.h
@@ -22,11 +22,12 @@ public:
// Base
void setChannel(uint8_t channel); // 0..125
uint8_t getChannel();
- void setPowerLevel(rf24_pa_dbm_e level); // RF24_PA_MIN .. RF24_PA_MAX
void setDataRate(rf24_datarate_e rate); // RF24_250KBPS, RF24_1MBPS, RF24_2MBPS
void setCrcLength(rf24_crclength_e length); // RF24_CRC_DISABLED, RF24_CRC_8, RF24_CRC_16
void powerUp();
- void powerDown();
+ void powerDown(bool hard = false);
+ void setPowerLevel(rf24_pa_dbm_e level); // RF24_PA_MIN .. RF24_PA_MAX
+ void setPowerMax();
// Communication
void openWritingPipe(const uint64_t address);