From 29f0c4788ceecabd9c3cff8f02b6033f4c284201 Mon Sep 17 00:00:00 2001 From: Filip Strajnar Date: Wed, 25 Sep 2024 19:46:55 +0200 Subject: [PATCH] Added endpoints that set pin to high and low. --- .../Controllers/GpioController.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Proculite.GpioRest/Controllers/GpioController.cs b/Proculite.GpioRest/Controllers/GpioController.cs index 6a5d14e..2b5455d 100644 --- a/Proculite.GpioRest/Controllers/GpioController.cs +++ b/Proculite.GpioRest/Controllers/GpioController.cs @@ -27,5 +27,23 @@ namespace Proculite.GpioRest.Controllers { return Ok(_gpioService.StateOfAllPins()); } + + [HttpPut("pin-value/high/{pinNumber}")] + public IActionResult SetPinHigh(int pinNumber) + { + if (!ModelState.IsValid) + return BadRequest(); + + return Ok(_gpioService.SetPinHighReturning(pinNumber)); + } + + [HttpPut("pin-value/low/{pinNumber}")] + public IActionResult SetPinLow(int pinNumber) + { + if (!ModelState.IsValid) + return BadRequest(); + + return Ok(_gpioService.SetPinLowReturning(pinNumber)); + } } }