readpin implementation
Some checks failed
Build and deploy Docs site to GitHub Pages / github-pages (push) Has been cancelled
PR Build Check / build (Heltec_v3_companion_radio_ble) (push) Has been cancelled
PR Build Check / build (Heltec_v3_repeater) (push) Has been cancelled
PR Build Check / build (Heltec_v3_room_server) (push) Has been cancelled
PR Build Check / build (LilyGo_Tlora_C6_repeater_) (push) Has been cancelled
PR Build Check / build (PicoW_repeater) (push) Has been cancelled
PR Build Check / build (RAK_4631_companion_radio_ble) (push) Has been cancelled
PR Build Check / build (RAK_4631_repeater) (push) Has been cancelled
PR Build Check / build (RAK_4631_room_server) (push) Has been cancelled
PR Build Check / build (wio-e5-mini_repeater) (push) Has been cancelled

This commit is contained in:
2026-05-12 00:39:27 +02:00
parent 9a1f98fa84
commit 4eed1b377e
3 changed files with 34 additions and 4 deletions

View File

@@ -3,16 +3,16 @@
/* ------------------------------ Config -------------------------------- */
#ifndef LORA_FREQ
#define LORA_FREQ 915.0
#define LORA_FREQ 869.618
#endif
#ifndef LORA_BW
#define LORA_BW 250
#define LORA_BW 62.5
#endif
#ifndef LORA_SF
#define LORA_SF 10
#define LORA_SF 8
#endif
#ifndef LORA_CR
#define LORA_CR 5
#define LORA_CR 8
#endif
#ifndef LORA_TX_POWER
#define LORA_TX_POWER 20
@@ -443,6 +443,14 @@ void SensorMesh::handleCommand(uint32_t sender_timestamp, char* command, char* r
board.setGpio(val);
}
sprintf(reply, "%x", board.getGpio());
} else if (memcmp(command, "readpin ", 8) == 0) {
uint8_t pin = atoi(&command[8]); // Pin-Nummer extrahieren
if (pin < 32) {
bool pin_state = board.readPin(pin); // Zustand des Pins auslesen
sprintf(reply, "%s", pin_state ? "ON" : "OFF");
} else {
strcpy(reply, "Err - invalid pin");
}
} else{
_cli.handleCommand(sender_timestamp, command, reply); // common CLI commands
}

View File

@@ -102,6 +102,9 @@ void setup() {
command[0] = 0;
// Konfiguriere GPIO 2 als Eingang mit Pull-Up
pinMode(2, INPUT_PULLUP);
sensors.begin();
the_mesh.begin(fs);

View File

@@ -48,6 +48,25 @@ public:
#endif
}
// Implement an actual getGpio for ESP32 boards
uint32_t getGpio() override {
uint32_t state = 0;
for (int pin = 0; pin < 32; pin++) {
if (digitalRead(pin) == HIGH) {
state |= (1 << pin);
}
}
return state;
}
// Read the state of a single pin
public:
// Liest den Zustand eines einzelnen Pins (0-31)
bool readPin(uint8_t pin) {
if (pin >= 32) return false; // Ungültiger Pin
return digitalRead(pin) == HIGH;
}
// Temperature from ESP32 MCU
float getMCUTemperature() override {
uint32_t raw = 0;