Added an endpoint for all pin values. All pin value endpoints now return PinValueModel.
This commit is contained in:
parent
76f8f4a777
commit
83bba359cb
|
|
@ -19,7 +19,13 @@ namespace Proculite.GpioRest.Controllers
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest();
|
return BadRequest();
|
||||||
|
|
||||||
return Ok(_gpioService.CurrentPinValue(pinNumber).ToString());
|
return Ok(_gpioService.PinValueModelOfPin(pinNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("pin-value")]
|
||||||
|
public IActionResult AllPinValues()
|
||||||
|
{
|
||||||
|
return Ok(_gpioService.StateOfAllPins());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Device.Gpio;
|
using System.Device.Gpio;
|
||||||
|
using Proculite.GpioRest.Models;
|
||||||
|
|
||||||
namespace Proculite.GpioRest.Services
|
namespace Proculite.GpioRest.Services
|
||||||
{
|
{
|
||||||
|
|
@ -47,5 +48,15 @@ namespace Proculite.GpioRest.Services
|
||||||
{
|
{
|
||||||
return _gpioController.Read(pinNumber);
|
return _gpioController.Read(pinNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PinValueModel PinValueModelOfPin(int pinNumber)
|
||||||
|
{
|
||||||
|
return new PinValueModel(pinNumber, _gpioController.Read(pinNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
public PinValueModel[] StateOfAllPins()
|
||||||
|
{
|
||||||
|
return _pins.Select(PinValueModelOfPin).ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue