/** * Write a pin value * <pre class="PUT"> PUT [url]/gpio/write/:pin/:value/</pre> * * @param String - pin number * @param String - value * * @example * No POST Body * * @return JSON - **Object** success message * * @since 2016-02-05 * @author Wesley Dekkers <*****@*****.**> * @todo check if values are set correctly * @todo check if pin exists **/ public function send($id) { try { $config = \Rhonda\Config::get('config'); $send = new \Models\RFID(); $send->id = $id; $send->path = $config->RFID_PATH; $send->send(); echo \Rhonda\Success::create(); } catch (\Exception $e) { echo \Rhonda\Error::handle($e); } }
/** * Set a pin mode * <pre class="PUT"> PUT [url]/gpio/mode/:pin/:mode/</pre> * * @param String - pin number (wPi pin) * @param String - mode IN/OUT (or others) * * @example * No POST Body * * @return JSON - **Object** success message * * @since 2016-02-05 * @author Wesley Dekkers <*****@*****.**> * @todo check if modes are set correctly * @todo check if pin exists **/ public function mode($pin, $mode) { try { if (!is_numeric($pin)) { throw new \Exception("Pin should be numeric", 1); } $mode_gpio = new \Models\GPIO(); $mode_gpio->pin = $pin; $mode_gpio->mode = $mode; $mode_gpio->mode(); echo \Rhonda\Success::create(); } catch (\Exception $e) { echo \Rhonda\Error::handle($e); } }