WIP.
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
{
|
{
|
||||||
"active": true,
|
"active": true,
|
||||||
"id": "Sprinklers/7",
|
"id": "Sprinklers/7",
|
||||||
"start_time": "22:38",
|
"start_time": "15:50",
|
||||||
"recurrence": 0,
|
"recurrence": 0,
|
||||||
"duration": 1,
|
"duration": 1,
|
||||||
"action": "stop"
|
"action": "stop"
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ file(
|
|||||||
../../src/ubus/capabilities_shutters.cpp
|
../../src/ubus/capabilities_shutters.cpp
|
||||||
../../src/ubus/capabilities_sprinklers.cpp
|
../../src/ubus/capabilities_sprinklers.cpp
|
||||||
../../src/ubus/speach_command.cpp
|
../../src/ubus/speach_command.cpp
|
||||||
|
../../src/ubus/timers.cpp
|
||||||
../../src/helpers/Tokenizer.cpp
|
../../src/helpers/Tokenizer.cpp
|
||||||
../../src/helpers/Strings.cpp
|
../../src/helpers/Strings.cpp
|
||||||
../../src/main.cpp
|
../../src/main.cpp
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ extern "C" {
|
|||||||
#include "ubus/capabilities_shutters.h"
|
#include "ubus/capabilities_shutters.h"
|
||||||
#include "ubus/capabilities_sprinklers.h"
|
#include "ubus/capabilities_sprinklers.h"
|
||||||
#include "ubus/speach_command.h"
|
#include "ubus/speach_command.h"
|
||||||
|
#include "ubus/timers.h"
|
||||||
|
|
||||||
#include "timers/Timers.h"
|
#include "timers/Timers.h"
|
||||||
#include "devices/Devices.h"
|
#include "devices/Devices.h"
|
||||||
@@ -113,19 +114,6 @@ int main (void)
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Capabilities theCapabilities;
|
|
||||||
CapabilitiesLights theCapLights (&theDevices);
|
|
||||||
CapabilitiesShutters theCapShutters (&theDevices);
|
|
||||||
CapabilitiesSprinklers theCapSprinklers (&theDevices);
|
|
||||||
SpeachCommand theSpeachCommand (&theDevices);
|
|
||||||
|
|
||||||
/* Setup the Ubus context. */
|
|
||||||
theCtx = setupUbus ();
|
|
||||||
if (theCtx == NULL) {
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Setup the Timers. */
|
/* Setup the Timers. */
|
||||||
Timers theTimers (theTimerPath, &theDevices);
|
Timers theTimers (theTimerPath, &theDevices);
|
||||||
@@ -134,6 +122,23 @@ int main (void)
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Setup the UBus Models. */
|
||||||
|
CapabilitiesModel theCapabilities;
|
||||||
|
CapabilitiesLightsModel theCapLights (&theDevices);
|
||||||
|
CapabilitiesShuttersModel theCapShutters (&theDevices);
|
||||||
|
CapabilitiesSprinklersModel theCapSprinklers (&theDevices);
|
||||||
|
SpeachCommandModel theSpeachCommand (&theDevices);
|
||||||
|
TimersModel theTimersModel;
|
||||||
|
|
||||||
|
/* Setup the Ubus context. */
|
||||||
|
theCtx = setupUbus ();
|
||||||
|
if (theCtx == NULL) {
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Add the UBus to the model exposed. */
|
/* Add the UBus to the model exposed. */
|
||||||
ubus_add_object (theCtx, &theCapabilities);
|
ubus_add_object (theCtx, &theCapabilities);
|
||||||
@@ -141,6 +146,7 @@ int main (void)
|
|||||||
ubus_add_object (theCtx, &theCapShutters);
|
ubus_add_object (theCtx, &theCapShutters);
|
||||||
ubus_add_object (theCtx, &theCapSprinklers);
|
ubus_add_object (theCtx, &theCapSprinklers);
|
||||||
ubus_add_object (theCtx, &theSpeachCommand);
|
ubus_add_object (theCtx, &theSpeachCommand);
|
||||||
|
ubus_add_object (theCtx, &theTimersModel);
|
||||||
|
|
||||||
/* Main Event Loop. */
|
/* Main Event Loop. */
|
||||||
uloop_run ();
|
uloop_run ();
|
||||||
|
|||||||
@@ -40,30 +40,30 @@ namespace {
|
|||||||
|
|
||||||
using namespace UBus;
|
using namespace UBus;
|
||||||
|
|
||||||
static ObjectType gCapabilitiesUbus_types(
|
static ObjectType gCapabilitiesModelUbus_types(
|
||||||
"capabilities",
|
"capabilities",
|
||||||
Method("get", UBUS_CPP(Capabilities, Get))
|
Method("get", UBUS_CPP(CapabilitiesModel, Get))
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn Capabilities
|
* @fn CapabilitiesModel
|
||||||
*
|
*
|
||||||
* @brief Constructor of the UBus Mixer Volume.
|
* @brief Constructor of the UBus Mixer Volume.
|
||||||
*/
|
*/
|
||||||
Capabilities::Capabilities (void) :
|
CapabilitiesModel::CapabilitiesModel (void) :
|
||||||
UBusObject (gCapabilitiesUbus_types, "domo.capabilities")
|
UBusObject (gCapabilitiesModelUbus_types, "domo.capabilities")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn ~Capabilities
|
* @fn ~CapabilitiesModel
|
||||||
*
|
*
|
||||||
* @brief Destructor of the UBus Mixer Volume.
|
* @brief Destructor of the UBus Mixer Volume.
|
||||||
*/
|
*/
|
||||||
Capabilities::~Capabilities (void)
|
CapabilitiesModel::~CapabilitiesModel (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ Capabilities::~Capabilities (void)
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int Capabilities::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
int CapabilitiesModel::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
||||||
struct blob_attr *aMsg)
|
struct blob_attr *aMsg)
|
||||||
{
|
{
|
||||||
int theResult;
|
int theResult;
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _UBUS_CAPABILITIES_H
|
#ifndef _UBUS_CAPABILITIES_MODEL_H
|
||||||
#define _UBUS_CAPABILITIES_H
|
#define _UBUS_CAPABILITIES_MODEL_H
|
||||||
|
|
||||||
/*------------------------------- INCLUDES ----------------------------------*/
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
@@ -36,15 +36,15 @@
|
|||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
class Capabilities : public UBusObject {
|
class CapabilitiesModel : public UBusObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Capabilities (void);
|
CapabilitiesModel (void);
|
||||||
~Capabilities (void);
|
~CapabilitiesModel (void);
|
||||||
|
|
||||||
int Get (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
int Get (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _UBUS_CAPABILITIES_H */
|
#endif /* _UBUS_CAPABILITIES_MODEL_H */
|
||||||
|
|||||||
@@ -43,20 +43,20 @@ using namespace UBus;
|
|||||||
|
|
||||||
static ObjectType gCapabilitiesLightsUbus_types(
|
static ObjectType gCapabilitiesLightsUbus_types(
|
||||||
"lights",
|
"lights",
|
||||||
Method("get", UBUS_CPP(CapabilitiesLights, Get)),
|
Method("get", UBUS_CPP(CapabilitiesLightsModel, Get)),
|
||||||
Method("delete", UBUS_CPP(CapabilitiesLights, Delete)),
|
Method("delete", UBUS_CPP(CapabilitiesLightsModel, Delete)),
|
||||||
Method("put", UBUS_CPP(CapabilitiesLights, Put)),
|
Method("put", UBUS_CPP(CapabilitiesLightsModel, Put)),
|
||||||
Method("post", UBUS_CPP(CapabilitiesLights, Post))
|
Method("post", UBUS_CPP(CapabilitiesLightsModel, Post))
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn CapabilitiesLights
|
* @fn CapabilitiesLightsModel
|
||||||
*
|
*
|
||||||
* @brief Constructor of the UBus Mixer Volume.
|
* @brief Constructor of the UBus Mixer Volume.
|
||||||
*/
|
*/
|
||||||
CapabilitiesLights::CapabilitiesLights (Devices *aDevice) :
|
CapabilitiesLightsModel::CapabilitiesLightsModel (Devices *aDevice) :
|
||||||
UBusObject (gCapabilitiesLightsUbus_types, "domo.capabilities.lights"),
|
UBusObject (gCapabilitiesLightsUbus_types, "domo.capabilities.lights"),
|
||||||
mDevices (aDevice)
|
mDevices (aDevice)
|
||||||
{
|
{
|
||||||
@@ -64,11 +64,11 @@ CapabilitiesLights::CapabilitiesLights (Devices *aDevice) :
|
|||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn ~CapabilitiesLights
|
* @fn ~CapabilitiesLightsModel
|
||||||
*
|
*
|
||||||
* @brief Destructor of the UBus Mixer Volume.
|
* @brief Destructor of the UBus Mixer Volume.
|
||||||
*/
|
*/
|
||||||
CapabilitiesLights::~CapabilitiesLights (void)
|
CapabilitiesLightsModel::~CapabilitiesLightsModel (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ CapabilitiesLights::~CapabilitiesLights (void)
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesLights::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
int CapabilitiesLightsModel::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
||||||
struct blob_attr *aMsg)
|
struct blob_attr *aMsg)
|
||||||
{
|
{
|
||||||
int theResult;
|
int theResult;
|
||||||
@@ -102,7 +102,7 @@ int CapabilitiesLights::Get (struct ubus_context *aCtx, struct ubus_request_data
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesLights::Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesLightsModel::Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ int CapabilitiesLights::Delete (struct ubus_context*, struct ubus_request_data*,
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesLights::Put (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesLightsModel::Put (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ int CapabilitiesLights::Put (struct ubus_context*, struct ubus_request_data*, st
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesLights::Post (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
int CapabilitiesLightsModel::Post (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
||||||
struct blob_attr *aMsg)
|
struct blob_attr *aMsg)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _UBUS_CAPABILITIES_LIGHTS_H
|
#ifndef _UBUS_CAPABILITIES_LIGHTS_MODEL_H
|
||||||
#define _UBUS_CAPABILITIES_LIGHTS_H
|
#define _UBUS_CAPABILITIES_LIGHTS_MODEL_H
|
||||||
|
|
||||||
/*------------------------------- INCLUDES ----------------------------------*/
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
@@ -41,11 +41,11 @@ class Devices;
|
|||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
class CapabilitiesLights : public UBusObject {
|
class CapabilitiesLightsModel : public UBusObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CapabilitiesLights (Devices *aDevice);
|
CapabilitiesLightsModel (Devices *aDevice);
|
||||||
~CapabilitiesLights (void);
|
~CapabilitiesLightsModel (void);
|
||||||
|
|
||||||
int Get (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
int Get (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
||||||
int Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
int Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
||||||
@@ -56,4 +56,4 @@ private:
|
|||||||
Devices *mDevices;
|
Devices *mDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _UBUS_CAPABILITIES_LIGHTS_H */
|
#endif /* _UBUS_CAPABILITIES_LIGHTS_MODEL_H */
|
||||||
|
|||||||
@@ -39,42 +39,42 @@ namespace {
|
|||||||
|
|
||||||
using namespace UBus;
|
using namespace UBus;
|
||||||
|
|
||||||
static ObjectType gCapabilitiesShuttersUbus_types(
|
static ObjectType gCapabilitiesShuttersModelUbus_types(
|
||||||
"shutters",
|
"shutters",
|
||||||
Method("get", UBUS_CPP(CapabilitiesShutters, Get)),
|
Method("get", UBUS_CPP(CapabilitiesShuttersModel, Get)),
|
||||||
Method("delete", UBUS_CPP(CapabilitiesShutters, Delete)),
|
Method("delete", UBUS_CPP(CapabilitiesShuttersModel, Delete)),
|
||||||
Method("put", UBUS_CPP(CapabilitiesShutters, Put)),
|
Method("put", UBUS_CPP(CapabilitiesShuttersModel, Put)),
|
||||||
Method("post", UBUS_CPP(CapabilitiesShutters, Post)),
|
Method("post", UBUS_CPP(CapabilitiesShuttersModel, Post)),
|
||||||
|
|
||||||
Method("open", UBUS_CPP(CapabilitiesShutters, Open)),
|
Method("open", UBUS_CPP(CapabilitiesShuttersModel, Open)),
|
||||||
Method("close", UBUS_CPP(CapabilitiesShutters, Close)),
|
Method("close", UBUS_CPP(CapabilitiesShuttersModel, Close)),
|
||||||
|
|
||||||
Method("up", UBUS_CPP(CapabilitiesShutters, Up)),
|
Method("up", UBUS_CPP(CapabilitiesShuttersModel, Up)),
|
||||||
Method("down", UBUS_CPP(CapabilitiesShutters, Down)),
|
Method("down", UBUS_CPP(CapabilitiesShuttersModel, Down)),
|
||||||
|
|
||||||
Method("position", UBUS_CPP(CapabilitiesShutters, Position))
|
Method("position", UBUS_CPP(CapabilitiesShuttersModel, Position))
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn CapabilitiesShutters
|
* @fn CapabilitiesShuttersModel
|
||||||
*
|
*
|
||||||
* @brief Constructor of the UBus Mixer Volume.
|
* @brief Constructor of the UBus Mixer Volume.
|
||||||
*/
|
*/
|
||||||
CapabilitiesShutters::CapabilitiesShutters (Devices *aDevice) :
|
CapabilitiesShuttersModel::CapabilitiesShuttersModel (Devices *aDevice) :
|
||||||
UBusObject (gCapabilitiesShuttersUbus_types, "domo.capabilities.shutters"),
|
UBusObject (gCapabilitiesShuttersModelUbus_types, "domo.capabilities.shutters"),
|
||||||
mDevices (aDevice)
|
mDevices (aDevice)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn ~CapabilitiesShutters
|
* @fn ~CapabilitiesShuttersModel
|
||||||
*
|
*
|
||||||
* @brief Destructor of the UBus Mixer Volume.
|
* @brief Destructor of the UBus Mixer Volume.
|
||||||
*/
|
*/
|
||||||
CapabilitiesShutters::~CapabilitiesShutters (void)
|
CapabilitiesShuttersModel::~CapabilitiesShuttersModel (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ CapabilitiesShutters::~CapabilitiesShutters (void)
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesShutters::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
int CapabilitiesShuttersModel::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
||||||
struct blob_attr *aMsg)
|
struct blob_attr *aMsg)
|
||||||
{
|
{
|
||||||
int theResult;
|
int theResult;
|
||||||
@@ -108,7 +108,7 @@ int CapabilitiesShutters::Get (struct ubus_context *aCtx, struct ubus_request_da
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesShutters::Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesShuttersModel::Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ int CapabilitiesShutters::Delete (struct ubus_context*, struct ubus_request_data
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesShutters::Put (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesShuttersModel::Put (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ int CapabilitiesShutters::Put (struct ubus_context*, struct ubus_request_data*,
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesShutters::Post (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesShuttersModel::Post (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ int CapabilitiesShutters::Post (struct ubus_context*, struct ubus_request_data*,
|
|||||||
*
|
*
|
||||||
* @brief Open the Shutter
|
* @brief Open the Shutter
|
||||||
*/
|
*/
|
||||||
int CapabilitiesShutters::Open (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesShuttersModel::Open (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
printf ("Open the Shutter\n");
|
printf ("Open the Shutter\n");
|
||||||
@@ -160,7 +160,7 @@ int CapabilitiesShutters::Open (struct ubus_context*, struct ubus_request_data*,
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesShutters::Close (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesShuttersModel::Close (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
printf ("Close the Shutter\n");
|
printf ("Close the Shutter\n");
|
||||||
@@ -172,7 +172,7 @@ int CapabilitiesShutters::Close (struct ubus_context*, struct ubus_request_data*
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesShutters::Up (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesShuttersModel::Up (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
printf ("Up the Shutter\n");
|
printf ("Up the Shutter\n");
|
||||||
@@ -184,7 +184,7 @@ int CapabilitiesShutters::Up (struct ubus_context*, struct ubus_request_data*, s
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesShutters::Down (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesShuttersModel::Down (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
printf ("Down the Shutter\n");
|
printf ("Down the Shutter\n");
|
||||||
@@ -196,7 +196,7 @@ int CapabilitiesShutters::Down (struct ubus_context*, struct ubus_request_data*,
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesShutters::Position (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesShuttersModel::Position (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
printf ("Position the Shutter\n");
|
printf ("Position the Shutter\n");
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _UBUS_CAPABILITIES_SHUTTERS_H
|
#ifndef _UBUS_CAPABILITIES_SHUTTERS_MODEL_H
|
||||||
#define _UBUS_CAPABILITIES_SHUTTERS_H
|
#define _UBUS_CAPABILITIES_SHUTTERS_MODEL_H
|
||||||
|
|
||||||
/*------------------------------- INCLUDES ----------------------------------*/
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
@@ -38,11 +38,11 @@ class Devices;
|
|||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
class CapabilitiesShutters : public UBusObject {
|
class CapabilitiesShuttersModel : public UBusObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CapabilitiesShutters (Devices *aDevice);
|
CapabilitiesShuttersModel (Devices *aDevice);
|
||||||
~CapabilitiesShutters (void);
|
~CapabilitiesShuttersModel (void);
|
||||||
|
|
||||||
int Get (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
int Get (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
||||||
int Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
int Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
||||||
@@ -61,4 +61,4 @@ private:
|
|||||||
Devices *mDevices;
|
Devices *mDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _UBUS_CAPABILITIES_SHUTTERS_H */
|
#endif /* _UBUS_CAPABILITIES_SHUTTERS_MODEL_H */
|
||||||
|
|||||||
@@ -41,12 +41,12 @@ namespace {
|
|||||||
|
|
||||||
using namespace UBus;
|
using namespace UBus;
|
||||||
|
|
||||||
static ObjectType gCapabilitiesSprinklersUbus_types(
|
static ObjectType gCapabilitiesSprinklersModelUbus_types(
|
||||||
"sprinklers",
|
"sprinklers",
|
||||||
Method("get", UBUS_CPP(CapabilitiesSprinklers, Get)),
|
Method("get", UBUS_CPP(CapabilitiesSprinklersModel, Get)),
|
||||||
Method("delete", UBUS_CPP(CapabilitiesSprinklers, Delete)),
|
Method("delete", UBUS_CPP(CapabilitiesSprinklersModel, Delete)),
|
||||||
Method("put", UBUS_CPP(CapabilitiesSprinklers, Put)),
|
Method("put", UBUS_CPP(CapabilitiesSprinklersModel, Put)),
|
||||||
Method("post", UBUS_CPP(CapabilitiesSprinklers, Post))
|
Method("post", UBUS_CPP(CapabilitiesSprinklersModel, Post))
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -56,19 +56,19 @@ static ObjectType gCapabilitiesSprinklersUbus_types(
|
|||||||
*
|
*
|
||||||
* @brief Constructor of the UBus Mixer Volume.
|
* @brief Constructor of the UBus Mixer Volume.
|
||||||
*/
|
*/
|
||||||
CapabilitiesSprinklers::CapabilitiesSprinklers (Devices *aDevice) :
|
CapabilitiesSprinklersModel::CapabilitiesSprinklersModel (Devices *aDevice) :
|
||||||
UBusObject (gCapabilitiesSprinklersUbus_types, "domo.capabilities.sprinklers"),
|
UBusObject (gCapabilitiesSprinklersModelUbus_types, "domo.capabilities.sprinklers"),
|
||||||
mDevices (aDevice)
|
mDevices (aDevice)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn ~CapabilitiesSprinklers
|
* @fn ~CapabilitiesSprinklersModel
|
||||||
*
|
*
|
||||||
* @brief Destructor of the UBus Mixer Volume.
|
* @brief Destructor of the UBus Mixer Volume.
|
||||||
*/
|
*/
|
||||||
CapabilitiesSprinklers::~CapabilitiesSprinklers (void)
|
CapabilitiesSprinklersModel::~CapabilitiesSprinklersModel (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ CapabilitiesSprinklers::~CapabilitiesSprinklers (void)
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesSprinklers::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
int CapabilitiesSprinklersModel::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
||||||
struct blob_attr *aMsg)
|
struct blob_attr *aMsg)
|
||||||
{
|
{
|
||||||
int theResult;
|
int theResult;
|
||||||
@@ -101,7 +101,7 @@ int CapabilitiesSprinklers::Get (struct ubus_context *aCtx, struct ubus_request_
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesSprinklers::Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesSprinklersModel::Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ int CapabilitiesSprinklers::Delete (struct ubus_context*, struct ubus_request_da
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesSprinklers::Put (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
int CapabilitiesSprinklersModel::Put (struct ubus_context*, struct ubus_request_data*, struct blob_attr*)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ int CapabilitiesSprinklers::Put (struct ubus_context*, struct ubus_request_data*
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int CapabilitiesSprinklers::Post (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
int CapabilitiesSprinklersModel::Post (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
||||||
struct blob_attr *aMsg)
|
struct blob_attr *aMsg)
|
||||||
{
|
{
|
||||||
int theResult;
|
int theResult;
|
||||||
@@ -140,7 +140,7 @@ int CapabilitiesSprinklers::Post (struct ubus_context *aCtx, struct ubus_request
|
|||||||
Json::Value theElement;
|
Json::Value theElement;
|
||||||
int theID;
|
int theID;
|
||||||
bool theState;
|
bool theState;
|
||||||
fprintf (stderr,"CapabilitiesSprinklers::Post \n");
|
fprintf (stderr,"CapabilitiesSprinklersModel::Post \n");
|
||||||
|
|
||||||
if (!theReader.parse (theString, theRoot)) {
|
if (!theReader.parse (theString, theRoot)) {
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _UBUS_CAPABILITIES_SPRINKLERS_H
|
#ifndef _UBUS_CAPABILITIES_SPRINKLERS_MODEL_H
|
||||||
#define _UBUS_CAPABILITIES_SPRINKLERS_H
|
#define _UBUS_CAPABILITIES_SPRINKLERS_MODEL_H
|
||||||
|
|
||||||
/*------------------------------- INCLUDES ----------------------------------*/
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
@@ -38,11 +38,11 @@ class Devices;
|
|||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
class CapabilitiesSprinklers : public UBusObject {
|
class CapabilitiesSprinklersModel : public UBusObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CapabilitiesSprinklers (Devices *aDevice);
|
CapabilitiesSprinklersModel (Devices *aDevice);
|
||||||
~CapabilitiesSprinklers (void);
|
~CapabilitiesSprinklersModel (void);
|
||||||
|
|
||||||
int Get (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
int Get (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
||||||
int Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
int Delete (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
||||||
@@ -53,4 +53,4 @@ private:
|
|||||||
Devices *mDevices;
|
Devices *mDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _UBUS_CAPABILITIES_SPRINKLERS_H */
|
#endif /* _UBUS_CAPABILITIES_SPRINKLERS_MODEL_H */
|
||||||
|
|||||||
@@ -44,31 +44,31 @@ namespace {
|
|||||||
|
|
||||||
using namespace UBus;
|
using namespace UBus;
|
||||||
|
|
||||||
static ObjectType gSpeachCommandUbus_types(
|
static ObjectType gSpeachCommandModelUbus_types(
|
||||||
"speach",
|
"speach",
|
||||||
Method("post", UBUS_CPP(SpeachCommand, Post))
|
Method("post", UBUS_CPP(SpeachCommandModel, Post))
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn SpeachCommand
|
* @fn SpeachCommandModel
|
||||||
*
|
*
|
||||||
* @brief Constructor of the UBus Speach Command execution.
|
* @brief Constructor of the UBus Speach Command execution.
|
||||||
*/
|
*/
|
||||||
SpeachCommand::SpeachCommand (Devices *aDevice) :
|
SpeachCommandModel::SpeachCommandModel (Devices *aDevice) :
|
||||||
UBusObject (gSpeachCommandUbus_types, "domo.speach.command"),
|
UBusObject (gSpeachCommandModelUbus_types, "domo.speach.command"),
|
||||||
mDevices (aDevice)
|
mDevices (aDevice)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! ----------------------------------------------------------------------------
|
/*! ----------------------------------------------------------------------------
|
||||||
* @fn ~SpeachCommand
|
* @fn ~SpeachCommandModel
|
||||||
*
|
*
|
||||||
* @brief Destructor of the UBus Speach Command execution.
|
* @brief Destructor of the UBus Speach Command execution.
|
||||||
*/
|
*/
|
||||||
SpeachCommand::~SpeachCommand (void)
|
SpeachCommandModel::~SpeachCommandModel (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ SpeachCommand::~SpeachCommand (void)
|
|||||||
*
|
*
|
||||||
* @brief Get the List of the Capabilities.
|
* @brief Get the List of the Capabilities.
|
||||||
*/
|
*/
|
||||||
int SpeachCommand::Post (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
int SpeachCommandModel::Post (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
||||||
struct blob_attr *aMsg)
|
struct blob_attr *aMsg)
|
||||||
{
|
{
|
||||||
int theResult = 0;
|
int theResult = 0;
|
||||||
@@ -121,7 +121,7 @@ int SpeachCommand::Post (struct ubus_context *aCtx, struct ubus_request_data *aR
|
|||||||
*
|
*
|
||||||
* @brief analyse and Execute the following commmand.
|
* @brief analyse and Execute the following commmand.
|
||||||
*/
|
*/
|
||||||
int SpeachCommand::AnalyseAndExecute (std::string aCommand)
|
int SpeachCommandModel::AnalyseAndExecute (std::string aCommand)
|
||||||
{
|
{
|
||||||
std::vector <std::string> theTokens;
|
std::vector <std::string> theTokens;
|
||||||
Tokenizer s(aCommand, " ");
|
Tokenizer s(aCommand, " ");
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _UBUS_SPEACH_COMMANDS_H
|
#ifndef _UBUS_SPEACH_COMMANDS_MODEL_H
|
||||||
#define _UBUS_SPEACH_COMMANDS_H
|
#define _UBUS_SPEACH_COMMANDS_MODEL_H
|
||||||
|
|
||||||
/*------------------------------- INCLUDES ----------------------------------*/
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
@@ -41,11 +41,11 @@ class Devices;
|
|||||||
|
|
||||||
/*--------------------------------- CLASS ----------------------------------*/
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
class SpeachCommand : public UBusObject {
|
class SpeachCommandModel : public UBusObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SpeachCommand (Devices *aDevice);
|
SpeachCommandModel (Devices *aDevice);
|
||||||
~SpeachCommand (void);
|
~SpeachCommandModel (void);
|
||||||
|
|
||||||
int Post (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
int Post (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
||||||
|
|
||||||
@@ -54,4 +54,4 @@ private:
|
|||||||
Devices *mDevices;
|
Devices *mDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _UBUS_SPEACH_COMMANDS_H */
|
#endif /* _UBUS_SPEACH_COMMANDS_MODEL_H */
|
||||||
|
|||||||
93
src/domod/src/ubus/timers.cpp
Normal file
93
src/domod/src/ubus/timers.cpp
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*!
|
||||||
|
* TimersModel.cpp
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016, 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 ---------------------------------*/
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <libubox/blobmsg_json.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "timers.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
using namespace UBus;
|
||||||
|
|
||||||
|
static ObjectType gTimersModelUbus_types(
|
||||||
|
"TimersModel",
|
||||||
|
Method("get", UBUS_CPP(TimersModel, Get))
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*! ----------------------------------------------------------------------------
|
||||||
|
* @fn TimersModel
|
||||||
|
*
|
||||||
|
* @brief Constructor of the UBus Mixer Volume.
|
||||||
|
*/
|
||||||
|
TimersModel::TimersModel (void) :
|
||||||
|
UBusObject (gTimersModelUbus_types, "domo.timers")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! ----------------------------------------------------------------------------
|
||||||
|
* @fn ~TimersModel
|
||||||
|
*
|
||||||
|
* @brief Destructor of the UBus Mixer Volume.
|
||||||
|
*/
|
||||||
|
TimersModel::~TimersModel (void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! ----------------------------------------------------------------------------
|
||||||
|
* @fn Get
|
||||||
|
*
|
||||||
|
* @brief Get the List of the Capabilities.
|
||||||
|
*/
|
||||||
|
int TimersModel::Get (struct ubus_context *aCtx, struct ubus_request_data *aReq,
|
||||||
|
struct blob_attr *aMsg)
|
||||||
|
{
|
||||||
|
int theResult = 0;
|
||||||
|
printf ("Get the TimersModel\n");
|
||||||
|
#if 0
|
||||||
|
struct blob_buf theBuf = {0};
|
||||||
|
|
||||||
|
std::ifstream theCapFile ("./rsc/capabilities.json");
|
||||||
|
std::stringstream theBuffer;
|
||||||
|
theBuffer << theCapFile.rdbuf();
|
||||||
|
|
||||||
|
blob_buf_init (&theBuf, 0);
|
||||||
|
|
||||||
|
blobmsg_add_json_from_string (&theBuf, theBuffer.str().c_str());
|
||||||
|
|
||||||
|
theResult = ubus_send_reply (aCtx, aReq, theBuf.head);
|
||||||
|
|
||||||
|
blob_buf_free (&theBuf);
|
||||||
|
#endif
|
||||||
|
return theResult;
|
||||||
|
}
|
||||||
50
src/domod/src/ubus/timers.h
Normal file
50
src/domod/src/ubus/timers.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*!
|
||||||
|
* timers.h
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016, 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _UBUS_TIMERS_H
|
||||||
|
#define _UBUS_TIMERS_H
|
||||||
|
|
||||||
|
/*------------------------------- INCLUDES ----------------------------------*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <ubuscpp/UBusObject.h>
|
||||||
|
|
||||||
|
/*--------------------------------- Define ----------------------------------*/
|
||||||
|
|
||||||
|
/*--------------------------------- CLASS ----------------------------------*/
|
||||||
|
|
||||||
|
class TimersModel : public UBusObject {
|
||||||
|
|
||||||
|
public:
|
||||||
|
TimersModel (void);
|
||||||
|
~TimersModel (void);
|
||||||
|
|
||||||
|
int Get (struct ubus_context*, struct ubus_request_data*, struct blob_attr*);
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _UBUS_TIMERS_H */
|
||||||
Reference in New Issue
Block a user