diff --git a/bsp/board/domo/ovl/usr/local/configs/restd/v1-shutters.json b/bsp/board/domo/ovl/usr/local/configs/restd/v1-shutters.json index 8dcfa538..e3f79822 100644 --- a/bsp/board/domo/ovl/usr/local/configs/restd/v1-shutters.json +++ b/bsp/board/domo/ovl/usr/local/configs/restd/v1-shutters.json @@ -41,5 +41,21 @@ "method": "delete" } } + { + "model": "put", + "endpoint": "/v1/shutters/:id/up", + "ubus": { + "path": "domo.shutters.up", + "method": "up" + } + }, + { + "model": "put", + "endpoint": "/v1/shutters/:id/down", + "ubus": { + "path": "domo.shutters.down", + "method": "down" + } + } ] } \ No newline at end of file diff --git a/bsp/board/domo/ovl/usr/local/configs/restd/v1.json b/bsp/board/domo/ovl/usr/local/configs/restd/v1.json index b8a262b5..a433c9de 100644 --- a/bsp/board/domo/ovl/usr/local/configs/restd/v1.json +++ b/bsp/board/domo/ovl/usr/local/configs/restd/v1.json @@ -3,9 +3,9 @@ "resources": [ { "model": "get", - "endpoint": "/v1/device-capabilities", + "endpoint": "/v1/capabilities", "ubus": { - "path": "domo.devices.capabilities", + "path": "domo.capabilities", "method": "list" } } diff --git a/docs/api/.vuepress/config.js b/docs/api/.vuepress/config.js index bffa893e..8e5e21e0 100644 --- a/docs/api/.vuepress/config.js +++ b/docs/api/.vuepress/config.js @@ -6,7 +6,7 @@ module.exports = { sidebar: [ '/', ['/ history', 'History'], - ['/ capabilities', 'Capabilities'], + ['/ device', 'Capabilities'], ] } } diff --git a/docs/api/package.json b/docs/api/package.json index 71ecfe3d..53239896 100644 --- a/docs/api/package.json +++ b/docs/api/package.json @@ -4,3 +4,4 @@ "docs:build": "vuepress build" } } +0 \ No newline at end of file diff --git a/src/prog/domod/builders/cmake/CMakeLists.txt b/src/prog/domod/builders/cmake/CMakeLists.txt index 61ab96c5..baca56bd 100644 --- a/src/prog/domod/builders/cmake/CMakeLists.txt +++ b/src/prog/domod/builders/cmake/CMakeLists.txt @@ -26,11 +26,11 @@ file( ${workspaceRoot}/src/prog/domod/src/devices/shutter.cpp ${workspaceRoot}/src/prog/domod/src/devices/sprinkler.cpp # ubus models - ${workspaceRoot}/src/prog/domod/src/ubus/capabilities_model.cpp - ${workspaceRoot}/src/prog/domod/src/ubus/capabilities_lights_model.cpp - ${workspaceRoot}/src/prog/domod/src/ubus/capabilities_shutters_model.cpp - ${workspaceRoot}/src/prog/domod/src/ubus/capabilities_sprinklers_model.cpp - ${workspaceRoot}/src/prog/domod/src/ubus/sequences_model.cpp + ${workspaceRoot}/src/prog/domod/src/ubus/capabilities-controller.cpp + ${workspaceRoot}/src/prog/domod/src/ubus/lights-controller.cpp + ${workspaceRoot}/src/prog/domod/src/ubus/shutters-controller.cpp + ${workspaceRoot}/src/prog/domod/src/ubus/sprinklers-controller.cpp + ${workspaceRoot}/src/prog/domod/src/ubus/sequences-controller.cpp # timers ${workspaceRoot}/src/prog/domod/src/sequences/sequences-manager.cpp ${workspaceRoot}/src/prog/domod/src/sequences/sequence.cpp diff --git a/src/prog/domod/src/main.cpp b/src/prog/domod/src/main.cpp index 01a18d06..2b351a9b 100644 --- a/src/prog/domod/src/main.cpp +++ b/src/prog/domod/src/main.cpp @@ -40,10 +40,12 @@ extern "C" { #include "sequences/sequences-manager.h" #include "devices/devices-manager.h" -#include "ubus/capabilities_model.h" -#include "ubus/capabilities_lights_model.h" -#include "ubus/capabilities_shutters_model.h" -#include "ubus/capabilities_sprinklers_model.h" +#include "ubus/capabilities-controller.h" +#include "ubus/lights-controller.h" +#include "ubus/shutters-controller.h" +#include "ubus/sprinklers-controller.h" +#include "ubus/sequences-controller.h" + /*-------------------------------- DEFINES ---------------------------------*/ @@ -62,7 +64,6 @@ static struct ubus_context *setup_ubus(void) if (uloop_init() != 0) { - fprintf(stderr, "Failed to init Uloop.\n"); return NULL; } @@ -73,7 +74,6 @@ static struct ubus_context *setup_ubus(void) if (!the_ctx) { - fprintf(stderr, "Failed to connect to ubus\n"); return NULL; } @@ -150,10 +150,11 @@ int main(int argc, char *argv[]) the_sequences_manager.save(); /* Setup the UBus Models. */ - CapabilitiesModel the_capabilities(the_config_path + "./capabilities.json"); - CapabilitiesLightsModel the_cap_lights(&the_devices_manager); - CapabilitiesShuttersModel the_cap_shutters(&the_devices_manager); - CapabilitiesSprinklersModel the_cap_sprinklers(&the_devices_manager); + CapabilitiesController the_capabilities(the_config_path + "./capabilities.json"); + LightsController the_lights(&the_devices_manager); + ShuttersController the_shutters(&the_devices_manager); + SprinklersController the_sprinklers(&the_devices_manager); + SequencesController the_sequences(&the_sequences_manager); /* Setup the Ubus context. */ the_ctx = setup_ubus(); @@ -164,9 +165,10 @@ int main(int argc, char *argv[]) /* Add the UBus to the model exposed. */ ubus_add_object(the_ctx, &the_capabilities); - ubus_add_object(the_ctx, &the_cap_lights); - ubus_add_object(the_ctx, &the_cap_shutters); - ubus_add_object(the_ctx, &the_cap_sprinklers); + ubus_add_object(the_ctx, &the_lights); + ubus_add_object(the_ctx, &the_shutters); + ubus_add_object(the_ctx, &the_sprinklers); + ubus_add_object(the_ctx, &the_sequences); /* Main Event Loop. */ uloop_run(); @@ -176,89 +178,3 @@ int main(int argc, char *argv[]) return the_ret; } - -#if 0 - -#include "ubus/speach_command.h" -#include "ubus/timers.h" - -#include "timers/Timers.h" -#include "devices/Devices.h" - -/*--------------------------------- GLOBALS ---------------------------------*/ - -#define kConfigPath "/usr/local/share/domo/" - -} // SetupUbus. - - -/*! ---------------------------------------------------------------------------- - * @fn main - * - * @brief Main function of Domo Daemon. - */ -int main (void) -{ - int theRet = 0; - std::string theDevicePath, theTimerPath; - struct ubus_context *theCtx = NULL; - - // Create Configs Paths... - - theDevicePath = kConfigPath; - theDevicePath += "/Devices.json"; - - theTimerPath = kConfigPath; - theTimerPath += "/Timers.json"; - - //printf ("DOMO PATH: %s\n", thePath.c_str()); - - Devices theDevices (theDevicePath); - - if (theDevices.load() != 0) { - - return -1; - } - - /* Setup the Timers. */ - Timers theTimers (theTimerPath, &theDevices); - - if (theTimers.load() != 0) { - - return -1; - } - - /* Setup the UBus Models. */ - CapabilitiesModel theCapabilities; - CapabilitiesLightsModel theCapLights (&theDevices); - - - SpeachCommandModel theSpeachCommand (&theDevices); - TimersModel theTimersModel (&theTimers); - - /* Setup the Ubus context. */ - theCtx = setupUbus (); - if (theCtx == NULL) { - - return -1; - } - - - - /* Add the UBus to the model exposed. */ - ubus_add_object (theCtx, &theCapabilities); - ubus_add_object (theCtx, &theCapLights); - - - ubus_add_object (theCtx, &theSpeachCommand); - ubus_add_object (theCtx, &theTimersModel); - - /* Main Event Loop. */ - uloop_run (); - - ubus_free (theCtx); - uloop_done (); - - return theRet; -} -#endif \ No newline at end of file diff --git a/src/prog/domod/src/ubus/capabilities_model.cpp b/src/prog/domod/src/ubus/capabilities-controller.cpp similarity index 72% rename from src/prog/domod/src/ubus/capabilities_model.cpp rename to src/prog/domod/src/ubus/capabilities-controller.cpp index e6b72932..6f971609 100644 --- a/src/prog/domod/src/ubus/capabilities_model.cpp +++ b/src/prog/domod/src/ubus/capabilities-controller.cpp @@ -1,5 +1,5 @@ /*! - * capabilities.cpp + * devices-capabilities.cpp * * Copyright (c) 2015-2018, NADAL Jean-Baptiste. All rights reserved. * @@ -33,43 +33,43 @@ extern "C" { #include } -#include "capabilities_model.h" +#include "capabilities-controller.h" namespace { using namespace UBus; -static ObjectType gCapabilitiesModelUbus_types( - "capabilities", - Method("get", UBUS_CPP(CapabilitiesModel, get))); +static ObjectType gCapabilitiesControllerUbus_types( + "CapabilitiesController", + Method("list", UBUS_CPP(CapabilitiesController, list))); } /*! ---------------------------------------------------------------------------- - * @fn CapabilitiesModel + * @fn CapabilitiesController * - * @brief Constructor of the UBus Mixer Volume. + * @brief Constructor of the Device Capabilities controller. */ -CapabilitiesModel::CapabilitiesModel(const std::string &a_capability_file) : UBusObject(gCapabilitiesModelUbus_types, "domo.capabilities"), +CapabilitiesController::CapabilitiesController(const std::string &a_capability_file) : UBusObject(gCapabilitiesControllerUbus_types, "domo.capabilities"), m_capability_file(a_capability_file) { } /*! ---------------------------------------------------------------------------- - * @fn ~CapabilitiesModel + * @fn ~CapabilitiesController * - * @brief Destructor of the UBus Mixer Volume. + * @brief Destructor of the Device Capabilities controller. */ -CapabilitiesModel::~CapabilitiesModel(void) +CapabilitiesController::~CapabilitiesController(void) { } /*! ---------------------------------------------------------------------------- - * @fn get + * @fn list * * @brief Get the List of the Capabilities. */ -int CapabilitiesModel::get(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *) +int CapabilitiesController::list(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *) { int the_result; struct blob_buf the_buf = {0}; diff --git a/src/prog/domod/src/ubus/capabilities_model.h b/src/prog/domod/src/ubus/capabilities-controller.h similarity index 76% rename from src/prog/domod/src/ubus/capabilities_model.h rename to src/prog/domod/src/ubus/capabilities-controller.h index adfb4c6d..aeeb9a55 100644 --- a/src/prog/domod/src/ubus/capabilities_model.h +++ b/src/prog/domod/src/ubus/capabilities-controller.h @@ -1,5 +1,5 @@ /*! - * capabilities.h + * capabilities-controller.h * * Copyright (c) 2015-2018, NADAL Jean-Baptiste. All rights reserved. * @@ -23,8 +23,8 @@ * */ -#ifndef _UBUS_CAPABILITIES_MODEL_H -#define _UBUS_CAPABILITIES_MODEL_H +#ifndef _UBUS_CAPABILITIES_CONTROLLER_H +#define _UBUS_CAPABILITIES_CONTROLLER_H /*------------------------------- INCLUDES ----------------------------------*/ @@ -37,16 +37,16 @@ /*--------------------------------- CLASS ----------------------------------*/ -class CapabilitiesModel : public UBusObject +class CapabilitiesController : public UBusObject { public: - CapabilitiesModel(const std::string &a_capability_file); - ~CapabilitiesModel(void); + CapabilitiesController(const std::string &a_capability_file); + ~CapabilitiesController(void); - int get(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int list(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); private: std::string m_capability_file; }; -#endif /* _UBUS_CAPABILITIES_MODEL_H */ +#endif /* _UBUS_CAPABILITIES_CONTROLLER_H */ diff --git a/src/prog/domod/src/ubus/capabilities_shutters_model.cpp b/src/prog/domod/src/ubus/capabilities_shutters_model.cpp deleted file mode 100644 index 30ac4d8f..00000000 --- a/src/prog/domod/src/ubus/capabilities_shutters_model.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/*! - * capabilities_shutters.cpp - * - * Copyright (c) 2015-2018, NADAL Jean-Baptiste. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - * - * @Author: NADAL Jean-Baptiste - * @Date: 24/03/2015 - * - */ - -/*-------------------------------- INCLUDES ---------------------------------*/ - -extern "C" { -#include -} - -#include - -#include "devices/devices-manager.h" - -#include "domo.h" - -#include "capabilities_shutters_model.h" - -namespace -{ - -using namespace UBus; - -static ObjectType gCapabilitiesShuttersModelUbus_types( - "shutters", - Method("get", UBUS_CPP(CapabilitiesShuttersModel, get)), - Method("delete", UBUS_CPP(CapabilitiesShuttersModel, del)), - Method("put", UBUS_CPP(CapabilitiesShuttersModel, put)), - Method("post", UBUS_CPP(CapabilitiesShuttersModel, post)), - - Method("open", UBUS_CPP(CapabilitiesShuttersModel, open)), - Method("close", UBUS_CPP(CapabilitiesShuttersModel, close)), - - Method("up", UBUS_CPP(CapabilitiesShuttersModel, up)), - Method("down", UBUS_CPP(CapabilitiesShuttersModel, down)), - - Method("position", UBUS_CPP(CapabilitiesShuttersModel, position))); -} - -/*! ---------------------------------------------------------------------------- - * @fn CapabilitiesShuttersModel - * - * @brief Constructor of the UBus Mixer Volume. - */ -CapabilitiesShuttersModel::CapabilitiesShuttersModel(DevicesManager *a_device_manager) : UBusObject(gCapabilitiesShuttersModelUbus_types, "domo.capabilities.shutters"), - m_devices_manager(a_device_manager) -{ -} - -/*! ---------------------------------------------------------------------------- - * @fn ~CapabilitiesShuttersModel - * - * @brief Destructor of the UBus Mixer Volume. - */ -CapabilitiesShuttersModel::~CapabilitiesShuttersModel(void) -{ -} - -/*! ---------------------------------------------------------------------------- - * @fn get - * - * @brief Get the List of the Capabilities. - */ -int CapabilitiesShuttersModel::get(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *) -{ - int the_result; - struct blob_buf the_buf = {0}; - - blob_buf_init(&the_buf, 0); - - blobmsg_add_json_from_string(&the_buf, m_devices_manager->get(kShutterEntry).c_str()); - - the_result = ubus_send_reply(a_ctx, a_req, the_buf.head); - - blob_buf_free(&the_buf); - - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn del - * - * @brief Get the List of the Capabilities. - */ -int CapabilitiesShuttersModel::del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) -{ - int the_result = 0; - - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn put - * - * @brief Get the List of the Capabilities. - */ -int CapabilitiesShuttersModel::put(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) -{ - int the_result = 0; - - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn post - * - * @brief Get the List of the Capabilities. - */ -int CapabilitiesShuttersModel::post(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) -{ - int the_result = 0; - - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn open - * - * @brief Open the Shutter - */ -int CapabilitiesShuttersModel::open(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) -{ - int the_result = 0; - printf("Open the Shutter\n"); - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn close - * - * @brief Get the List of the Capabilities. - */ -int CapabilitiesShuttersModel::close(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) -{ - int the_result = 0; - printf("Close the Shutter\n"); - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn up - * - * @brief Get the List of the Capabilities. - */ -int CapabilitiesShuttersModel::up(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) -{ - int the_result = 0; - printf("Up the Shutter\n"); - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn down - * - * @brief Get the List of the Capabilities. - */ -int CapabilitiesShuttersModel::down(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) -{ - int the_result = 0; - printf("Down the Shutter\n"); - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn position - * - * @brief Get the List of the Capabilities. - */ -int CapabilitiesShuttersModel::position(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) -{ - int the_result = 0; - printf("Position the Shutter\n"); - return the_result; -} diff --git a/src/prog/domod/src/ubus/capabilities_lights_model.cpp b/src/prog/domod/src/ubus/lights-controller.cpp similarity index 62% rename from src/prog/domod/src/ubus/capabilities_lights_model.cpp rename to src/prog/domod/src/ubus/lights-controller.cpp index 80c188d1..37c1c83e 100644 --- a/src/prog/domod/src/ubus/capabilities_lights_model.cpp +++ b/src/prog/domod/src/ubus/lights-controller.cpp @@ -35,49 +35,64 @@ extern "C" { #include "domo.h" -#include "capabilities_lights_model.h" +#include "lights-controller.h" namespace { using namespace UBus; -static ObjectType gCapabilitiesLightsUbus_types( - "lights", - Method("get", UBUS_CPP(CapabilitiesLightsModel, get)), - Method("delete", UBUS_CPP(CapabilitiesLightsModel, del)), - Method("put", UBUS_CPP(CapabilitiesLightsModel, put)), - Method("post", UBUS_CPP(CapabilitiesLightsModel, post))); +static ObjectType gLightsControllerUbus_types( + "lightsController", + Method("create", UBUS_CPP(LightsController, create)), + Method("list", UBUS_CPP(LightsController, list)), + Method("read", UBUS_CPP(LightsController, read), Int32Arg("id")), + Method("update", UBUS_CPP(LightsController, update), Int32Arg("id")), + Method("delete", UBUS_CPP(LightsController, del), Int32Arg("id")) +); } /*! ---------------------------------------------------------------------------- - * @fn CapabilitiesLightsModel + * @fn LightsController * - * @brief Constructor of the UBus Mixer Volume. + * @brief Constructor of the Lights Controller. */ -CapabilitiesLightsModel::CapabilitiesLightsModel(DevicesManager *a_device_manager) : UBusObject(gCapabilitiesLightsUbus_types, "domo.capabilities.lights"), +LightsController::LightsController(DevicesManager *a_device_manager) : UBusObject(gLightsControllerUbus_types, "domo.lights"), m_devices_manager(a_device_manager) { } /*! ---------------------------------------------------------------------------- - * @fn ~CapabilitiesLightsModel + * @fn ~LightsController * - * @brief Destructor of the UBus Mixer Volume. + * @brief Destructor of the Lights Controller. */ -CapabilitiesLightsModel::~CapabilitiesLightsModel(void) +LightsController::~LightsController(void) { } + /*! ---------------------------------------------------------------------------- - * @fn get + * @fn create * - * @brief get the List of the Capabilities. + * @brief Create a new Sequence Object. */ -int CapabilitiesLightsModel::get(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *a_msg) +int LightsController::create(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn list + * + * @brief List all the sequences + */ +int LightsController::list(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *) { int the_result; struct blob_buf the_buf = {0}; + printf("%s\n", __PRETTY_FUNCTION__); blob_buf_init(&the_buf, 0); @@ -91,41 +106,28 @@ int CapabilitiesLightsModel::get(struct ubus_context *a_ctx, struct ubus_request } /*! ---------------------------------------------------------------------------- - * @fn del + * @fn read * - * @brief Get the List of the Capabilities. + * @brief Read a specific sequence object. */ -int CapabilitiesLightsModel::del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +int LightsController::read(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) { - int the_result = 0; - - return the_result; + printf("%s\n", __PRETTY_FUNCTION__); + return 0; } /*! ---------------------------------------------------------------------------- - * @fn put + * @fn update * - * @brief Get the List of the Capabilities. + * @brief Update a specific sequence. */ -int CapabilitiesLightsModel::put(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) -{ - int the_result = 0; - - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn post - * - * @brief Get the List of the Capabilities. - */ -int CapabilitiesLightsModel::post(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *a_msg) +int LightsController::update(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *a_msg) { int the_result = 0; struct blob_buf the_buf = {0}; char *the_string; struct json_object *the_root_node, *the_output_node; - fprintf(stderr, "CapabilitiesLights::Post \n"); + printf("%s\n", __PRETTY_FUNCTION__); the_string = blobmsg_format_json(a_msg, true); @@ -161,3 +163,14 @@ int CapabilitiesLightsModel::post(struct ubus_context *a_ctx, struct ubus_reques return the_result; } + +/*! ---------------------------------------------------------------------------- + * @fn del + * + * @brief delete a specific sequence. + */ +int LightsController::del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} diff --git a/src/prog/domod/src/ubus/capabilities_lights_model.h b/src/prog/domod/src/ubus/lights-controller.h similarity index 70% rename from src/prog/domod/src/ubus/capabilities_lights_model.h rename to src/prog/domod/src/ubus/lights-controller.h index 5b8edba9..69a99194 100644 --- a/src/prog/domod/src/ubus/capabilities_lights_model.h +++ b/src/prog/domod/src/ubus/lights-controller.h @@ -1,5 +1,5 @@ /*! - * capabilities_lights.h + * lights-controller.h * * Copyright (c) 2015-2018, NADAL Jean-Baptiste. All rights reserved. * @@ -23,8 +23,8 @@ * */ -#ifndef _UBUS_CAPABILITIES_LIGHTS_MODEL_H -#define _UBUS_CAPABILITIES_LIGHTS_MODEL_H +#ifndef _UBUS_LIGHTS_CONTROLLER_H +#define _UBUS_LIGHTS_CONTROLLER_H /*------------------------------- INCLUDES ----------------------------------*/ @@ -38,20 +38,21 @@ class DevicesManager; /*--------------------------------- CLASS ----------------------------------*/ -class CapabilitiesLightsModel : public UBusObject +class LightsController : public UBusObject { public: - CapabilitiesLightsModel(DevicesManager *a_device_manager); - ~CapabilitiesLightsModel(void); + LightsController(DevicesManager *a_device_manager); + ~LightsController(void); - int get(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int create(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int list(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int read(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int update(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); int del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); - int put(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); - int post(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); private: DevicesManager *m_devices_manager; }; -#endif /* _UBUS_CAPABILITIES_LIGHTS_MODEL_H */ +#endif /* _UBUS_LIGHTS_CONTROLLER_H */ diff --git a/src/prog/domod/src/ubus/sequences-controller.cpp b/src/prog/domod/src/ubus/sequences-controller.cpp new file mode 100644 index 00000000..2cd5ee47 --- /dev/null +++ b/src/prog/domod/src/ubus/sequences-controller.cpp @@ -0,0 +1,128 @@ +/*! + * sequences-controller.cpp + * + * Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + * + * @Author: NADAL Jean-Baptiste + * @Date: 02/07/2016 + * + */ + +/*-------------------------------- INCLUDES ---------------------------------*/ + +#include + +extern "C" { +#include +} + +#include + +#include "sequences/sequences-manager.h" + +#include "sequences-controller.h" + +namespace +{ + +using namespace UBus; + +static ObjectType gSequencesControllerUbus_types( + "SequencesController", + Method("create", UBUS_CPP(SequencesController, create)), + Method("list", UBUS_CPP(SequencesController, list)), + Method("read", UBUS_CPP(SequencesController, read), Int32Arg("id")), + Method("update", UBUS_CPP(SequencesController, update), Int32Arg("id")), + Method("delete", UBUS_CPP(SequencesController, del), Int32Arg("id")) + ); +} + +/*! ---------------------------------------------------------------------------- + * @fn SequencesController + * + * @brief Constructor of the Sequence controller. + */ +SequencesController::SequencesController(SequencesManager *a_sequences_manager) : + UBusObject(gSequencesControllerUbus_types, "domo.sequences"), + m_sequences_manager(a_sequences_manager) +{ +} + +/*! ---------------------------------------------------------------------------- + * @fn ~SequencesController + * + * @brief Destructor of the Sequence controller. + */ +SequencesController::~SequencesController(void) +{ +} + +/*! ---------------------------------------------------------------------------- + * @fn create + * + * @brief Create a new Sequence Object. + */ +int SequencesController::create(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn list + * + * @brief List all the sequences + */ +int SequencesController::list(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn read + * + * @brief Read a specific sequence object. + */ +int SequencesController::read(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn update + * + * @brief Update a specific sequence. + */ +int SequencesController::update(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn del + * + * @brief delete a specific sequence. + */ +int SequencesController::del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} diff --git a/src/prog/domod/src/ubus/sequences_model.h b/src/prog/domod/src/ubus/sequences-controller.h similarity index 69% rename from src/prog/domod/src/ubus/sequences_model.h rename to src/prog/domod/src/ubus/sequences-controller.h index f7b02a1e..a0ae0802 100644 --- a/src/prog/domod/src/ubus/sequences_model.h +++ b/src/prog/domod/src/ubus/sequences-controller.h @@ -1,5 +1,5 @@ /*! - * timers.h + * sequences-controller.h * * Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved. * @@ -23,8 +23,8 @@ * */ -#ifndef _UBUS_SEQUENCES_H -#define _UBUS_SEQUENCES_H +#ifndef _UBUS_SEQUENCES_CONTROLLER_H +#define _UBUS_SEQUENCES_CONTROLLER_H /*------------------------------- INCLUDES ----------------------------------*/ @@ -38,18 +38,21 @@ class SequencesManager; /*--------------------------------- CLASS ----------------------------------*/ -class SequencesModel : public UBusObject +class SequencesController : public UBusObject { public: - SequencesModel(SequencesManager *a_sequences_manager); - ~SequencesModel(void); + SequencesController(SequencesManager *a_sequences_manager); + ~SequencesController(void); - int get(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int create(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int list(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int read(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int update(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); int del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); private: SequencesManager *m_sequences_manager; }; -#endif /* _UBUS_SEQUENCES_H */ +#endif /* _UBUS_SEQUENCES_CONTROLLER_H */ diff --git a/src/prog/domod/src/ubus/sequences_model.cpp b/src/prog/domod/src/ubus/sequences_model.cpp deleted file mode 100644 index 6cda7aee..00000000 --- a/src/prog/domod/src/ubus/sequences_model.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/*! - * SequencesModel.cpp - * - * Copyright (c) 2016-2018, NADAL Jean-Baptiste. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - * - * @Author: NADAL Jean-Baptiste - * @Date: 02/07/2016 - * - */ - -/*-------------------------------- INCLUDES ---------------------------------*/ - -#include - -extern "C" { -#include -} - -#include - -#include "sequences/sequences-manager.h" - -#include "sequences_model.h" - -namespace -{ - -using namespace UBus; - -static ObjectType gSequencesModelUbus_types( - "SequencesModel", - Method("get", UBUS_CPP(SequencesModel, get)), - Method("delete", UBUS_CPP(SequencesModel, del))); -} - -/*! ---------------------------------------------------------------------------- - * @fn SequencesModel - * - * @brief Constructor of the Timer Objects. - */ -SequencesModel::SequencesModel(SequencesManager *a_sequences_manager) : - UBusObject(gSequencesModelUbus_types, "domo.sequences"), - m_sequences_manager(a_sequences_manager) -{ -} - -/*! ---------------------------------------------------------------------------- - * @fn ~SequencesModel - * - * @brief Destructor of the Timer Objects. - */ -SequencesModel::~SequencesModel(void) -{ -} - -/*! ---------------------------------------------------------------------------- - * @fn get - * - * @brief Get the List of timer objects. - */ -int SequencesModel::get(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *a_msg) -{ - int the_result = 0; -#if 0 - int theID = -1; - Json::Reader theReader; - Json::StyledWriter theWriter; - Json::Value theRoot; - struct blob_buf theBuf = {0}; - char *theString = blobmsg_format_json (aMsg, true); - - printf ("Get the TimersModel.\n"); - - if (!theReader.parse (theString, theRoot)) { - - fprintf (stderr, "Failed parse the parameters.\n"); - return UBUS_STATUS_INVALID_ARGUMENT; - } - - theID = theRoot["id"].asInt(); - - blob_buf_init (&theBuf, 0); - - if (theID == 0) - blobmsg_add_json_from_string (&theBuf, theWriter.write(mTimers->to_json()).c_str()); - else { - printf ("we want a specific id :%d\n", theID); - blobmsg_add_json_from_string (&theBuf, theWriter.write(mTimers->get(theID).to_json()).c_str()); - } - - theResult = ubus_send_reply (aCtx, aReq, theBuf.head); - - blob_buf_free (&theBuf); -#endif - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn del - * - * @brief Delete a Timer Object. - */ -int SequencesModel::del(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *a_msg) -{ - int the_result = 0; -#if 0 - Json::Reader theReader; - Json::Value theRoot; - int theID = -1; - char *theString = blobmsg_format_json (aMsg, true); - - if (!theReader.parse (theString, theRoot)) { - - fprintf (stderr, "Failed parse the parameters.\n"); - return UBUS_STATUS_INVALID_ARGUMENT; - } - - theID = theRoot["id"].asInt(); - - printf ("try to delete id: %d\n", theID); - - theResult = mTimers->remove (theID); - - if (theResult == 0) { - - printf ("Successfully removed.\n"); - //TODO SAVE and return OK. - } -#endif - return the_result; -} diff --git a/src/prog/domod/src/ubus/shutters-controller.cpp b/src/prog/domod/src/ubus/shutters-controller.cpp new file mode 100644 index 00000000..925c9a96 --- /dev/null +++ b/src/prog/domod/src/ubus/shutters-controller.cpp @@ -0,0 +1,164 @@ +/*! + * shutters-controller.cpp + * + * Copyright (c) 2015-2018, NADAL Jean-Baptiste. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + * + * @Author: NADAL Jean-Baptiste + * @Date: 24/03/2015 + * + */ + +/*-------------------------------- INCLUDES ---------------------------------*/ + +extern "C" { +#include +} + +#include + +#include "devices/devices-manager.h" + +#include "domo.h" + +#include "shutters-controller.h" + +namespace +{ + +using namespace UBus; + +static ObjectType gShuttersControllerUbus_types( + "ShuttersController", + Method("create", UBUS_CPP(ShuttersController, create)), + Method("list", UBUS_CPP(ShuttersController, list)), + Method("read", UBUS_CPP(ShuttersController, read), Int32Arg("id")), + Method("update", UBUS_CPP(ShuttersController, update), Int32Arg("id")), + Method("delete", UBUS_CPP(ShuttersController, del), Int32Arg("id")), + + Method("up", UBUS_CPP(ShuttersController, up)), + Method("down", UBUS_CPP(ShuttersController, down)) +); +} + +/*! ---------------------------------------------------------------------------- + * @fn ShuttersController + * + * @brief Constructor of the UBus Mixer Volume. + */ +ShuttersController::ShuttersController(DevicesManager *a_device_manager) : UBusObject(gShuttersControllerUbus_types, "domo.shutters"), + m_devices_manager(a_device_manager) +{ +} + +/*! ---------------------------------------------------------------------------- + * @fn ~ShuttersController + * + * @brief Destructor of the UBus Mixer Volume. + */ +ShuttersController::~ShuttersController(void) +{ +} + + +/*! ---------------------------------------------------------------------------- + * @fn create + * + * @brief Create a new Sequence Object. + */ +int ShuttersController::create(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn list + * + * @brief List all the sequences + */ +int ShuttersController::list(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *) +{ + int the_result; + struct blob_buf the_buf = {0}; + printf("%s\n", __PRETTY_FUNCTION__); + + blob_buf_init(&the_buf, 0); + + blobmsg_add_json_from_string(&the_buf, m_devices_manager->get(kShutterEntry).c_str()); + + the_result = ubus_send_reply(a_ctx, a_req, the_buf.head); + + blob_buf_free(&the_buf); + + return the_result; +} + +/*! ---------------------------------------------------------------------------- + * @fn read + * + * @brief Read a specific sequence object. + */ +int ShuttersController::read(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn update + * + * @brief Update a specific sequence. + */ +int ShuttersController::update(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn del + * + * @brief delete a specific sequence. + */ +int ShuttersController::del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn up + * + * @brief action up the specific shutter. + */ +int ShuttersController::up(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn down + * + * @brief action down the specific shutter. + */ +int ShuttersController::down(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} diff --git a/src/prog/domod/src/ubus/capabilities_shutters_model.h b/src/prog/domod/src/ubus/shutters-controller.h similarity index 68% rename from src/prog/domod/src/ubus/capabilities_shutters_model.h rename to src/prog/domod/src/ubus/shutters-controller.h index a8bab718..91e002aa 100644 --- a/src/prog/domod/src/ubus/capabilities_shutters_model.h +++ b/src/prog/domod/src/ubus/shutters-controller.h @@ -1,5 +1,5 @@ /*! - * capabilities_shutters + * shutters-controller.h * * Copyright (c) 2015-2018, NADAL Jean-Baptiste. All rights reserved. * @@ -23,8 +23,8 @@ * */ -#ifndef _UBUS_CAPABILITIES_SHUTTERS_MODEL_H -#define _UBUS_CAPABILITIES_SHUTTERS_MODEL_H +#ifndef _UBUS_SHUTTERS_MODEL_H +#define _UBUS_SHUTTERS_MODEL_H /*------------------------------- INCLUDES ----------------------------------*/ @@ -38,25 +38,21 @@ class DevicesManager; /*--------------------------------- CLASS ----------------------------------*/ -class CapabilitiesShuttersModel : public UBusObject +class ShuttersController : public UBusObject { public: - CapabilitiesShuttersModel(DevicesManager *a_device_manager); - ~CapabilitiesShuttersModel(void); + ShuttersController(DevicesManager *a_device_manager); + ~ShuttersController(void); - int get(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int create(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int list(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int read(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int update(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); int del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); - int put(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); - int post(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); - - int open(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); - int close(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); int up(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); int down(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); - int position(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); - private: DevicesManager *m_devices_manager; }; diff --git a/src/prog/domod/src/ubus/capabilities_sprinklers_model.cpp b/src/prog/domod/src/ubus/sprinklers-controller.cpp similarity index 53% rename from src/prog/domod/src/ubus/capabilities_sprinklers_model.cpp rename to src/prog/domod/src/ubus/sprinklers-controller.cpp index 4a60296d..91e136a8 100644 --- a/src/prog/domod/src/ubus/capabilities_sprinklers_model.cpp +++ b/src/prog/domod/src/ubus/sprinklers-controller.cpp @@ -1,5 +1,5 @@ /*! - * capabilities_sprinklers.cpp + * sprinklers-controller.cpp * * Copyright (c) 2015-2018, NADAL Jean-Baptiste. All rights reserved. * @@ -37,49 +37,65 @@ extern "C" { #include "domo.h" -#include "capabilities_sprinklers_model.h" +#include "sprinklers-controller.h" namespace { using namespace UBus; -static ObjectType gCapabilitiesSprinklersModelUbus_types( - "sprinklers", - Method("get", UBUS_CPP(CapabilitiesSprinklersModel, get)), - Method("delete", UBUS_CPP(CapabilitiesSprinklersModel, del)), - Method("put", UBUS_CPP(CapabilitiesSprinklersModel, put)), - Method("post", UBUS_CPP(CapabilitiesSprinklersModel, post))); +static ObjectType gSprinklersControllerUbus_types( + "SprinklersController", + Method("create", UBUS_CPP(SprinklersController, create)), + Method("list", UBUS_CPP(SprinklersController, list)), + Method("read", UBUS_CPP(SprinklersController, read), Int32Arg("id")), + Method("update", UBUS_CPP(SprinklersController, update), Int32Arg("id")), + Method("delete", UBUS_CPP(SprinklersController, del), Int32Arg("id")), + Method("open", UBUS_CPP(SprinklersController, open), Int32Arg("id")), + Method("close", UBUS_CPP(SprinklersController, close), Int32Arg("id")) + ); } /*! ---------------------------------------------------------------------------- - * @fn CapabilitiesSprinkler + * @fn SprinklersController * - * @brief Constructor of the UBus Mixer Volume. + * @brief Constructor of the UBus Sprinkler controller. */ -CapabilitiesSprinklersModel::CapabilitiesSprinklersModel(DevicesManager *a_device_manager) : UBusObject(gCapabilitiesSprinklersModelUbus_types, "domo.capabilities.sprinklers"), +SprinklersController::SprinklersController(DevicesManager *a_device_manager) : UBusObject(gSprinklersControllerUbus_types, "domo.sprinklers"), m_devices_manager(a_device_manager) { } /*! ---------------------------------------------------------------------------- - * @fn ~CapabilitiesSprinklersModel + * @fn ~SprinklersController * - * @brief Destructor of the UBus Mixer Volume. + * @brief Destructor of the UBus Sprinkler controller. */ -CapabilitiesSprinklersModel::~CapabilitiesSprinklersModel(void) +SprinklersController::~SprinklersController(void) { } /*! ---------------------------------------------------------------------------- - * @fn get + * @fn create * - * @brief Get the List of the Capabilities. + * @brief Create a new sprinkler. */ -int CapabilitiesSprinklersModel::get(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *) +int SprinklersController::create(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn list + * + * @brief List all the sequences + */ +int SprinklersController::list(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *) { int the_result; struct blob_buf the_buf = {0}; + printf("%s\n", __PRETTY_FUNCTION__); blob_buf_init(&the_buf, 0); @@ -93,41 +109,28 @@ int CapabilitiesSprinklersModel::get(struct ubus_context *a_ctx, struct ubus_req } /*! ---------------------------------------------------------------------------- - * @fn del + * @fn read * - * @brief Get the List of the Capabilities. + * @brief Read a specific sequence object. */ -int CapabilitiesSprinklersModel::del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +int SprinklersController::read(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) { - int the_result = 0; - - return the_result; + printf("%s\n", __PRETTY_FUNCTION__); + return 0; } /*! ---------------------------------------------------------------------------- - * @fn put + * @fn update * - * @brief Get the List of the Capabilities. + * @brief Update a specific sequence. */ -int CapabilitiesSprinklersModel::put(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) -{ - int the_result = 0; - - return the_result; -} - -/*! ---------------------------------------------------------------------------- - * @fn post - * - * @brief Get the List of the Capabilities. - */ -int CapabilitiesSprinklersModel::post(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *a_msg) +int SprinklersController::update(struct ubus_context *a_ctx, struct ubus_request_data *a_req, struct blob_attr *a_msg) { int the_result = 0; struct blob_buf the_buf = {0}; char *the_string; struct json_object *the_root_node, *the_output_node; - fprintf(stderr, "CapabilitiesSprinklersModel::Post \n"); + printf("%s\n", __PRETTY_FUNCTION__); the_string = blobmsg_format_json(a_msg, true); @@ -163,3 +166,36 @@ int CapabilitiesSprinklersModel::post(struct ubus_context *a_ctx, struct ubus_re return the_result; } + +/*! ---------------------------------------------------------------------------- + * @fn del + * + * @brief delete a specific sequence. + */ +int SprinklersController::del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn open + * + * @brief open a specific sprinkler. + */ +int SprinklersController::open(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} + +/*! ---------------------------------------------------------------------------- + * @fn close + * + * @brief close a specific sprinkler. + */ +int SprinklersController::close(struct ubus_context *, struct ubus_request_data *, struct blob_attr *) +{ + printf("%s\n", __PRETTY_FUNCTION__); + return 0; +} diff --git a/src/prog/domod/src/ubus/capabilities_sprinklers_model.h b/src/prog/domod/src/ubus/sprinklers-controller.h similarity index 64% rename from src/prog/domod/src/ubus/capabilities_sprinklers_model.h rename to src/prog/domod/src/ubus/sprinklers-controller.h index 5ef11857..ebea522c 100644 --- a/src/prog/domod/src/ubus/capabilities_sprinklers_model.h +++ b/src/prog/domod/src/ubus/sprinklers-controller.h @@ -1,5 +1,5 @@ /*! - * capabilities_sprinklers.h + * sprinklers-controller.h * * Copyright (c) 2015-2018, NADAL Jean-Baptiste. All rights reserved. * @@ -23,8 +23,8 @@ * */ -#ifndef _UBUS_CAPABILITIES_SPRINKLERS_MODEL_H -#define _UBUS_CAPABILITIES_SPRINKLERS_MODEL_H +#ifndef _UBUS_SPRINKLERS_CONTROLLER_H +#define _UBUS_SPRINKLERS_CONTROLLER_H /*------------------------------- INCLUDES ----------------------------------*/ @@ -38,20 +38,24 @@ class DevicesManager; /*--------------------------------- CLASS ----------------------------------*/ -class CapabilitiesSprinklersModel : public UBusObject +class SprinklersController : public UBusObject { public: - CapabilitiesSprinklersModel(DevicesManager *a_device_manager); - ~CapabilitiesSprinklersModel(void); + SprinklersController(DevicesManager *a_device_manager); + ~SprinklersController(void); - int get(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int create(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int list(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int read(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int update(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); int del(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); - int put(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); - int post(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int open(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + int close(struct ubus_context *, struct ubus_request_data *, struct blob_attr *); + private: DevicesManager *m_devices_manager; }; -#endif /* _UBUS_CAPABILITIES_SPRINKLERS_MODEL_H */ +#endif /* _UBUS_SPRINKLERS_CONTROLLER_H */